Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8435139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:50:30+00:00 2026-06-10T06:50:30+00:00

My program was meant to draw a simple textured cube on screen, however, I

  • 0

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:

    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
};

In addition, here is the vertex shader:

#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);
};

and the fragment shader (I have given up on textures for now):

#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);
};

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 Durian Software Tutorial and the latest OpenGL Superbible. The rest of the code is here.

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:50:31+00:00Added an answer on June 10, 2026 at 6:50 am

    You’re looking pretty good so far.

    The only thing that I see right now is that you’ve got DEPTH_TEST enabled, but you don’t clear the depth buffer. Even if the buffer initialized to a good value, you would be drawing empty scenes on every frame after the first one, because the depth buffer’s not being cleared.

    If that does not help, can you make sure that you have no glGetError() errors? You may have to clean up your unused texturing attributes/uniforms to get the errors to be clean, but that would be my next step.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This program is meant to generate a dynamic array, however it gives an access
I'm developing a simple p2p program that is meant to work over the Internet,
I am working on a simple program to just draw circles around some fixed
I've written a very simple program that is meant to covert a char to
What is meant by running the program in warm cache? Can someone be kind
In a previous question, I asked what it meant when my program returned an
How can a program draw text on a frame buffer mapped in as an
I wrote a program to render a wavefront obj model in DirectX 10 I
In my program I have a memory DC to which I frequenty draw, then
This program is meant to read in a csv file and create a dictionary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.