void MainWindow::initGlut() { // Create dummy arguments for command line options int dummy_argc = 1; char *dummy_argv[1]; dummy_argv[0] = new char[255]; dummy_argv[0] = (char*)"Main Window"; // Initialize glut toolkit glutInit(&dummy_argc, dummy_argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(100,100); glutInitWindowSize(762, 576); glutCreateWindow("3D-Viewer"); glutSetKeyRepeat(1); //Register callback functions glutDisplayFunc(MainWindow::callback_render); glutReshapeFunc(MainWindow::callback_reshape); glutMouseFunc(MainWindow::callback_mouse); glutMotionFunc(MainWindow::callback_motion); glutKeyboardFunc(MainWindow::callback_key); glutKeyboardUpFunc(MainWindow::callback_keyUp); glutSpecialFunc(MainWindow::callback_specialkey); glutSpecialUpFunc(MainWindow::callback_specialkeyUp); glutTimerFunc(15, MainWindow::callback_timer, 0); // glutIdleFunc(MainWindow::callback_render); // Init OpenGL stuff initGL(); // Call glut main loop to hold window at top glutMainLoop(); }
void game_init(int* argc, char** argv, const char* title) { glutInit(argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitWindowSize(800, 600); glutInitContextVersion(3, 1); glutInitContextProfile(GLUT_FORWARD_COMPATIBLE); glutInitContextProfile(GLUT_CORE_PROFILE); glutCreateWindow(title); glewExperimental = true; glewInit(); glutKeyboardFunc(keyboard_down); glutKeyboardUpFunc(keyboard_up); glutSpecialFunc(keyboard_special_down); glutSpecialUpFunc(keyboard_special_up); glutCloseFunc(window_close); glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); bodies = list_new(); body_program = pipeline_new( shader_new(SHADER_VERTEX, "body.vert"), shader_new(SHADER_FRAGMENT, "body.frag")); glGenVertexArrays(1, &body_vao); glBindVertexArray(body_vao); pipeline_attribute(body_program, "coord", 0); pipeline_attribute(body_program, "color", 1); }
void Sim::init(int* argc, char* argv[], const string& title) { glutInit(argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(800, 800); glutInitContextVersion(3, 1); glutInitContextProfile(GLUT_FORWARD_COMPATIBLE); glutInitContextProfile(GLUT_CORE_PROFILE); glutCreateWindow(title.c_str()); glewExperimental = true; glewInit(); glutKeyboardFunc(keyboard_down); glutKeyboardUpFunc(keyboard_up); glutSpecialFunc(keyboard_special_down); glutSpecialUpFunc(keyboard_special_up); glutReshapeFunc(reshape); glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF); glEnable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearColor(0.0, 0.0, 0.0, 1.0); glShadeModel(GL_SMOOTH); }
void CKeyboard::keySpOps(void){ if(keySpMap[GLUT_KEY_F1]){ if(!keyRepeat) printf("Key Repeat Enabled\n"); else printf("Key Repeat Disabled\n"); keyRepeat=!keyRepeat; glutSetKeyRepeat(keyRepeat); } }
//Entry point. int main(int argc, char **argv) { init(argc, argv); glutDisplayFunc(display); glutTimerFunc(1000 / 60, timer, 0); glutSetKeyRepeat(0); glutKeyboardFunc(keyDown); glutKeyboardUpFunc(keyUp); glutReshapeFunc(reshape); glutMainLoop(); return 0; }
//GlutInstace Class Constructor(Default and 5 argument version) Glut2D::Glut2D(const std::string& windowCaption,const int windowWidth,const int windowHeight,void(*timer)(Glut2D&), const unsigned int timerTime,void(*display)(Glut2D&)):camera(),_windowID(-1),_windowWidth(windowWidth),_windowHeight(windowHeight), _active(false),_timer(timer),_timerTime(timerTime),_display(display),_dt(0.0),_ot(0.0),_mouseX(0),_mouseY(0) { //Check Timer Function if(!_timer) { throw std::runtime_error("Glut2D - Invalid timer function!!!"); } //Check Display Function if(!_display) { throw std::runtime_error("Glut2D - Invalid display function!!!"); } //Add to Static Vector _instance.push_back(this); //Set Window Size and Create Window glutInitWindowSize(_windowWidth,_windowHeight); _windowID=glutCreateWindow(windowCaption.c_str()); //Input Functions glutKeyboardFunc(keyboardDown); glutKeyboardUpFunc(keyboardUp); glutSpecialFunc(specialDown); glutSpecialUpFunc(specialUp); glutMouseFunc(mouse); glutEntryFunc(mouseEntry); glutMotionFunc(motion); glutPassiveMotionFunc(motion); glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF); //Window Functions glutReshapeFunc(Glut2D::reshape); glutWindowStatusFunc(Glut2D::windowStatus); //Timer Function glutTimerFunc(_timerTime,Glut2D::timer,0); //Display Function glutDisplayFunc(Glut2D::display); //Enable Color Key Transparency glEnable(GL_ALPHA_TEST); glAlphaFunc(GL_GREATER,0.0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); }
void Kengine::InitGlut(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_RGBA | GLUT_DOUBLE); glutInitWindowPosition(50, 50); glutInitWindowSize(640, 480); glClearColor(0.f, 0.f, 0.f, 0.f); glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF); glEnable(GL_DEPTH_TEST); windowId = glutCreateWindow("Derp"); }
void Kengine::InitGlut(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_RGBA | GLUT_DOUBLE); glutInitWindowPosition(50, 50); glutInitWindowSize(640, 480); glClearColor(0.f, 0.f, 0.f, 0.f); glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF); // Use both! glEnable(GL_CULL_FACE); glCullFace(GL_FRONT_AND_BACK); windowId = glutCreateWindow("Derp"); }
void GlutInit() { glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF) ; glutKeyboardFunc(KeyboardDown); glutKeyboardUpFunc(KeyboardUp); glutSpecialFunc(SpecialDown); glutSpecialUpFunc(SpecialUp); glutMouseFunc(MouseButton); glutMotionFunc(MouseMotion); glutPassiveMotionFunc(MouseMotion); glutDisplayFunc(Display); glutIdleFunc(Display); glutReshapeFunc(Reshape); glutEntryFunc(MouseEntry); //glutVisibilityFunc(visible); }
static void keySpOps(void) { static int cur_color = 0; if(keySpMap[GLUT_KEY_F1]) { if(!keyRepeat)printf("Key Repeat Enabled\n"); else printf("Key Repeat Disabled\n"); keyRepeat=!keyRepeat; glutSetKeyRepeat(keyRepeat); } if(keySpMap[GLUT_KEY_RIGHT]) { cur_color = (cur_color + 1) % num_colors; CrystalColors[0] = colorPick[cur_color]; redisplay = true; } if(keySpMap[GLUT_KEY_LEFT]) { cur_color = (cur_color + num_colors - 1) % num_colors; CrystalColors[0] = colorPick[cur_color]; redisplay = true; } }
int main(int ac, char **av) { sConfig->addParam("-a", "--addr", "map generator address", TYPE_FLAG_AND_VALUE, "127.0.0.1"); sConfig->addParam("-p", "--port", "map generator port", TYPE_FLAG_AND_VALUE, "9000"); sConfig->parseParam(ac, av); srand(time(NULL)); //map = MapGenerator::CreateNewRandomMap(WIDTH, HEIGHT, 0.35, 0.35); map = MapGenerator::GetNewMapFromNode(WIDTH, HEIGHT, 0.35, 0.42, sConfig->getFlagValue("-a"), sConfig->getFlagValue("-p")); player = new Object(2, 7.0f, 7.0f, 0.0f, 0.0f); map->AddObject(player); glutInit(&ac, av); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(1280, 720); glutCreateWindow("OpenGL fps"); glClearColor(0.2, 0.2, 0.2, 1.0); glEnable(GL_DEPTH_TEST); for (int i = 0; i < 257; ++i) keyStates[i] = false; glutDisplayFunc(draw); glutReshapeFunc(handleResize); glutSpecialFunc(keySpecial); glutKeyboardFunc(keyPressed); glutKeyboardUpFunc(keyUp); glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF); glutIdleFunc(idle); glutVisibilityFunc(visibility); UpdatePlayerPosition(); //keyOperations(); glutPostRedisplay(); glutMainLoop(); return 0; }
static int SetKeyRepeat(lua_State *L) { int mode = KeyCodes[checkoption(L, 1, NULL, KeyStrings)]; glutSetKeyRepeat(mode); return 0; }
/* * Class: gruenewa_opengl_GLUT__ * Method: glutSetKeyRepeat * Signature: (I)V */ JNIEXPORT void JNICALL Java_gruenewa_opengl_GLUT_00024_glutSetKeyRepeat (JNIEnv * jenv, jobject jobj, jint arg1) { glutSetKeyRepeat(arg1); }