Jump to content

  • Log In with Google      Sign In   
  • Create Account

rendering a .obj in modern opengl / win32?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1   Members   -  Reputation: 143


Posted 17 April 2012 - 12:56 PM

After this long trying to figure out how to draw a .obj onto the frustum I think I'm very close to driving a knife through my soul!...

why would I get a black screen when drawing ?

using this function :

  glDrawElements( GL_QUADS, faces.size(), GL_UNSIGNED_INT,  faces.data());

has anyone made anything decent in win32/opengl?

I've tried so many different gldebuggers.


tried moving the camera using the glintercept freecamera tool.

looked on so many websites about gldrawelements not rendering/not working/ showing black screen/

LOOKED! at the super bible 5th edition about it no luck what so ever.

tell me how to fix this problem please oooo please..

here is my full source code:


#2   Moderators   -  Reputation: 10031


Posted 17 April 2012 - 01:19 PM

I mentioned one major problem in your last thread about loading obj files. When you have a buffer object bound, a pointer parameter is an offset from the start of the buffer object and not a pointer to your system memory storage. If you want to set a pointer to the beginning of a buffer object, you pass a null pointer. I also mentioned it in point 3 that you should store your indices in an element buffer object.

Since you're not creating a core profile rendering context, you are at the moment getting away with some things you won't get away with in modern OpenGL. For example, it is technically correct to pass a pointer to your index buffer, but in modern OpenGL you must store it in an element array buffer object, and quads are not valid primitives either.

Those are some points I notices. I'm not going into any details in such a big code dump though. If you're having troubles getting even a simple program going, you should take a look at some of the resources in the getting started box on this sub-forum's front page.

#3   Members   -  Reputation: 143


Posted 17 April 2012 - 02:41 PM

Ty brother bob your information did help me greatly still got a few more bugs to figure out but yes ty. Posted Image "no model shows yet" but the code feels like its more correct to me :)

#4   Members   -  Reputation: 143


Posted 17 April 2012 - 05:20 PM

would it be possible brother bob if you could list out the functions in order of usage to render a mesh in opengl 3.3 Posted Image saving you all the time required to scan my code Posted Image.

for example

step 1) glGenBuffers()

step 2) glBindBuffers()

step 3) glBufferData()

#5   Moderators   -  Reputation: 10031


Posted 17 April 2012 - 06:12 PM

I could do that, but it wouldn't help you solve your actual problem. You are much better off reading a proper tutorial or something on the subject and learning why it is done the way it is. The order of function calls itself is not so much the problem with your code as far as I could see, but understanding how to use and set up the buffer objects.

For example the problem I mentioned with setting up the vertex attribute pointer. Perhaps some function calls are, in fact, in the wrong order. But just learning the correct order is not going to help you understand what the last parameter to glVertexAttribPointer means, so you're going to have to read up on that anyway. If you read a proper tutorial on the subject, you will, in the process, learn how and when to call the functions as well. There are so much more to get it going that just calling this function, then calling that function, and then some other function. The functions have parameters as well and they have a very specific meaning that you have to understand also.

#6   Members   -  Reputation: 2028


Posted 17 April 2012 - 11:05 PM

Based on your code and complaints you sound pretty new so to debug you should try if you haven't:

Can you draw a single triangle instead of the obj model? Looks like you have done that.

Make sure this actually gets sent to the shader. glUseProgram has to have the shader bound before sending uniforms.
glUniformMatrix4fv(matrixuniform, 1, TRUE, myMatrix);

What is the model you are loading. Is it centered around 0,0,0? Try translating it -10, -20 or more units in the z axis. It could just be behind the camera.

Coding style/readability to help yourself or start doing. You shouldn't have all your code together like that, especially because of the fact you have it all in 1 file, its hard even for me to read what happens first, second, third. All your loading and opengl calls should go into a GameLoop() call or soemthing from WinMain.

Describe what you have had to work as I said drawing a triangle with the shader etc. Even your winMain has no while loop in it from what I see because of the code, but to me it looks like your program never continuously performs drawing.
See the while loop around translate message.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.