• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Lesson1_OpenGL

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.

2 replies to this topic

### #1turbello  Members

Posted 21 June 2011 - 01:17 PM

Hi, I'm new and I have just started learning OpenGL.

I'm not stuck with something but I have a little question:

if(height == 0) // Prevent A Divide By Zero By
{
height = 1; // Making Height Equal To One
}

Is it not better that you set the '==' to '<=' ?
If someone who doesn't know anything about C++, and he see a method ' SetWindowHeight(int height) ' that will set the window height.

Then he can accidentally write: SetHeight(-500);

I don't know much about programming. This is my first year in college I get Programming. ( I'm studying Digital Arts & Entertainment ).
I've only seen Win32.. So nothing from OpenGl and that's why I'm learning it now :-)

Edited by turbello, 21 June 2011 - 01:19 PM.

### #2achild  Members

Posted 21 June 2011 - 01:26 PM

Hi, I'm new and I have just started learning OpenGL.

I'm not stuck with something but I have a little question:

if(height == 0) // Prevent A Divide By Zero By
{
height = 1; // Making Height Equal To One
}

Is it not better that you set the '==' to '<=' ?
If someone who doesn't know anything about C++, and he see a method ' SetWindowHeight(int height) ' that will set the window height.

Then he can accidentally write: SetHeight(-500);

I don't know much about programming. This is my first year in college I get Programming. ( I'm studying Digital Arts & Entertainment ).
I've only seen Win32.. So nothing from OpenGl and that's why I'm learning it now :-)

Whoa! Is it just nehe that has a dark theme or is this everywhere now? Anyway....
 I guess it's just Nehe!

First: To avoid negatives, why not just use an "unsigned int" parameter instead of int?
 OR, depending on what you want, I guess you could use -500 to represent a window 500 pixels high, but with Y axis flipped?

Second: As for what to do when height is 0, shouldn't that be valid? Everything should be set to a state of "off" or an equivalent in that case. In other words, if the window really has a client area that is 0 in height (this can happen if it's resizeable), you DON'T want to set up opengl to work as if it was 1 pixel high - you want to set it to some state indicating there is nothing to do rather. Well.... IMHO.

### #3turbello  Members

Posted 21 June 2011 - 01:32 PM

Thanks for the quick reply! :-)

 OR, depending on what you want, I guess you could use -500 to represent a window 500 pixels high, but with Y axis flipped?

I'll check it ^^

Edited by turbello, 21 June 2011 - 01:37 PM.

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.