Jump to content
  • Advertisement
Sign in to follow this  
Psilobe

OpenGL simple 3d problem

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

I'm trying to create a small plane around origo using vertex lists and everything went fine untill I tried to generete the coordinates instead of manually inserting them.

I had a list that looked like this:

short vertex[] = {
-6,-5,-6,
-6,-5,-2,
-6,-5,2,
etc...
}

with 16 vertexes in it.
It rendered 9 squars in a chessboard fassion for me.

Now I tried doing it like this instead:

vector<int> vertexV;
short vertex[48];

for (int i = 0; i<4;i++){
for (int j = 0; j<4;j++){
int X = -6+i*4;
int Y = -5;
int Z = -6+j*4;
vertexV.push_back(X);
vertexV.push_back(Y);
vertexV.push_back(Z);
}
}

for (int i=0; i<48;i++){
vertex= vertexV;
cout<<vertex<<endl;
}

I have the correct values in my list called vertex[] but the squares wont render. I havent touched my list of corners or my list of colors. And all the values are in the same order.

If anyone might have any idea what I've done wrong I'd be very happy.

Share this post


Link to post
Share on other sites
Advertisement
I use the following functions to render my objects from lists:

glVertexPointer(3,GL_SHORT,0,&vertex);
glColorPointer(3,GL_FLOAT,0,&color);
glDrawElements(GL_QUADS,36,GL_UNSIGNED_SHORT,&indexQuads);


Share this post


Link to post
Share on other sites
Try putting a break-point at the time of drawing and inspect the values in the debugger, to make sure they are actually the same. I don't see anything in the code you posted that would make a difference, if the only change is that you fill vertex like that?
Also make sure you don't have two variables that are both named vertex or something like that.

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!