I also heard from my sister's husband that it would be wise to make a new Draw class for this and then make two "virtual" functions that have same name for example effect, one for scaling and one for rotating which you would use in the draw function by calling the effect function of wanted type
That can be a good solution for some problems, but this isn't one of them. virtual functions are part of C++ that let you implement the same thing for objects that have the same base class, for instance.
class shape
{
protected virtual void draw();
}
class square : shape
{
protected virtual draw()
{
//code to draw a square
}
}
class triangle : shape
{
protected virtual draw()
{
//code to draw a triangle
}
}
Then, any time someone hands you a 'shape' object, you can call shape->draw() and it will know how to draw that shape whether it's a triangle or a square.
btw, since you're not calling ogl_draw/ogl_flip inside the GetMessage loop any more, your app will eventually become unresponsive and crash. You need to pump (Get/Dispatch) messages.
I don't understand this...those for loops are on the place where was earlier the ogl_draw() function and flip function too How this is not inside GetMessage loop? I understand the for loop is making this problem but I don't see any way to fix it. Cos I need some way to control the lenght of that flipping and as I see it the only way is with for loop(=?)
OK, they were inside the loop, but if you draw 1180 frames, that's over 20seconds you are not responding to messages, and Windows will complain.
Here is roughly how I would do it:
//setup
#define ROTATING 1
#define SCALING 2
#define FINISHED 3
int state = ROTATING;
float scale = 1.0f;
float angle = 0.0f;
int frame = 0;
...
...
do
{
MSG msg;
while (PeekMessage(&msg,NULL,0,0, PM_NOREMOVE))
{
if (GetMessage(&msg,NULL,0,0)>0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
quit = 1;
break;
}
}
if (state == ROTATING)
{
angle += 0.5f;
frame++;
if (frame > 180)
state = SCALING;
}
else if (state == SCALING)
{
scale -= 0.001f;
frame++;
if (frame > 180 + 1000)
state = FINISHED;
}
ogl_draw(angle, scale);
ogl_flip();
} while (!quit);
bool ogl_draw(float angle, float scale)
{
...
glTranslatef(0,0,-5000);
glRotatef(angle,0,0,1);
glScalef(scale,scale,scale);
}
I think that will work.
On a separate note, you wrote this
for (j=0.999; j>0.0;j-=0.001)
{
float scaleamount = j;
ogl_draw(true);
}
and then inside ogl_draw() you had this
glScalef(scaleamount,scaleamount,scaleamount);
I guess you must also have added a global variable line at the top of the code like this
float scaleamount;
The problem is these two scale amounts are not the same scaleamount. The one in the for loop only lives inside the for loop. The other one would be unaffected. This is called 'scoping'. If you'd like to understand that more then give me a shout.

Jim