• Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
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....
[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 [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 this post


Link to post
Share on other sites
Thanks for the quick reply! :-)

[size="2"][quote][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][/size]

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement