Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 15 Mar 2012
Offline Last Active Apr 17 2012 10:38 AM

Posts I've Made

In Topic: OpenGL .obj Parser/Rendering Problem Really Really Need Help!

12 April 2012 - 10:52 AM

Hmm, I dont think the code is quite right yet...

The following is basically what I use.

  glGenBuffersARB(1, &texCoordBuffer);
  glBindBufferARB(GL_ARRAY_BUFFER_ARB, texCoordBuffer);
  glBufferDataARB(GL_ARRAY_BUFFER_ARB, texCoords.size()*sizeof(float), &texCoords[0], GL_STATIC_DRAW_ARB);
  glVertexAttribPointerARB(inTexCoord, 2, GL_FLOAT, GL_FALSE, 0, 0);

  glGenBuffersARB(1, &colorBuffer);
  glBindBufferARB(GL_ARRAY_BUFFER_ARB, colorBuffer);
  glBufferDataARB(GL_ARRAY_BUFFER_ARB, colors.size()*sizeof(float), &colors[0], GL_STATIC_DRAW_ARB);
  glVertexAttribPointerARB(inVColor, 4, GL_FLOAT, GL_FALSE, 0, 0);

  glGenBuffersARB(1, &normalBuffer);
  glBindBufferARB(GL_ARRAY_BUFFER_ARB, normalBuffer);
  glBufferDataARB(GL_ARRAY_BUFFER_ARB, normals.size()*sizeof(float), &normals[0], GL_STATIC_DRAW_ARB);
  glVertexAttribPointerARB(inNormal, 3, GL_FLOAT, GL_FALSE, 0, 0);

  glGenBuffersARB(1, &vertexBuffer);
  glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBuffer);
  glBufferDataARB(GL_ARRAY_BUFFER_ARB, vertices.size()*sizeof(float), &vertices[0], GL_STATIC_DRAW_ARB);
  glVertexAttribPointerARB(inVertex, 3, GL_FLOAT, GL_FALSE, 0, 0);

  glDrawArrays(GL_TRIANGLES, 0, vertices.size() / 3);


1) Generate the buffer
2) Bind the buffer
3) Set the bound buffer data
4) Set the shader attribute to point to the bound buffer
5) Enable the shader attribute rather than using the default value (i.e the one set with glVertexAttrib3f)

In Topic: OpenGL .obj Parser/Rendering Problem Really Really Need Help!

12 April 2012 - 10:16 AM

It should be:-

//Model Vertices cordinates
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(0, 0, GL_INT, GL_FALSE,0,0);

//Model Texture cordinates
glBindBuffer(GL_ARRAY_BUFFER, texcoordbuffer);
glVertexAttribPointer(1, 0, GL_FLOAT, GL_FALSE,0,0);

Also... I see another issue.
glDrawElements( GL_QUADS, faces.size(), GL_UNSIGNED_INT, reinterpret_cast<GLvoid*>(&faces[0]));

should be glDrawArrays.

Afterall, you have added your data to a VBO, so why are you now drawing the data from faces[]?

That is also why it is displaying incorrectly, because faces[] contains the data for vertexes and tex coords merged into one.

So yeah, have a look at:

(cant remember the exact code myself, but let me know if you have any issues) Posted Image

In Topic: OpenGL .obj Parser/Rendering Problem Really Really Need Help!

12 April 2012 - 10:02 AM


Not entirely sure (there was quite a lot of code in that pastebin) but...

glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);

//Model Vertices cordinates
glVertexAttribPointer(0, 0, GL_INT, GL_FALSE,0,0);

//Model Texture cordinates
glVertexAttribPointer(1, 0, GL_FLOAT, GL_FALSE,0,0);

I think you need to bind the buffer containing the texture before setting glVertexAttribPointer for the texture coordinates.

In Topic: How to animate a 3ds Max model in my OpenGL program?

23 March 2012 - 06:05 AM

If you don't need boned animation and you are using the fixed function pipeline in OpenGL, you might want to give the following free and open-source Obj Wavefront model library a try.


It can read in basic animation files and simply transforms and rotates the parts making up the model (if it has been exported with objects or groups).

I wrote it for my University dissertation and it tends to be good enough for the majority of my projects so it might help you too if you do decide to go with Wavefront Obj.

In Topic: [SOLVED]Perspective Correct Texture Coordinates (Frag Shader)

20 March 2012 - 04:29 AM

True, the specs of the hardware do confirm that it should be able to work fine with the shader, they even mention the hardware perspective correction.

So yeah, it is probably a Linux driver issue. I did try out the software using the same version of Linux but on an nvidia card (using the open-source nouveau) driver and it worked fine. So it seems to be an issue with the intel drivers and my card.

This is a bit of a pain because I have spent so long on this issue lol.