SFML community forums
Help => General => Topic started by: vicer1234 on June 09, 2011, 08:22:31 pm
-
Hi,
using Sprite.SetPosition(10,10) will set the sprite at 10,10 from the left top corner.
But in the same window if i use glVertex2f(10.0,10.0) it will get placed in some other position with reference to the centre of the screen (Opengl)
How to related it, like taking the SFML co-ordinate as reference the Opengl prmitives should also be drawn at the same place. eg
Sprite.SetPosition(10.0, 10.0); and glVertex2f(10.0,10.0) at the same place
How to make it happen???
All suggestions are welcome
-
It must be done in a derived sf::Drawable class, otherwise you won't get the modelview and projection matrices that SFML uses to draw stuff.
-
It must be done in a derived sf::Drawable class, otherwise you won't get the modelview and projection matrices that SFML uses to draw stuff.
Can you elaborate a little more please!!
you mean
class Block : public sf::Drawable
{
Draw();
}
void Block::Draw()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.f, 1.f, 1.f, 500.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//if the particle is still alive, then draw
glPushMatrix();
glTranslatef((iter)->m_ParticlePosition.x, (iter)->m_ParticlePosition.y, -400.0f);
glRotatef((iter)->m_Angle,0,0,1);
//glScalef(1.0f, 1.0f, 1.0f);
glColor4ub((iter)->m_Color.r, (iter)->m_Color.g, (iter)->m_Color.b, (iter)->m_Color.a);
glBegin(GL_QUADS);
glTexCoord2f(texCoords.Left, texCoords.Top); glVertex2f(-halfWidth, -halfHeight);
glTexCoord2f(texCoords.Left, texCoords.Bottom); glVertex2f(-halfWidth, halfHeight);
glTexCoord2f(texCoords.Right, texCoords.Bottom); glVertex2f(halfWidth, halfHeight);
glTexCoord2f(texCoords.Right, texCoords.Top); glVertex2f(halfWidth, -halfHeight);
glEnd();
glColor4ub(255, 255, 255, 255);
glPopMatrix();
}
Is this what u mean???
-
Nop.
sf::Renderer has one virtual function (Render), you must override it.