Jump to content
  • Advertisement
Sign in to follow this  
Dejan7

OpenGL How do i draw 2 different objects?

This topic is 2485 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

Ok this question probably doesn't make too much sesne as i am beginner, but i'll try to explain shortly.

I've been following the http://www.opengl-tutorial.org/ and they are great so far, but i've been having some problems with lesson 4 , so if anyone here has completed these tuts, it would be really great.

Anyway, i manage to draw that colored cube, and i kinda get the Model-View-Projection matrices and all that stuff, but at the end of the article, under "Excercises" it says "Draw the cube AND the triangle, at different locations. You will need to generate 2 MVP matrices, to make 2 draw calls in the main loop, but only 1 shader is required." So i am little bit confused, i don't know how and where to write all the code to have separate MVP matrices, vertices and whatnot for cube and for triangle. Can anyone help?

Share this post


Link to post
Share on other sites
Advertisement
glLoadIdentity();
glTranslate(cube.x,cube.y, cube.z);
//setup the cube vertices/object
glDrawArrays()

glLoadIdentity();
glTranslatef(tri.x, tri.y, tri.z);
//setup the triangle vertices/object
glDrawArrays()

Share this post


Link to post
Share on other sites
Wow, thanks for the fast reply :)
But it's not kinda the way he in the tutorial does it, he uses that model-view-projection stuff, first he creates the vertices in .cpp and transforms them, then he loads the stuff to vertex shader, i think. I am pretty lost, don't know what should i be looking for :/

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!