Renderer* Init(Settings vs) { assert(!initted); if (initted) return 0; // no mode set, find an ok one if ((vs.width <= 0) || (vs.height <= 0)) { const std::vector<VideoMode> modes = GetAvailableVideoModes(); assert(!modes.empty()); vs.width = modes.front().width; vs.height = modes.front().height; } WindowSDL *window = new WindowSDL(vs, "Pioneer"); width = window->GetWidth(); height = window->GetHeight(); const int didLoad = ogl_LoadFunctions(); if (!didLoad) Error("glLoadGen failed to load functions.\n"); { std::ostringstream buf; write_opengl_info(buf); FILE *f = FileSystem::userFiles.OpenWriteStream("opengl.txt", FileSystem::FileSourceFS::WRITE_TEXT); if (!f) Output("Could not open 'opengl.txt'\n"); const std::string &s = buf.str(); fwrite(s.c_str(), 1, s.size(), f); fclose(f); } if (ogl_ext_EXT_texture_compression_s3tc == ogl_LOAD_FAILED) { Error("OpenGL extension GL_EXT_texture_compression_s3tc not supported.\nPioneer can not run on your graphics card as it does not support compressed (DXTn/S3TC) format textures."); } // We deliberately ignore the value from GL_NUM_COMPRESSED_TEXTURE_FORMATS, because some drivers // choose not to list any formats (despite supporting texture compression). See issue #3132. // This is (probably) allowed by the spec, which states that only formats which are "suitable // for general-purpose usage" should be enumerated. Renderer *renderer = new RendererOGL(window, vs); Output("Initialized %s\n", renderer->GetName()); std::ostringstream dummy; dump_and_clear_opengl_errors(dummy); initted = true; MaterialDescriptor desc; desc.effect = EFFECT_VTXCOLOR; desc.vertexColors = true; vtxColorMaterial = renderer->CreateMaterial(desc); vtxColorMaterial->IncRefCount(); return renderer; }
Renderer* Init(Settings vs) { assert(!initted); if (initted) return 0; // no mode set, find an ok one if ((vs.width <= 0) || (vs.height <= 0)) { const std::vector<VideoMode> modes = GetAvailableVideoModes(); assert(!modes.empty()); vs.width = modes.front().width; vs.height = modes.front().height; } WindowSDL *window = new WindowSDL(vs, "Pioneer"); width = window->GetWidth(); height = window->GetHeight(); GLenum glew_err; if ((glew_err = glewInit()) != GLEW_OK) Error("GLEW initialisation failed: %s", glewGetErrorString(glew_err)); { std::ostringstream buf; write_opengl_info(buf); FILE *f = FileSystem::userFiles.OpenWriteStream("opengl.txt", FileSystem::FileSourceFS::WRITE_TEXT); if (!f) Output("Could not open 'opengl.txt'\n"); const std::string &s = buf.str(); fwrite(s.c_str(), 1, s.size(), f); fclose(f); } if (!glewIsSupported("GL_VERSION_2_0") ) Error("OpenGL Version 2.0 is not supported. Pioneer cannot run on your graphics card."); if (!glewIsSupported("GL_ARB_vertex_buffer_object")) Error("OpenGL extension ARB_vertex_buffer_object not supported. Pioneer can not run on your graphics card."); if (!glewIsSupported("GL_EXT_texture_compression_s3tc")) Error("OpenGL extension GL_EXT_texture_compression_s3tc not supported.\nPioneer can not run on your graphics card as it does not support compressed (DXTn/S3TC) format textures."); // We deliberately ignore the value from GL_NUM_COMPRESSED_TEXTURE_FORMATS, because some drivers // choose not to list any formats (despite supporting texture compression). See issue #3132. // This is (probably) allowed by the spec, which states that only formats which are "suitable // for general-purpose usage" should be enumerated. Renderer *renderer = new RendererGL2(window, vs); Output("Initialized %s\n", renderer->GetName()); initted = true; MaterialDescriptor desc; desc.vertexColors = true; vtxColorMaterial = renderer->CreateMaterial(desc); vtxColorMaterial->IncRefCount(); return renderer; }
Renderer* Init(Settings vs) { assert(!initted); if (initted) return 0; // no mode set, find an ok one if ((vs.width <= 0) || (vs.height <= 0)) { const std::vector<VideoMode> modes = GetAvailableVideoModes(); assert(!modes.empty()); vs.width = modes.front().width; vs.height = modes.front().height; } WindowSDL *window = new WindowSDL(vs, "Pioneer"); width = window->GetWidth(); height = window->GetHeight(); glewExperimental = true; GLenum glew_err; if ((glew_err = glewInit()) != GLEW_OK) Error("GLEW initialisation failed: %s", glewGetErrorString(glew_err)); { std::ostringstream buf; write_opengl_info(buf); FILE *f = FileSystem::userFiles.OpenWriteStream("opengl.txt", FileSystem::FileSourceFS::WRITE_TEXT); if (!f) Output("Could not open 'opengl.txt'\n"); const std::string &s = buf.str(); fwrite(s.c_str(), 1, s.size(), f); fclose(f); } // pump this once as glewExperimental is necessary but spews a single error GLenum err = glGetError(); if (!glewIsSupported("GL_VERSION_3_2") ) Error("OpenGL Version 3.2 is not supported. Pioneer cannot run on your graphics card."); // Brilliantly under OpenGL 3.2 CORE profile Glew says this isn't supported, this forces us to use a COMPATIBILITY profile :/ if (!glewIsSupported("GL_EXT_texture_compression_s3tc")) { if (glewIsSupported("GL_ARB_texture_compression")) { GLint intv[4]; glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &intv[0]); if( intv[0] == 0 ) { Error("GL_NUM_COMPRESSED_TEXTURE_FORMATS is zero.\nPioneer can not run on your graphics card as it does not support compressed (DXTn/S3TC) format textures."); } } else { Error("OpenGL extension GL_EXT_texture_compression_s3tc not supported.\nPioneer can not run on your graphics card as it does not support compressed (DXTn/S3TC) format textures."); } } // We deliberately ignore the value from GL_NUM_COMPRESSED_TEXTURE_FORMATS, because some drivers // choose not to list any formats (despite supporting texture compression). See issue #3132. // This is (probably) allowed by the spec, which states that only formats which are "suitable // for general-purpose usage" should be enumerated. Renderer *renderer = new RendererOGL(window, vs); Output("Initialized %s\n", renderer->GetName()); std::ostringstream dummy; dump_and_clear_opengl_errors(dummy); initted = true; MaterialDescriptor desc; desc.effect = EFFECT_VTXCOLOR; desc.vertexColors = true; vtxColorMaterial = renderer->CreateMaterial(desc); vtxColorMaterial->IncRefCount(); return renderer; }