最終更新: mikk_ni3_92 2007年12月14日(金) 15:36:01履歴
現在地 >> メニュー >> サンプルコード::OpenGL >> PLIB::メニュー
#include <cstdio>
#include <GL/glut.h>
#include <plib/pu.h>
void PLIB_MENU();
void display();
void mouse(int button, int state,int x, int y);
void motion(int x, int y);
void PLIB_EXIT_CB ( puObject * );
void PLIB_HELLO_CB ( puObject * );
using namespace std;
/************ OpenGLの初期設定 *********************/
inline void GLUT_INIT()
{
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
}
inline void GLUT_CALL_FUNC()
{
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutPassiveMotionFunc(motion);
}
inline void MY_INIT()
{
glClearColor(0.0, 1.0, 0.0, 1.0);
}
/****************** PLIBの初期設定 *************************/
inline void PLIB_INIT()
{
puInit () ;
PLIB_MENU();
}
void PLIB_MENU()
{
char *file_submenu[] = { "Exit","HELLO" ,NULL};
puCallback file_submenu_cb [] = { PLIB_EXIT_CB,PLIB_HELLO_CB,NULL};
puMenuBar *menu = new puMenuBar ( -1 ) ;
menu->add_submenu ( "File", file_submenu, file_submenu_cb ) ;
menu->close () ;
}
/************** メイン関数 ******************/
int main(int argc, char **argv)
{
glutInit(&argc,argv);
GLUT_INIT();
glutCreateWindow("window name");
GLUT_CALL_FUNC();
MY_INIT();
PLIB_INIT();
glutMainLoop();
return 0;
}
/********[ここからコールバック]****************************************/
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
puDisplay () ;
glutSwapBuffers() ;
glutPostRedisplay() ;
}
void mouse(int button, int state,int x, int y)
{
puMouse ( button, state, x, y ) ;
glutPostRedisplay() ;
}
void motion( int x, int y )
{
puMouse ( x, y ) ;
glutPostRedisplay () ;
}
/***************[plibコールバック]*********************************/
void PLIB_EXIT_CB ( puObject * )
{
exit(0);
}
void PLIB_HELLO_CB ( puObject * )
{
printf("hello\n");
}
#include <cstdio>
#include <GL/glut.h>
#include <plib/pu.h>
void PLIB_MENU();
void display();
void mouse(int button, int state,int x, int y);
void motion(int x, int y);
void PLIB_EXIT_CB ( puObject * );
void PLIB_HELLO_CB ( puObject * );
using namespace std;
/************ OpenGLの初期設定 *********************/
inline void GLUT_INIT()
{
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
}
inline void GLUT_CALL_FUNC()
{
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutPassiveMotionFunc(motion);
}
inline void MY_INIT()
{
glClearColor(0.0, 1.0, 0.0, 1.0);
}
/****************** PLIBの初期設定 *************************/
inline void PLIB_INIT()
{
puInit () ;
PLIB_MENU();
}
void PLIB_MENU()
{
char *file_submenu[] = { "Exit","HELLO" ,NULL};
puCallback file_submenu_cb [] = { PLIB_EXIT_CB,PLIB_HELLO_CB,NULL};
puMenuBar *menu = new puMenuBar ( -1 ) ;
menu->add_submenu ( "File", file_submenu, file_submenu_cb ) ;
menu->close () ;
}
/************** メイン関数 ******************/
int main(int argc, char **argv)
{
glutInit(&argc,argv);
GLUT_INIT();
glutCreateWindow("window name");
GLUT_CALL_FUNC();
MY_INIT();
PLIB_INIT();
glutMainLoop();
return 0;
}
/********[ここからコールバック]****************************************/
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
puDisplay () ;
glutSwapBuffers() ;
glutPostRedisplay() ;
}
void mouse(int button, int state,int x, int y)
{
puMouse ( button, state, x, y ) ;
glutPostRedisplay() ;
}
void motion( int x, int y )
{
puMouse ( x, y ) ;
glutPostRedisplay () ;
}
/***************[plibコールバック]*********************************/
void PLIB_EXIT_CB ( puObject * )
{
exit(0);
}
void PLIB_HELLO_CB ( puObject * )
{
printf("hello\n");
}