// Calculate the (new) xPos & yPos according to the NewPosition
void AviObject::SetPosition(long NewPosition)
{
if (NewPosition == 1) // Left top
{
xPos=0.0f;
yPos=0.0f;
}
else if (NewPosition == 2) // Right top
{
xPos=GLdouble(Init.ScreenWidth)-GLdouble(dWidth);
yPos=0.0f;
}
else if (NewPosition == 3) // Left bottom
{
xPos=0;
yPos=Init.ScreenHeight-dHeight;
}
else if (NewPosition == 4) // Right bottom
{
xPos=Init.ScreenWidth - dWidth;
yPos=Init.ScreenHeight - dHeight;
}
else if (NewPosition == 5) // Centered
{
xPos=(Init.ScreenWidth/2) - (dWidth/2);
yPos=(Init.ScreenHeight/2) - (dHeight/2);
}
// xp1 left vector
// xp2 right vector
// yp1 top vector
// yp2 bottom vector
xp1=GLdouble(xPos);
xp2=xp1 + GLdouble((dWidth / Init.ScreenWidth));
yp1=GLdouble(yPos);
yp2=yp1 + GLdouble((dHeight/Init.ScreenHeight));
}
-------
I know it''s all messy, but that is because i have been spending a lot of time on it, and each time it compiles correctly, but it does NOT do anything.
It seems that i can''t assign values to INT''s, Doubles, Floats and i don''t know which type to use.
Any help would be appreciated
Error in my code, but where?
Hi, i am using Ortho mode to display a texture on the screen. I want 5 different positions for the texture (in first case).
Lefttop, righttop, leftbottom, rightbottom and centred.
To calculate the correct vectors i made this code:
-------
The function does not actually do any opengl calls, it is only calculating the new xp1/2 and yp1/2. You do nothing with these vars. You should either pass them in as addresses to the function to modify them via pointers, or do some opengl call to set the glTexCoord or something like that.
Please ignore me I am being stupid! (these vars are probably class member variables?).
[edited by - DMTSC on April 17, 2002 8:14:20 AM]
Please ignore me I am being stupid! (these vars are probably class member variables?).
[edited by - DMTSC on April 17, 2002 8:14:20 AM]
You are right, i want to calculate the position only once, to increase performance. Only when the main app calls the class.setsize(3) then it should recalculate. In the draw function it should print the quad at xpos & ypos.
Without seeing the rest of the code to draw your quads it is difficult to see what is going wrong. An idea is that you mention drawing the quad from xpos,ypos - but looking at your set size function it would seem that you need to draw your quad from xp1,yp1 to xp2,yp2.
Hope this helps a little.
Hope this helps a little.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement