| 79 | } |
| 80 | |
| 81 | bool GraphicsDriver::Initialize() { |
| 82 | SDL_Window * window = (SDL_Window *)Window::Instance()->GetWindowObject(); |
| 83 | |
| 84 | // Set the profile to core as opposed to compatibility mode |
| 85 | SDL_GL_SetAttribute(SDL_GLattr::SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); |
| 86 | // Set max/min version |
| 87 | //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); |
| 88 | //SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 6); |
| 89 | // Enable double buffering |
| 90 | SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); |
| 91 | |
| 92 | // Create the gl context |
| 93 | STRATUS_LOG << "Creating OpenGL context" << std::endl; |
| 94 | GraphicsContext& context = GetContext(); |
| 95 | context.context = SDL_GL_CreateContext(window); |
| 96 | if (context.context == nullptr) { |
| 97 | STRATUS_ERROR << "Unable to create a valid OpenGL context" << std::endl; |
| 98 | STRATUS_ERROR << SDL_GetError() << std::endl; |
| 99 | return false; |
| 100 | } |
| 101 | |
| 102 | // Init gl core profile using gl3w |
| 103 | if (gl3wInit()) { |
| 104 | STRATUS_ERROR << "Failed to initialize core OpenGL profile" << std::endl; |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | //if (!gl3wIsSupported(maxGLVersion, minGLVersion)) { |
| 109 | // STRATUS_ERROR << "[error] OpenGL 3.2 not supported" << std::endl; |
| 110 | // _isValid = false; |
| 111 | // return; |
| 112 | //} |
| 113 | |
| 114 | // Query OpenGL about various different hardware capabilities |
| 115 | context.config.renderer = (const char *)glGetString(GL_RENDERER); |
| 116 | context.config.version = (const char *)glGetString(GL_VERSION); |
| 117 | glGetIntegerv(GL_MINOR_VERSION, &context.config.minorVersion); |
| 118 | glGetIntegerv(GL_MAJOR_VERSION, &context.config.majorVersion); |
| 119 | glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &context.config.maxAnisotropy); |
| 120 | glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &context.config.maxCombinedTextures); |
| 121 | glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &context.config.maxCubeMapTextureSize); |
| 122 | glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_VECTORS, &context.config.maxFragmentUniformVectors); |
| 123 | glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &context.config.maxRenderbufferSize); |
| 124 | glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &context.config.maxTextureImageUnits); |
| 125 | glGetIntegerv(GL_MAX_TEXTURE_SIZE, &context.config.maxTextureSize1D2D); |
| 126 | glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &context.config.maxTextureSize3D); |
| 127 | glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &context.config.maxTextureSizeCubeMap); |
| 128 | glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &context.config.maxVertexAttribs); |
| 129 | glGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &context.config.maxVertexUniformVectors); |
| 130 | glGetIntegerv(GL_MAX_DRAW_BUFFERS, &context.config.maxDrawBuffers); |
| 131 | glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &context.config.maxFragmentUniformComponents); |
| 132 | glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS, &context.config.maxVertexUniformComponents); |
| 133 | glGetIntegerv(GL_MAX_VARYING_FLOATS, &context.config.maxVaryingFloats); |
| 134 | glGetIntegerv(GL_MAX_VIEWPORT_DIMS, context.config.maxViewportDims); |
| 135 | glGetIntegerv(GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS, &context.config.maxComputeShaderStorageBlocks); |
| 136 | glGetIntegerv(GL_MAX_COMPUTE_UNIFORM_BLOCKS, &context.config.maxComputeUniformBlocks); |
| 137 | glGetIntegerv(GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS, &context.config.maxComputeTexImageUnits); |
| 138 | glGetIntegerv(GL_MAX_COMPUTE_UNIFORM_COMPONENTS, &context.config.maxComputeUniformComponents); |
nothing calls this directly
no test coverage detected