Problems with glScalef

I am trying to use glScalef using variable defined values, and something is not working.
When I use:
1
2
float var = 4;
glScalef(2/var, 0.0, 0.0);

which is ideally what I want, it won't work.
I have tried:
1
2
float var = 2/4;
glScalef(var, 0.0, 0.0);

and this still doesn't work.
But when I tried this:
1
2
float var = 0.5;
glScalef(var, 0.0, 0.0);

it does work.
What is the problem, and how can I fix it?
How is it not working? Build errors? Getting any kind of message? Or just unexpected behavior?
Unexpected behavior. It shows a black screen. I'm not sure why.
From MSDN

If scale factors other than 1.0 are applied to the modelview matrix and lighting is enabled, automatic normalization of normals should probably also be enabled (glEnable and glDisable with argument GL_NORMALIZE).


http://msdn.microsoft.com/en-us/library/windows/desktop/dd368580(v=vs.85).aspx

Not sure if this is what's going on or not.

EDIT:
Nevermind, you're not going over 1.0. I have no idea what's going on here. Maybe one of our OpenGL guys/gals can get in here.
Last edited on
Have you tried 2.0/4 instead of 2/4

I think operator/ gets its type from the left hand operand so you are getting an integer divide from the integer literal, i.e. 0
Thanks, that works.
Topic archived. No new replies allowed.