Skip to content

Instantly share code, notes, and snippets.

@YHaruoka
Last active June 23, 2018 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YHaruoka/71f33457c4f122b09bcc58de03742647 to your computer and use it in GitHub Desktop.
Save YHaruoka/71f33457c4f122b09bcc58de03742647 to your computer and use it in GitHub Desktop.
/* ------------------------------------------------------
  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