現在地 >> メニュー >> サンプルコード::OpenGL >> ドラッグ処理

次 >> ドラッグ処理2

問題


ウィンドウを作成し、ドラッグ処理を行ってる間、
何かをコマンドプロンプトに表示せよ。

答え


#include <cstdio>
#include <GL/glut.h>

void display();
void MouseDrug(int x, int y);

using namespace std;


inline void GLUT_INIT()
{
glutInitDisplayMode(GLUT_RGBA);
}


inline void GLUT_CALL_FUNC()
{
glutDisplayFunc(display);
glutMotionFunc(MouseDrug);
}

inline void MY_INIT()
{
glClearColor(0.0, 1.0, 0.0, 1.0);
}


int main(int argc, char **argv)
{
glutInit(&argc,argv);
GLUT_INIT();

glutCreateWindow("window name");

GLUT_CALL_FUNC();
MY_INIT();

glutMainLoop();

return 0;
}

/********[ここからコールバック]****************************************/
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glFlush();

}

void MouseDrug(int x, int y)
{
printf("X = %d : Y = %d\n" , x , y);

}

メモ


どのボタン反応する。
特定のボタンのドラッグ処理には、フラグが必要。

目次

― その他 ―

Wiki内検索

計測中...(07.10.8〜)

Save The World






▲よろしければ広告のクリックもお願いします


▲ランキングに参加しました

管理人/副管理人のみ編集できます