int kl_vid_init() { kl_glfw_init(); glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 4); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 1); glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); if (glfwOpenWindow(1280, 720, 8, 8, 8, 0, 24, 8, GLFW_WINDOW) < 0) { //if (glfwOpenWindow(1920, 1080, 8, 8, 8, 0, 24, 8, GLFW_FULLSCREEN) < 0) { fprintf(stderr, "vid-glfw -> failed to create window\n"); return -1; } glfwSetWindowTitle("Kludge Engine"); glfwSwapInterval(0); /* VSync disabled */ return 0; }
int main(int argc, char* argv[]) { int rc; rc = glfwInit(); if(!rc) sys_err("glfwInit() failed"); int w = 640; int h = 480; int r = 0; int g = 0; int b = 0; int a = 0; int d = 0; int s = 0; rc = glfwOpenWindow(w, h, r, g, b, a, d, s, GLFW_WINDOW); if(!rc) { int errn = errno; glfwTerminate(); sys_errno(errn, "glfwOpenWindow() failed"); } font_set_color(1, 1, 1, 0); glClearColor(0.3f, 0.3f, 0.3f, 1.0f); while(1) { glClear(GL_COLOR_BUFFER_BIT); int x = 50; int y = 50; const char* txt = "howdy"; font_draw(x, y, txt); glfwSwapBuffers(); if(!glfwGetWindowParam(GLFW_OPENED)) break; } glfwTerminate(); return 0; }
bool CApp::initialize(const char* title, int width, int height, bool fullscreen) { // Try to initialize OpenGL if (!glfwInit()) { std::cout << "Unable to initialize OpenGL!" << std::endl; return false; } // Setup GLFW Profile glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // Try to open the window int mode = fullscreen ? GLFW_FULLSCREEN : GLFW_WINDOW; if (!glfwOpenWindow(width, height, 0, 0, 0, 0, 32, 0, mode)) { std::cout << "Unable to open window!" << std::endl; glfwTerminate(); return false; } glfwSetWindowTitle(title); // Try to initialize GLEW glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { std::cout << "Failed to initialize GLEW!" << std::endl; return false; } // Enable sticky keys for capturing glfwEnable(GLFW_STICKY_KEYS); // Try to initialize the Renderer if (!Renderer.initialize()) { std::cout << "Unable to initialize Renderer!" << std::endl; glfwTerminate(); return false; } // Callbacks glfwSetWindowSizeCallback(resize); return true; }
int main() { std::cout << "Starting GLFW and opening window." << std::endl; glfwInit(); glfwOpenWindow(800, 600, 8, 8, 8, 8, 8, 0, GLFW_WINDOW); glfwSetKeyCallback(keyPressed); glEnable(GL_DEPTH_TEST); std::cout << "Starting GLEW." << std::endl; std::cout << "Starting Main Loop." << std::endl; glClearColor(1.0, 1.0, 1.0, 1.0); while(true) { draw(); if(glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam(GLFW_OPENED)) break; } std::cout << "Starting Ending." << std::endl; glfwTerminate(); return 0; }
bool GLFWWindow::open(const std::string& title, uint width, uint height) { if(opened) return true; this->title = title; this->width = width; this->height = height; if(glfwInit() == GL_FALSE) { logError("cannot initialize GLFW"); return false; } glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3); glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); if(!glfwOpenWindow(width, height, 8, 8, 8, 8, 24, 8, GLFW_WINDOW)) { logError("cannot open the GLFW window"); return false; } if(!glxwInit()) return false; glfwSetWindowTitle(title.c_str()); glfwSetMouseButtonCallback(&mouseButtonCallback); glfwSetMousePosCallback(&mousePosCallback); glfwSetMouseWheelCallback(&mouseWheelCallback); glfwSetKeyCallback(&keyCallback); this->opened = true; return true; }
void Init() { const int window_width = 800, window_height = 600; if (glfwInit() != GL_TRUE) Shut_Down(1); glfwEnable(GLFW_KEY_REPEAT); // test for issue #3059 int red_bits = glfwGetWindowParam(GLFW_RED_BITS); glfwOpenWindowHint(GLFW_RED_BITS, 8); assert(glfwGetWindowParam(GLFW_RED_BITS) == 8); glfwOpenWindowHint(GLFW_RED_BITS, red_bits); // 800 x 600, 16 bit color, no depth, alpha or stencil buffers, windowed if (glfwOpenWindow(window_width, window_height, 5, 6, 5, 0, 0, 0, GLFW_WINDOW) != GL_TRUE) Shut_Down(1); glfwSetWindowTitle("The GLFW Window"); glfwSetKeyCallback( OnKeyPressed ); glfwSetCharCallback( OnCharPressed ); glfwSetWindowCloseCallback(OnClose); glfwSetWindowSizeCallback(OnResize); glfwSetWindowRefreshCallback(OnRefresh); glfwSetMouseWheelCallback(OnMouseWheel); glfwSetMousePosCallback(OnMouseMove); glfwSetMouseButtonCallback(OnMouseClick); // set the projection matrix to a normal frustum with a max depth of 50 glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspect_ratio = ((float)window_height) / window_width; glFrustum(.5, -.5, -.5 * aspect_ratio, .5 * aspect_ratio, 1, 50); glMatrixMode(GL_MODELVIEW); PullInfo(); }
int glfw_init() { //sprawdzamy, czy mozemy odpalic GLFW if( !glfwInit() ) { //inicjalizowanie glfw fprintf( stderr, "Nie udalo sie uruchomic GLFW\n" ); return -1; } // void glfwOpenWindowHint( int target, int hint ) // Funkcja ustawia wlasciwosci dla okna ktore ma by otwarte. Aby zostaly one // zarejestrowane, musza byc ustawione przed otwarciem okna glfwOpenWindow. glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); // antialiasing = 4x glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // wersja OpenGL = 3.3 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3); glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // nie chcemy starego OpenGL // otwieramy okno // glfwOpenWindow ( int width, int height, // int redbits, int greenbits, int bluebits, int alphabits, // int dephbits, int stencilbits, int mode ) if( !glfwOpenWindow( 1900, 1000, 0,0,0,0, 32,0, GLFW_WINDOW ) ) { fprintf(stderr, "Nie udalo sie otworzyc okna GLFW\n" ); glfwTerminate(); // zabija wszystkie watki zwiazane z glfw return -1; } // odpalamy glew glewExperimental=true; if( glewInit() != GLEW_OK ) { fprintf(stderr, "Nie udalo sie uruchomic GLEW\n" ); return -1; } // nadajemy tytul belce glownej glfwSetWindowTitle( "Trojkat" ); // nasluchujemy czy zostal wcisniety jakis klawisz. // GLFW_STICKY_KEYS loguje wszystkie operacje wcisniecia i wysyla je do glfwGetKey (dodaje do jakiejs kolejki) glfwEnable( GLFW_STICKY_KEYS ); }
void CEngine::_WindowInit(char *WindowTitle, E_ENGINE_INITIALISATION_FLAGS InitFlags) { glfwInit(); glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); GLFWvidmode DesktopMode; glfwGetDesktopMode(&DesktopMode); _Width = DesktopMode.Width; _Height = DesktopMode.Height; if(!glfwOpenWindow(_Width, _Height, DesktopMode.RedBits, DesktopMode.GreenBits, DesktopMode.BlueBits, 8, 8, 0, (InitFlags & EIF_FULLSCREEN)? GLFW_FULLSCREEN : GLFW_WINDOW)) { glfwTerminate(); } glfwSetWindowTitle(WindowTitle); glfwSetWindowSizeCallback( WindowResize ); glfwGetWindowSize( &_Width, &_Height); glfwSwapInterval(1); _Height = _Height > 0 ? _Height : 1; }
bool setupWindow( int width, int height, bool fullscreen ) { // Create OpenGL window if( !glfwOpenWindow( width, height, 8, 8, 8, 8, 24, 8, fullscreen ? GLFW_FULLSCREEN : GLFW_WINDOW ) ) { glfwTerminate(); return false; } if( !fullscreen ) glfwSetWindowTitle( caption.c_str() ); // Disable vertical synchronization glfwSwapInterval( 0 ); // Set listeners glfwSetWindowCloseCallback( windowCloseListener ); glfwSetKeyCallback( keyPressListener ); glfwSetMousePosCallback( mouseMoveListener ); glfwSetMouseButtonCallback( mouseButtonListener ); return true; }
static int open_window(int width, int height, int mode) { double base = glfwGetTime(); if (!glfwOpenWindow(width, height, 0, 0, 0, 0, 16, 0, mode)) { fprintf(stderr, "Failed to create %s mode GLFW window\n", get_mode_name(mode)); return 0; } glfwSetWindowTitle("Window Re-opener"); glfwSetWindowSizeCallback(window_size_callback); glfwSetWindowCloseCallback(window_close_callback); glfwSetKeyCallback(key_callback); glfwSwapInterval(1); printf("Opening %s mode window took %0.3f seconds\n", get_mode_name(mode), glfwGetTime() - base); return 1; }
int openWindow() { if (!glfwInit()) { fprintf( stderr, "Failed to initialize GLFW\n" ); return -1; } glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 2); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 1); glewExperimental = GL_TRUE; if(!glfwOpenWindow(800, 600, 0,0,0,0, 32,0, GLFW_WINDOW)) { fprintf(stderr, "Failed to open GLFW window\n"); glfwTerminate(); return -1; } if (glewInit() != GLEW_OK) { fprintf(stderr, "Failed to initialize GLEW\n"); return -1; } glfwSetWindowTitle("Triangles"); return 0; }
int main_GLFW(AppData& app_data) { GLFWInitializer glfw_initializer; if(!glfwOpenWindow( app_data.render_width, app_data.render_height, 8, 8, 8, 8, 32, 8, GLFW_WINDOW )) throw std::runtime_error("Error creating GLFW window"); else { glfwSetWindowTitle("CloudTrace: OGLplus cloud ray-tracer"); glfwPollEvents(); GLAPIInitializer api_init; render_loop(app_data); } return 0; }
void Screen::Open(uint16 width, uint16 height, bool fullscreen) { // Abrimos la ventana glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE, GL_TRUE); glfwOpenWindow(int(width), int(height), 8, 8, 8, 8, 0, 0, fullscreen ? GLFW_FULLSCREEN : GLFW_WINDOW ); if ( !fullscreen ) glfwSetWindowPos((GetDesktopWidth()-width)/2, (GetDesktopHeight()-height)/2); glfwSetWindowCloseCallback(GLFWwindowclosefun(CloseCallback)); glfwSwapInterval(1); SetTitle(""); opened = true; // Inicializamos los estados de OpenGL glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); // Configuramos viewport glViewport(0, 0, width, height); this->width = width; this->height = height; // Configuramos matriz de proyeccion glMatrixMode(GL_PROJECTION); glLoadIdentity(); // INVERTIMOS -> Modo espejo. glOrtho(0, width, height, 0, 0, 1000); // El 1000 podría ser un 1. // Configuramos matriz de modelado glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Inicializamos temporizador lastTime = glfwGetTime(); elapsed = 0; }
void opengl_driver_dummy( void ) { // This just a test to see if the appropriate libraries are linking; I don't intend to actually call this fn. Public only to keep gcc from muttering about unused code. // int running = GL_TRUE; // Initialize GLFW // if (!glfwInit()) exit( EXIT_FAILURE ); // Open an OpenGL window // if( !glfwOpenWindow( 300,300, 0,0,0,0,0,0, GLFW_WINDOW ) ) { glfwTerminate(); exit( EXIT_FAILURE ); } // Main loop while( running ) { // OpenGL rendering goes here... glClear( GL_COLOR_BUFFER_BIT ); glfwSwapBuffers(); // Swap front and back rendering buffers running = !glfwGetKey( GLFW_KEY_ESC ) // Check if ESC key was pressed or window was closed && glfwGetWindowParam( GLFW_OPENED ); } glfwTerminate(); // Close window and terminate GLFW exit( EXIT_SUCCESS ); // Exit program }
//************CONSTRUCTORS************ //Initializes OpenGL functions, default window size (800x600) and calls openGL standard initialize functions and creates the main window OpenGL::OpenGL() { height = 600; width = 800; if(glfwInit() == 0) { cgl::Error("Could not initialize GLFWInit()"); } if(glfwOpenWindow((int)this->width,(int)this->height,0,0,0,0,0,0,GLFW_WINDOW) != 1) { cgl::Error("Could not open GLFW Window"); } GLenum initReturn; if((initReturn = glewInit()) != GLEW_OK) { std::cout << glewGetErrorString(initReturn)<< std::endl; exit(1); } glfwSetWindowPos(0,0); glfwSetWindowTitle("Custom Game Library"); currentViewportHeight = 600; currentViewportWidth = 800; }
int init(){ if( !glfwInit() ) { fprintf( stderr, "Failed to initialize GLFW\n" ); return -1; } glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4); // 4x antialiasing width = 1024; height = 768; // Open a window and create its OpenGL context if( !glfwOpenWindow( width, height, 0,0,0,0, 32,0, GLFW_WINDOW ) ) { fprintf( stderr, "Failed to open GLFW window\n" ); glfwTerminate(); return -1; } glfwSetWindowTitle( "Tutorial" ); glfwEnable( GLFW_STICKY_KEYS ); init_gl(); return 0; }
void start_window() { glfwInit(); glfwOpenWindow(WindowWidth, WindowHeight, 5, 6, 5, 0, 8, 0, GLFW_WINDOW); glfwSetWindowTitle("Mythos science visualizer"); glClearDepth(1.0); glDepthFunc(GL_LESS); glShadeModel(GL_SMOOTH); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0, (float)WindowWidth/WindowHeight, 0.01, 200.0); glMatrixMode(GL_MODELVIEW); glfwSetWindowSizeCallback(Reshape); glfwSetKeyCallback(KeyboardInput); glfwSetCharCallback(CharacterInput); glfwEnable(GLFW_STICKY_KEYS); glfwEnable(GLFW_KEY_REPEAT); }
gb_error gb_screen_init() { glfwInit(); if (!glfwOpenWindow(256, 256, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) return GB_ERROR_SCREEN_FAILURE; glfwSetWindowTitle("gbem"); glEnable(GL_TEXTURE_2D); glMatrixMode(GL_PROJECTION); gluOrtho2D(0, 1, 0, 1); glMatrixMode(GL_MODELVIEW); glGenTextures(1, &gb_screen_texture); glBindTexture(GL_TEXTURE_2D, gb_screen_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); return GB_ERROR_OK; }
// other bool PGame::initGame() { Messages::mainTitleMessage(); if (!glfwInit()) // is GLFW initialization successful? { Messages::errorMessage("OpenGL/glfw initialization failed."); // in case, it is not terminateGLFW(); // terminate glfw and return false return false; } Messages::initMessage("GLFW", true); // prints out that initialization was success // 800 x 600, 16 bit color, no depth, alpha or stencil buffers, windowed if (!glfwOpenWindow(windowWidth, windowHeight, 8, 8, 8, 8, 24, 0, GLFW_WINDOW)) // attemps to open window { Messages::errorMessage("OpenGL window creation failed."); // failed terminateGLFW(); return false; } Messages::initMessage("OpenGL window", true); // prints out success glfwSetWindowTitle(this->windowTitle.c_str()); // temporary /*glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix // Calculate The Aspect Ratio Of The Window gluPerspective(45.0f,(float)windowWidth/(float)windowHeight,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glLoadIdentity();*/ // glfwSetKeyCallback(&PacGame::GameClasses::PGame::processKey); // sets keyboard input callback Messages::initMessage("Game", true); return true; }
// Text //--- Function Definitions ---// // ~ Initialization GLint MakeWindow(GLchar* title,GLint width,GLint height) { // --- Variables --- // winsize[0]=width; winsize[1]=height; // --- GLFW Configuration --- // if(!glfwinit) { glfwInit(); glfwinit=true; } // Set GLFW 'Hints' glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR,3); // OpenGL v3.2 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR,2); glfwOpenWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_COMPAT_PROFILE ); glfwOpenWindowHint(GLFW_WINDOW_NO_RESIZE,GL_TRUE); // Initialize Window if(glfwOpenWindow( width,height,RED_DEPTH,GRN_DEPTH,BLU_DEPTH, ALPHA_BUF,DEPTH_BUF,STENC_BUF,WINMODE)==GL_FALSE) { dprint("Attempt to create window context using GLFW has failed.\n"); return _BAD; } glfwSetWindowTitle(title); // Hide Cursor glfwDisable(GLFW_MOUSE_CURSOR); // Handle Input Events glfwSwapInterval(1); if(!SetCursorPos((GLint)(winsize[0]/2.0f),(GLint)(winsize[1]/2.0f))) { dprint("Call to 'SetCursorPos' failed with error %x.\n",GetLastError()); return _BAD; } //glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,GL_BLEND); //oglew=GetForegroundWindow(); return _OK; }
bool Root::initGLFW() { if(!glfwInit()) { LOG_ERROR("Could not init glfw!"); return false; } GLFWvidmode mode; glfwGetDesktopMode(&mode); desktopWidth = mode.Width; desktopHeight = mode.Height; if(fullscreen) { windowWidth = desktopWidth; windowHeight = desktopHeight; } #ifdef __APPLE__ glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); // Use OpenGL Core v3.2 glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); #endif if(!glfwOpenWindow(windowWidth, windowHeight, 0, 0, 0, 0, 32, 0, (fullscreen ? GLFW_FULLSCREEN : GLFW_WINDOW))) { return false; } glfwSetWindowTitle("Arya"); glfwEnable(GLFW_MOUSE_CURSOR); glfwSetKeyCallback(keyCallback); glfwSetMouseButtonCallback(mouseButtonCallback); glfwSetMousePosCallback(mousePosCallback); glfwSetMouseWheelCallback(mouseWheelCallback); return true; }
bool GLFWWindow::OpenWindowAndInitalizeGLEW(int width, int height, int redBits, int greenBits, int blueBits, int alphaBits, int depthBits, int stencilBits, bool fullscreen) { int mode = fullscreen ? GLFW_FULLSCREEN : GLFW_WINDOW; if(!glfwOpenWindow( width,height, redBits, greenBits,blueBits,alphaBits, depthBits,stencilBits, mode )) { TerminateWindow(); return false; } glfwSetWindowSizeCallback(OnWindowResize); //Set the window size params this->_windowWidth = width; this->_windowHeight = height; //Initialize GLEW glewExperimental = GL_TRUE; GLenum err = glewInit(); //We might get an INVALID_ENUM error here, so just clean the error for now //Explanation - http://www.opengl.org/wiki/OpenGL_Loading_Library glGetError(); if (err != GLEW_OK) { fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); return false; } return true; }
CDisplay::CDisplay(uint32 width, uint32 height, const char* title) : m_state(eS_Uninitialised) , m_displayScale(1.0f) , m_width(width) , m_height(height) { if (!glfwInit()) { fprintf(stderr, "Failed to initialise GLFW\n"); exit(EXIT_FAILURE); } m_state = eS_Initialised; if (!glfwOpenWindow(m_width, m_height, 0, 0, 0, 0, 0, 0, GLFW_WINDOW)) { fprintf(stderr, "Failed to open GLFW window\n"); exit(EXIT_FAILURE); } m_state = eS_Window; glfwSwapInterval(0); glfwSetWindowTitle(title); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glShadeModel(GL_FLAT); // Do texture stuff (http://www.gamedev.net/page/resources/_/reference/programming/opengl/269/opengl-texture-mapping-an-introduction-r947) glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_2D, eTID_Main); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); }
void GlfwGraphics::createWindow(const char* title, int width, int height) { // Open a window and create its OpenGL context if( !glfwOpenWindow( width, height, 0, 0, 0, 0, 0, 0, GLFW_WINDOW ) ) { ::glfwTerminate(); throw GdxRuntimeException("Failed to open GLFW window"); } ::glfwSetWindowTitle(title); //initializa glew glewInit(); updateSize(); //TODO: implement also window resize //setup a callback? m_listener.create(); m_frameStart = m_timer.systemNanoSeconds(); m_lastFrameTime = m_frameStart; m_deltaTime = 0; }
Engine::Engine (int width , int height) { Width = width; Height = height; if (!glfwInit()) { std::cout << "GLFW failed to initialize!\n"; } glfwOpenWindow(Width,Height,0,0,0,0,32,0,GLFW_WINDOW); if (glewInit() != GLEW_OK) { std::cout << "GLEW failed to initialize!\n"; } glfwSetWindowTitle("Engine"); glViewport(0,0,Width, Height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0,0,0,0,0,100); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor(1,0,0,1); glfwSwapInterval (0); }
int main(int argc, char * argv[]) { int running = GL_TRUE; glewExperimental = GL_TRUE; glfwInit(); glfwOpenWindow(1000, 1000, 0,0,0,0,0,0, GLFW_WINDOW); glewInit(); glEnable(GL_DEPTH_TEST); //Obj triangle = Obj(triangle_verts, 3, triangle_elements, 3, "v.vert", "t.tessc", "t.tesse", "g.geom", "f.frag"); //Obj square = Obj(square_verts, 4, square_elements, 6, "v.vert", NULL, NULL, "g.geom", "f.frag"); Obj wireframe_sphere = Obj(tetra_verts, 4, tetra_elements, 12 , "v.vert", "t.tessc", "t.tesse", "g.geom", "f.frag"); Obj wireframe_cone = *generateCone(20);//Obj(cone_verts, 6, cone_elements, 24 , "v.vert", NULL, NULL, "g.geom", "f.frag"); Obj hedgehog_sphere = Obj(tetra_verts, 4, tetra_elements, 12, "v.vert", "t.tessc", "t.tesse", "hedgehog.geom", "f.frag"); Obj lit_sphere = Obj(tetra_verts, 4, tetra_elements, 12, "v.vert", "t.tessc", "t.tesse", "lit.geom", "lit.frag"); switchTo(&wireframe_sphere); while(running) { glClearColor(0.0,0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); render(drawing, glfwGetTime()*30); glfwSwapBuffers(); running = !glfwGetKey(GLFW_KEY_ESC) && glfwGetWindowParam(GLFW_OPENED); if(glfwGetKey('A')){switchTo(&wireframe_sphere);} if(glfwGetKey('B')){switchTo(&wireframe_cone);} if(glfwGetKey('C')){switchTo(&hedgehog_sphere);} if(glfwGetKey('D')){switchTo(&lit_sphere);} if(glfwGetKey('E')){} } glfwTerminate(); }
int main(int argc, char **args) { if (!glfwInit()) { log("Failed to initialize GLFW"); exit(EXIT_FAILURE); } int depth_bits = 16; if (!glfwOpenWindow(640, 480, 0, 0, 0, 0, depth_bits, 0, GLFW_WINDOW)) { log("Failed to open GLFW window"); glfwTerminate(); exit(EXIT_FAILURE); } glfwSetWindowTitle("Teapot"); glfwEnable(GLFW_STICKY_KEYS); glfwSwapInterval(1); glfwSetKeyCallback(keyboard); glfwSetMouseButtonCallback(mouse_button); glfwSetMousePosCallback(mouse_motion); glfwSetWindowSizeCallback(resize); setup(); do { render(); glfwSwapBuffers(); } while (glfwGetKey(GLFW_KEY_ESC) != GLFW_PRESS && glfwGetWindowParam(GLFW_OPENED)); cleanup(); glfwTerminate(); return 0; }
void setupGLFWwindow(){ glfwOpenWindowHint(GLFW_FSAA_SAMPLES,4); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR,3); glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR,3); glfwOpenWindowHint(GLFW_OPENGL_PROFILE,GLFW_OPENGL_CORE_PROFILE); // Open a window and create its OpenGL context if( !glfwOpenWindow( width, height, 0,0,0,0, 32,0, GLFW_WINDOW ) ){ fprintf( stderr, "Failed to open GLFW window\n" ); glfwTerminate(); } // Initialize GLEW if (glewInit() != GLEW_OK) { fprintf(stderr, "Failed to initialize GLEW\n"); } glfwSetWindowTitle( "skyGesture Pre-Alpha GLFW Build v0.001a" ); glfwEnable(GLFW_STICKY_KEYS); //glfwEnable(GLFW_STICKY_MOUSE_BUTTONS); //glfwDisable(GLFW_MOUSE_CURSOR); do{ glfwSwapBuffers(); } while(glfwGetKey(GLFW_KEY_ESC)!= GLFW_PRESS && glfwGetWindowParam(GLFW_OPENED)); }
void init() { // int glfwInit( void ) if (glfwInit() != GL_TRUE) { exit(EXIT_FAILURE); } // int glfwOpenWindow( int width, int height, // int redbits, int greenbits, int bluebits, // int alphabits, int depthbits, int stencilbits, // int mode ) if (glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW) != GL_TRUE) { // void glfwTerminate( void ) glfwTerminate(); exit(EXIT_FAILURE); } glfwSetWindowSizeCallback(windowResize); glClearColor(0.5, 0.0, 0.5, 0.0); console = StdoutConsole_new(); Log_init(console); renderBatch = RenderBatch_new(4, TRUE); image = Image_new(); Image_loadFromFile(image, "res/box.png"); texture = Texture_newFromImage(image); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glEnable(GL_TEXTURE_2D); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); }
void init() { int width, height; glfwInit(); if( !glfwOpenWindow( 640, 480, 0, 0, 0, 0, 8, 0, GLFW_WINDOW ) ) return; glfwGetWindowSize( &width, &height ); height = height > 0 ? height : 1; glViewport( 0, 0, width, height ); glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 65.0f, (GLfloat)width/(GLfloat)height, 1.0f, 200.0f ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); gluLookAt(0.0f, -10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f ); }