looking for glScalef examples

Multiple sources of diff types would be very appreciated. Am applying to 2D case.

Thanks a lot.

glScalef( 1, 2, 1); // for example…

There is not much more you can do with it…

Mikael

Thanks for the reply.

I guess I am looking more for some Web sites that would show the before and after. Do you know of any? Right now, I am getting a black screen when I try to add a line like you mentioned (except I have 0 in last arg). I comment out and my drawing returns. I am trying to expand it.

Thanks.

You don’t want 0 for the last parameter. Use 1 for no scaling in that dimension.

glScale just multiplies the following X,Y and Z coordinates by the amount specified in the glScale command.

Thats one of the simplest commands in OpenGL, why dont you just RTFM first?

I’ll continue to post on here since I still can’t expand even with the last arg as 1 and hope that DOH! goes away

Given that the following is within a display routine, what am I doing incorrectly?

glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_LINE_LOOP);
glColor3f(1.0, 1.0, 1.0);
glScalef(13.0, 13.0, 1.0);
for (i=0; i<count; i++)
{
glVertex2f(c_array[i].lat, c_array[i].lon);
}
glEnd();

glutSwapBuffers();

Try putting this after glClearColor:

glPushMatrix(GL_MODELVIEW);
glLoadIdentity();

I hope this helps.

Unfortunately, that’s not really an option. I am already provided with a main function containing:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(LEFT_EDGE, RIGHT_EDGE,
BOTTOM_EDGE, TOP_EDGE);

prior to the call to the display routine and need to maintain this “format”

Thanks, though.

Read what DOH! posted. It doesn’t get any simpler than that.

Well, maybe I don’t understand what DOH! is saying - I just took at as an insult.

Perhaps you can start by saying what you don’t understand with DOH!'s post?

Or parhaps you can start by saying what you don’t understand from TFM ?

According to the site you’ve linked, I really should have got an GL_INVALID_OPERATION error for the code I posted above but I didn’t. I wonder why.

Anyways, is it mandatory then for me to use the push and pop around the scaling to see the effect?

I need to maintain the code from the main function that I posted above in resolving this problem.

Thanks.

According to the site you’ve linked, I really should have got an GL_INVALID_OPERATION error for the code I posted above but I didn’t. I wonder why.

Assuming you got your error reading code correct, it’s most likely a driver bug.

Anyways, is it mandatory then for me to use the push and pop around the scaling to see the effect?

You could do that. You could also rescale by the inverse:

glScalef(13, 13, 1);
glBegin(…);
/* Render code goes here */
glEnd();
glScalef(1.0/13, 1.0/13, 1);

Either way will be fine. Using push/pop, or reloading hte matrix would ensure that you don’t run into precision problems by continuously rescaling.

Thanks for the feedback.

Well, this has given me some options to think over a little more.

Thanks very much.

The code in your outer loop is setting the projection matrix, you are scaling the modelview matrix, and you don’t clear it out, so every frame, you are going to be scaling again. (OpenGL is a state machine, the state of the modelview matrix won’t change unless you change it.)

So, frame 1, you scale by 13,13. Frame 2, you will now be scaling 1313, 1313. Frame 3, 131313, 131313, etc… as you can see, you will quickly be scaling this up.

Edit: I guess your code never set the matrix mode to GL_MODELVIEW like it should have so you are scaling the GL_PROJECTION matrix, which in itself is usually a no no.

[This message has been edited by Deiussum (edited 09-04-2003).]

I just talked to someone about it and found out I am missing glTranslate.

Thanks for all the info.

Hi !

You cannot put a glScale between glbegin() glEnd(), you can only use glColor…glVertex… and a few other functions between glbegin/glEnd.

Mikael

Yeah, exactly why I should have the got the error (mentioned above).

Thanks for the info though.

I have no more questions.

Thanks everybody.

The code you gave didn’t show anywhere where you were checking for errors. To get errors, you need to actually check for them using glGetError(). The compiler won’t help you with this, and no exceptions will be thrown.