Hi, I want to use SFML to create a window and handle input for OpenGL but I also want to use SFML for drawing strings(because it seams easy to me and I don't want to search for another OpenGL textlibrary).
Now I have a code to draw an image(with texturemapping) but when I execute the function, no matter if it is before or after the textdrawing, the drawn string is always white.
That's the relevant codepart:
img->draw(); // if I comment this line out the text is red as it should be
if(m_show_fps)
{
static int i(0);
stringstream fps("");
fps << "fps: " << static_cast<int>(1/m_window->GetFrameTime()) << endl;
sf::String fps_drawable(fps.str(), Font::GetDefaultFont(), 10);
fps_drawable.SetColor(Color::Red);
m_window->Draw(fps_drawable);
}
And image::draw
void image::draw() const
{
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBindTexture(GL_TEXTURE_2D, m_tex_name);
glVertexPointer(coord_per_vertex, GL_SHORT, coord_per_vertex*sizeof(GLshort), &m_vertices[0]);
glTexCoordPointer(texel_per_vertex, GL_FLOAT, texel_per_vertex*sizeof(GLfloat), &m_tex_coords[0]);
glDrawElements(GL_QUADS, vertices_per_square, GL_UNSIGNED_BYTE, &m_indices[0]);
glFlush();
}