Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL issue: cannot render geometry on screen
    primarykey
    data
    text
    <p>My program was meant to draw a simple textured cube on screen, however, I cannot get it to render anything other than the clear color. This is my draw function:</p> <pre><code> void testRender() { glClearColor(.25f, 0.35f, 0.15f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); glUniformMatrix4fv(resources.uniforms.m4ModelViewProjection, 1, GL_FALSE, (const GLfloat*)resources.modelviewProjection.modelViewProjection); glEnableVertexAttribArray(resources.attributes.vTexCoord); glEnableVertexAttribArray(resources.attributes.vVertex); //deal with vTexCoord first glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,resources.hiBuffer); glBindBuffer(GL_ARRAY_BUFFER, resources.htcBuffer); glVertexAttribPointer(resources.attributes.vTexCoord,2,GL_FLOAT,GL_FALSE,sizeof(GLfloat)*2,(void*)0); //now the other one glBindBuffer(GL_ARRAY_BUFFER,resources.hvBuffer); glVertexAttribPointer(resources.attributes.vVertex,3,GL_FLOAT,GL_FALSE,sizeof(GLfloat)*3,(void*)0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, resources.htextures[0]); glUniform1i(resources.uniforms.colorMap, 0); glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_SHORT, (void*)0); //clean up a bit }; </code></pre> <p>In addition, here is the vertex shader:</p> <pre><code>#version 330 in vec3 vVertex; in vec2 vTexCoord; uniform mat4 m4ModelViewProjection; smooth out vec2 vVarryingTexCoord; void main(void) { vVarryingTexCoord = vTexCoord; gl_Position = m4ModelViewProjection * vec4(vVertex, 1.0); }; </code></pre> <p>and the fragment shader (I have given up on textures for now):</p> <pre><code>#version 330 uniform sampler2D colorMap; in vec2 vVarryingTexCoord; out vec4 vVaryingFragColor; void main(void) { vVaryingFragColor = texture(colorMap, vVarryingTexCoord); vVaryingFragColor = vec4(1.0,1.0,1.0,1.0); }; </code></pre> <p>the vertex array buffer for the position coordinates make a simple cube (with all coordinates a signed 0.25) while the modelview projection is just the inverse camera matrix (moved back by a factor of two) applied to a perspective matrix. However, even without the matrix transformation, I am unable to see anything onscreen. Originally, I had two different buffers that needed two different element index lists, but now both buffers (containing the vertex and texture coordinate data) are the same length and in order. The code itself is derived from the <a href="http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Chapter-1%3a-The-Graphics-Pipeline.html" rel="nofollow">Durian Software Tutorial</a> and the latest OpenGL Superbible. The rest of the code is <a href="http://pastebin.com/m3zLLypU" rel="nofollow">here</a>.</p> <p>By this point, I have tried nearly everything I can think of. Is this code even remotely close? If so, why can't I get anything to render onscreen?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload