Jump to content
  • Advertisement
Sign in to follow this  
DominicHughes

OpenGL rendering a .obj in modern opengl / win32?

This topic is 2402 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

gDEBugger/glIntercept


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:

http://pastebin.com/e9QxxUE5

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Ty brother bob your information did help me greatly still got a few more bugs to figure out but yes ty. smile.png "no model shows yet" but the code feels like its more correct to me :)

Share this post


Link to post
Share on other sites
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 smile.png saving you all the time required to scan my code biggrin.png.

for example

step 1) glGenBuffers()

step 2) glBindBuffers()

step 3) glBufferData()

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.
http://www.cprogramming.com/tutorial/opengl_first_windows_app.html
See the while loop around translate message.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!