// ------------------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------------------- int main (int argc, char** argv) { // Init //glutInit(&argc, argv); IupOpen(&argc, &argv); IupGLCanvasOpen(); IupImageLibOpen(); // Create dialog cMainDialog *main_dialog = new cMainDialog(); //glewExperimental = GL_TRUE; GLenum err = glewInit(); if(GLEW_OK != err) { fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); return EXIT_FAILURE; } printf("Glew Version: %s\n", glewGetString(GLEW_VERSION)); printf("GL Vendor: %s\n", glGetString(GL_VENDOR)); printf("GL Renderer: %s\n", glGetString(GL_RENDERER)); printf("\nGL Version: %s\n", glGetString(GL_VERSION)); //This is the new way for getting the GL version. //It returns integers. Much better than the old glGetString(GL_VERSION). int OpenGLVersion[2]; glGetIntegerv(GL_MAJOR_VERSION, &OpenGLVersion[0]); glGetIntegerv(GL_MINOR_VERSION, &OpenGLVersion[1]); printf("OpenGL major version = %d\n", OpenGLVersion[0]); printf("OpenGL minor version = %d\n", OpenGLVersion[1]); // For all versions of OpenGL 3.3 and above, // the corresponding GLSL version matches the OpenGL version. // So GL 4.1 uses GLSL 4.10. printf("Shader Version: %s\n\n", glGetString(GL_SHADING_LANGUAGE_VERSION)); int major, minor, rev; _glfwParseGLVersion(&major, &minor, &rev); cRender::m_new_render = major <= 2 ? false: true; g_model = new cModel(); if(!g_render_att) g_render_att = new cRenderAtt(); if(cRender::m_new_render) { if(!g_shader) { g_shader = new cShader(); if(!g_shader->create()) { delete g_shader; g_shader = NULL; } } if(!g_shader2) { g_shader2 = new cShader(); if(!g_shader2->create()) { delete g_shader2; g_shader2 = NULL; } } } init_opengl(); main_dialog->show_dialog(); IupMainLoop(); IupClose(); delete main_dialog; //delete obj_dialog; return EXIT_SUCCESS; }
GLFWAPI int GLFWAPIENTRY glfwOpenWindow( int width, int height, int redbits, int greenbits, int bluebits, int alphabits, int depthbits, int stencilbits, int mode ) { _GLFWfbconfig fbconfig; _GLFWwndconfig wndconfig; // Is GLFW initialized? if( !_glfwInitialized || _glfwWin.opened ) { return GL_FALSE; } // Set up desired framebuffer config fbconfig.redBits = Max( redbits, 0 ); fbconfig.greenBits = Max( greenbits, 0 ); fbconfig.blueBits = Max( bluebits, 0 ); fbconfig.alphaBits = Max( alphabits, 0 ); fbconfig.depthBits = Max( depthbits, 0 ); fbconfig.stencilBits = Max( stencilbits, 0 ); fbconfig.accumRedBits = Max( _glfwLibrary.hints.accumRedBits, 0 ); fbconfig.accumGreenBits = Max( _glfwLibrary.hints.accumGreenBits, 0 ); fbconfig.accumBlueBits = Max( _glfwLibrary.hints.accumBlueBits, 0 ); fbconfig.accumAlphaBits = Max( _glfwLibrary.hints.accumAlphaBits, 0 ); fbconfig.auxBuffers = Max( _glfwLibrary.hints.auxBuffers, 0 ); fbconfig.stereo = _glfwLibrary.hints.stereo ? GL_TRUE : GL_FALSE; fbconfig.samples = Max( _glfwLibrary.hints.samples, 0 ); // Set up desired window config wndconfig.mode = mode; wndconfig.refreshRate = Max( _glfwLibrary.hints.refreshRate, 0 ); wndconfig.windowNoResize = _glfwLibrary.hints.windowNoResize ? GL_TRUE : GL_FALSE; wndconfig.glMajor = Max( _glfwLibrary.hints.glMajor, 1 ); wndconfig.glMinor = Max( _glfwLibrary.hints.glMinor, 0 ); wndconfig.glForward = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE; wndconfig.glDebug = _glfwLibrary.hints.glDebug ? GL_TRUE : GL_FALSE; wndconfig.glProfile = _glfwLibrary.hints.glProfile; if( wndconfig.glMajor == 1 && wndconfig.glMinor > 5 ) { // OpenGL 1.x series ended with version 1.5 return GL_FALSE; } else if( wndconfig.glMajor == 2 && wndconfig.glMinor > 1 ) { // OpenGL 2.x series ended with version 2.1 return GL_FALSE; } else if( wndconfig.glMajor == 3 && wndconfig.glMinor > 3 ) { // OpenGL 3.x series ended with version 3.3 return GL_FALSE; } else { // For now, let everything else through } if( wndconfig.glProfile && ( wndconfig.glMajor < 3 || ( wndconfig.glMajor == 3 && wndconfig.glMinor < 2 ) ) ) { // Context profiles are only defined for OpenGL version 3.2 and above return GL_FALSE; } if( wndconfig.glForward && wndconfig.glMajor < 3 ) { // Forward-compatible contexts are only defined for OpenGL version 3.0 and above return GL_FALSE; } // Clear for next open call _glfwClearWindowHints(); // Check input arguments if( mode != GLFW_WINDOW && mode != GLFW_FULLSCREEN ) { return GL_FALSE; } // Clear GLFW window state _glfwWin.active = GL_TRUE; _glfwWin.iconified = GL_FALSE; _glfwWin.mouseLock = GL_FALSE; _glfwWin.autoPollEvents = GL_TRUE; _glfwClearInput(); // Unregister all callback functions _glfwWin.windowSizeCallback = NULL; _glfwWin.windowCloseCallback = NULL; _glfwWin.windowRefreshCallback = NULL; _glfwWin.keyCallback = NULL; _glfwWin.charCallback = NULL; _glfwWin.mousePosCallback = NULL; _glfwWin.mouseButtonCallback = NULL; _glfwWin.mouseWheelCallback = NULL; // Check width & height if( width > 0 && height <= 0 ) { // Set the window aspect ratio to 4:3 height = (width * 3) / 4; } else if( width <= 0 && height > 0 ) { // Set the window aspect ratio to 4:3 width = (height * 4) / 3; } else if( width <= 0 && height <= 0 ) { // Default window size width = 640; height = 480; } // Remember window settings _glfwWin.width = width; _glfwWin.height = height; _glfwWin.fullscreen = (mode == GLFW_FULLSCREEN ? GL_TRUE : GL_FALSE); // Platform specific window opening routine if( !_glfwPlatformOpenWindow( width, height, &wndconfig, &fbconfig ) ) { return GL_FALSE; } // Flag that window is now opened _glfwWin.opened = GL_TRUE; // Get window parameters (such as color buffer bits etc) _glfwPlatformRefreshWindowParams(); // Get OpenGL version _glfwParseGLVersion( &_glfwWin.glMajor, &_glfwWin.glMinor, &_glfwWin.glRevision ); if( _glfwWin.glMajor < wndconfig.glMajor || ( _glfwWin.glMajor == wndconfig.glMajor && _glfwWin.glMinor < wndconfig.glMinor ) ) { _glfwPlatformCloseWindow(); return GL_FALSE; } // Do we have non-power-of-two textures (added to core in version 2.0)? _glfwWin.has_GL_ARB_texture_non_power_of_two = ( _glfwWin.glMajor >= 2 ) || glfwExtensionSupported( "GL_ARB_texture_non_power_of_two" ); // Do we have automatic mipmap generation (added to core in version 1.4)? _glfwWin.has_GL_SGIS_generate_mipmap = ( _glfwWin.glMajor >= 2 ) || ( _glfwWin.glMinor >= 4 ) || glfwExtensionSupported( "GL_SGIS_generate_mipmap" ); if( _glfwWin.glMajor > 2 ) { _glfwWin.GetStringi = (PFNGLGETSTRINGIPROC) glfwGetProcAddress( "glGetStringi" ); if( !_glfwWin.GetStringi ) { _glfwPlatformCloseWindow(); return GL_FALSE; } } // If full-screen mode was requested, disable mouse cursor if( mode == GLFW_FULLSCREEN ) { glfwDisable( GLFW_MOUSE_CURSOR ); } // Start by clearing the front buffer to black (avoid ugly desktop // remains in our OpenGL window) glClear( GL_COLOR_BUFFER_BIT ); _glfwPlatformSwapBuffers(); return GL_TRUE; }