Lesson1_OpenGL

Started by
1 comment, last by turbello 12 years, 10 months ago
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 :-)
Advertisement

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....
[edit] I guess it's just Nehe!

First: To avoid negatives, why not just use an "unsigned int" parameter instead of int?
[edit] 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.
Thanks for the quick reply! :-)

[edit] 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]

I'll check it ^^

This topic is closed to new replies.

Advertisement