Last active
June 23, 2018 08:51
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ------------------------------------------------------ | |
Displayコールバック実験 | |
--------------------------------------------------------*/ | |
#include <GL/glut.h> | |
#include <iostream> | |
int display_num = 0; | |
// 描画処理が必要なときに呼ばれる | |
void display(void) | |
{ | |
display_num++; | |
std::cout << "display : " << display_num << "回目" << std::endl; | |
glClear(GL_COLOR_BUFFER_BIT); // カラーバッファを初期化する | |
glFlush(); // 描画を行う | |
} | |
void initialize(void) | |
{ | |
glClearColor(1.0, 1.0, 1.0, 1.0); // 画面を白にする | |
} | |
int main(int argc, char** argv) | |
{ | |
glutInit(&argc, argv); // GLUTを初期化する | |
glutInitWindowSize(800, 600); // 画面サイズを指定する | |
glutInitWindowPosition(100, 100); // 画面の初期位置を指定する | |
glutInitDisplayMode(GLUT_RGBA); // 表示モード設定 | |
glutCreateWindow("OpenGL Window"); // ウィンドウの名前 | |
// コールバック関数の設定 | |
glutDisplayFunc(display); // 描画処理が必要なときに呼ばれる | |
initialize(); // 初期化 | |
glutMainLoop(); // 毎フレームのLoop | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment