# Lesson1_OpenGL

This topic is 2402 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
[quote name='turbello' timestamp='1308683854' post='4826109']
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 :-)
[/quote]

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 [b]client[/b] 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.

##### Share on other sites
Thanks for the quick reply! :-)

[size="2"][quote] OR, depending on what you want, I guess you could use -500 to represent a window 500 pixels high, but with Y axis flipped?[/quote][/size]

[size="2"]I'll check it ^^[/size] Edited by turbello