Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Is there anything wrong with this code? (Its short)


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
7 replies to this topic

#1 clrscr   Members   -  Reputation: 158

Like
Likes
Like

Posted 14 December 2001 - 08:17 AM

I''m trying to draw 80 lines on the screen each line a little bit lower the the other (I know its dumb, but hey I''m just starting out. However, it looks like this code isn''t drawing anything. Heres the code: int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing { static float down = 0.0f; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glLoadIdentity(); glTranslatef(0.0f,0.0f,-10.0f); glColor3f(1.0f,0.0f,0.0f); for(int i = 0;i<80;i++) { glTranslatef(0.0f,-down,0.0f); glBegin(GL_LINES); glVertex3f(-10.0f,0.0f,0.0f); glVertex3f(10.0f,0.0f,0.0f); glEnd(); down+=0.10f; } return TRUE; // Everything Went OK } BTW- How do you get code to have that white box with syntax highlighting and such. "You can observe a lot just by watching."- Yogi Berra

Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 14 December 2001 - 08:26 AM

I''m not opengl guru, but I can tell one of your problems is that you are probably drawing off the edge of the screen. With identity view and default projection, I think the screen is small (about 1x1 units) so it is easy to draw off of it.

#3 jacksonh   Members   -  Reputation: 122

Like
Likes
Like

Posted 14 December 2001 - 08:52 AM

You don''t need to change the value in glTranslate(). It translates from where it last was so you just need this glTranslatef( 0.0f, 0.1f, 0.0f );

#4 clrscr   Members   -  Reputation: 158

Like
Likes
Like

Posted 14 December 2001 - 09:01 AM

That fixed it, thanks a lot jacksonh

"You can observe a lot just by watching."- Yogi Berra

#5 Skulver   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 December 2001 - 12:17 AM

Since others have solved your problem I will mention one small problem with what you have coded that may surface elsewhere in your code.

You declare down with
static float down = 0.0f

What this does is ensure that down only gets initialized once in your entire program, so the second time you call this function down will start at 8.0f (0.0f + 0.1f*80)

You should just be using
float down - 0.0f
in these kinds of situations as that will ensure it gets set to zero every time you call the method.


#6 Dredge-Master   Members   -  Reputation: 175

Like
Likes
Like

Posted 15 December 2001 - 03:33 AM

as a follow on to the previous post, if you were using static for speed, use register instead. Go''s faster anyway.

register float down=0.0f;



Beer - the love catalyst


#7 Dredge-Master   Members   -  Reputation: 175

Like
Likes
Like

Posted 15 December 2001 - 03:33 AM

as a follow on to the previous post, if you were using static for speed, use register instead. Go''s faster anyway.

register float down=0.0f;



Beer - the love catalyst


#8 Drizzt DoUrden   Members   -  Reputation: 100

Like
Likes
Like

Posted 15 December 2001 - 03:40 AM

quote:
Original post by clrscr
BTW- How do you get code to have that white box with syntax highlighting and such.

"You can observe a lot just by watching."- Yogi Berra


You put the word "source" inside of the brackets. ] and [, or [].
      
int DrawGLScene(GLvoid)
// Here's Where We Do All The Drawing

{
static float down = 0.0f;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity();
glTranslatef(0.0f,0.0f,-10.0f);
glColor3f(1.0f,0.0f,0.0f);
for(int i = 0;i<80;i++)
{
glTranslatef(0.0f,-down,0.0f);
glBegin(GL_LINES);
glVertex3f(-10.0f,0.0f,0.0f);
glVertex3f(10.0f,0.0f,0.0f);
glEnd();
down+=0.10f;
}

return TRUE;
// Everything Went OK

}


If that's what you meant. You can click "edit" on my post and see how I did it.


Edited by - Drizzt DoUrden on December 15, 2001 10:43:04 AM




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.



PARTNERS