5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

c++でopenGLをはじめた

Posted at

1.はじめに

今C++でプログラムを作っていて、グラフィックが必要でもともとUnityでやろうと思っていたが、C++のプログラムを呼び出すのが無料版ではできなさそうなのでopenGLでグラフィックを。

今回は本当に触りの部分で、以下のようなウィンドウを表示させます。

window.png

2.プログラム

test.cpp
# include <GL/glut.h>

void display()
{
}

int main(int argc, char *argv[]){
	// 初期化
	glutInit(&argc, argv);
	// ウィンドウを開く
	glutCreateWindow("Hello OpenGL/GLUT world.");
	// ウィンドウへの描画関数の登録
	glutDisplayFunc(display);
	// メインループ開始
	glutMainLoop();
	return 0;
}

3. ターミナルコマンド

$ gcc test.cpp -framework GLUT -framework OpenGL -Wno-deprecated
$ ./a.out

これで実行できました。

5
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?