something is wrong
hey there, i''ve just started out with some opengl stuff been going through NeHe''s tutorials which are great, but when i was messing around with something it stoped working,
for (int i=0; i.dist < -5.5f)
thing.dist = 15.0f;
thing.dist += float(speed);
glLoadIdentity();
glTranslatef(thing.x, 0.0f, thing.dist);
glBegin(GL_TRIANGLES);
glColor4ub(thing.r, thing.g, thing.b, 255);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();
}
unless i have missed something, this code should go through NUM times and create that many triangles, each with there own colur and own Z value(thing.dist) and there own X value(thing.x)
but for some reason nothing on the screen shows, i did have this working but as i added other things it stop, and the colours were very dull, i took everything else out so all it should do is these triangles and a cube, only the cube is seeable,
any ideas anyone, or did i miss something easy, thanks in advance </i>
What is the value of "speed" ?
If it is positive, then your triangles will start at distance 15.0f and the distance will be greater every time, without being stopped.
IMO, your test "(dist < -5.5f)" supposes that the distance should decrease.
So, try to set a negative speed (or else replace the "dist+=speed" by "dist-=speed").
If it is positive, then your triangles will start at distance 15.0f and the distance will be greater every time, without being stopped.
IMO, your test "(dist < -5.5f)" supposes that the distance should decrease.
So, try to set a negative speed (or else replace the "dist+=speed" by "dist-=speed").
Hi! Is your "for( " statement broken or did you just leave something out?
What I see is this:
for (int i=0; i{
if (thing.dist < -5.5f)
Now, that doesn''t make a very useful for loop.
Hope it helps,
Pixelish
What I see is this:
for (int i=0; i{
if (thing.dist < -5.5f)
Now, that doesn''t make a very useful for loop.
Hope it helps,
Pixelish
Pixelish: the real part of the "for" instruction is :
for ( int i = 0 ; i < num ; i++ )
I added spacing for the layout.
You read something wrong because the browser interprets the "i < num" part as a tag when there is no spacing (in HTML, all tags begins with "<")
Look at the source of the page to see the real code. (Right button click on the page, then "View Source" with both Netscape and IE)
for ( int i = 0 ; i < num ; i++ )
I added spacing for the layout.
You read something wrong because the browser interprets the "i < num" part as a tag when there is no spacing (in HTML, all tags begins with "<")
Look at the source of the page to see the real code. (Right button click on the page, then "View Source" with both Netscape and IE)
Hello. Forgive me if I''m being stupid.
I''m not privy to your data structures or code, so I''m not sure if the following is correct, but the code seems a little odd to me:
for (int i=0; i{
if (thing.dist < -5.5f)
thing.dist = 15.0f;
If thing is an array, then why are you referencing thing.dist instead of thing.dist???? Like:<br><br>for (int i=0; i{<br>****if (thing.dist < -5.5f)****<br>thing.dist = 15.0f;<br><br>Sorry if I''m being thick ^_^ </i> <br><br>Transformers Rulez!!
I''m not privy to your data structures or code, so I''m not sure if the following is correct, but the code seems a little odd to me:
for (int i=0; i{
if (thing.dist < -5.5f)
thing.dist = 15.0f;
If thing is an array, then why are you referencing thing.dist instead of thing.dist???? Like:<br><br>for (int i=0; i{<br>****if (thing.dist < -5.5f)****<br>thing.dist = 15.0f;<br><br>Sorry if I''m being thick ^_^ </i> <br><br>Transformers Rulez!!
Transformers Rulez!!
your dist value must be negative or all things will be draw behind the users veiw! start with -15.0f and u will see something ...........
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement