Hi guys,
I am currently trying to switch our rendering from fixed-function to shaders and can't seem to get anything to draw to screen. I know the shaders load and compile properly as I have the correct checks in place. Below is the code I think is relevant just to get something basic to render:
Code :void OGL_Core_Renderer::initGL(){ glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); // Spit out system graphics information. cout << "\t- OpenGL System Info -" << endl; driverName((char*)glGetString(GL_RENDERER)); cout << "\tVendor: " << glGetString(GL_VENDOR) << endl; cout << "\tRenderer: " << driverName() << endl; cout << "\tDriver Version: " << glGetString(GL_VERSION) << endl; cout << "\tGLSL Version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl; // if(!checkExtensions()) // throw Exception(0, "Graphics Requirements Not Met", "Your graphics driver does not meet the minimum requirements."); glGenVertexArrays(1, &mVertexArray); getError(); glBindVertexArray(mVertexArray); getError(); glGenBuffers(1, &mVertexBufferObject); getError(); glBindBuffer(GL_ARRAY_BUFFER, mVertexBufferObject); getError(); glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(DEFAULT_VERTEX_COORDS), DEFAULT_VERTEX_COORDS, GL_STATIC_DRAW); getError(); glGenBuffers(1, &mTextureBufferObject); getError(); glBindBuffer(GL_ARRAY_BUFFER, mTextureBufferObject); getError(); glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(DEFAULT_TEXTURE_COORDS), DEFAULT_TEXTURE_COORDS, GL_STATIC_DRAW); getError(); }
Code :void OGL_Core_Renderer::drawVertexArray(GLuint textureId, bool defaultTextureCoords){ clearScreen(0, 0, 0); /* We're going to create a simple diamond made from lines */ const GLfloat vert[4][2] = { { 0.0, 1.0 }, /* Top point */ { 1.0, 0.0 }, /* Right point */ { 0.0, -1.0 }, /* Bottom point */ { -1.0, 0.0 } }; /* Left point */ glUseProgram(mShaderManager->getShaderProgram()); getError(); glBindVertexArray(mVertexArray); glBindBuffer(GL_ARRAY_BUFFER, mVertexBufferObject); getError(); glBufferData(GL_ARRAY_BUFFER, 4 * 2 * sizeof(vert), vert, GL_STATIC_DRAW); getError(); glEnableVertexAttribArray(mVertexArray); getError(); glVertexAttribPointer(mVertexArray, 2, GL_FLOAT, GL_FALSE, 0, 0); getError(); glDrawArrays(GL_LINES, 0, 2); getError(); glDisableVertexAttribArray(mVertexArray); getError(); }
And the shaders:
Vert:
Code :#version 150 in vec4 position; void main() { gl_Position = vec4(1.0, 1.0, 0.0, 0.0) + position; }
Frag:
Code :#version 150 out vec3 fragColor; void main() { fragColor = vec3(0,0,1); }
I can't for the life of me figure out what step I have missed or done improperly. I have no errors or crashing at all even in my OGL Profiler. Does anything standout to you guys?



Reply With Quote