OpenGL + SFML need help ...

The Rectangle doesnt show up .. Why?
and if anybody knows how to set the perspective in OGL tell me pls
and what does glFlush mean?

thanks for help :D


#include<SFML/OpenGL.hpp>
#include<SFML/Graphics.hpp>
#include<iostream>

int main ()
{
float a = 0.2f;
float l = 0.3f; //length
float x = 0;
float y = 0;
bool run = 1;
std::cout << x << y << a;

sf::RenderWindow window (sf::VideoMode(800, 600), "test01");
while (run == 1)
{

glBegin(GL_QUADS);
glVertex3f(x+a, y+a, 0);
glVertex3f(x+a, y+a, 0);
glVertex3f(x+a, y+a, 0);
glVertex3f(x+a, y+a, 0);
glEnd();

window.display();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

}


return 0;
}
Last edited on
It may be because you forgot to set any of the colors, but you've actually forgotten to include SFML\RenderWindow.hpp so this shouldn't compile. My mistake, RenderWindow.hpp is included in Graphics.hpp. You should try setting the colors of the shapes and the glClearColor.
Last edited on
FWIW, you're using old (deprecated) OpenGL functions.

If you want a good tutorial on modern OpenGL, I recommend the arcsythesis tutorial here:
http://www.arcsynthesis.org/gltut/
thats my new Code .. and thx for the site it's really good ;)

#include<SFML/OpenGL.hpp>
#include<SFML/Graphics.hpp>
#include<iostream>

int main ()
{
float a = 0.2f;
float l = 0.3f; //length
float x = 0;
float y = 0;
bool run = 1;
std::cout << x << y << a;

sf::RenderWindow window (sf::VideoMode(800, 600), "test01");
while (run == 1)
{

glBegin(GL_QUADS);
glColor3f(9,9,9);
glVertex3f(x+a, y+a, 0);
glVertex3f(x+a, y+a, 0);
glVertex3f(x+a, y+a, 0);
glVertex3f(x+a, y+a, 0);
glEnd();

window.display();
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

}


return 0;
}
All of your vertices are in exactly the same place.
vertices .. whats that?
The plural form of a vertex.
http://en.wikipedia.org/wiki/Vertex_(geometry)

They're what you're trying to build your quad out of. You're plotting four of them in your program, using the glVertex3f method.

In order for that quad to draw, you need to plot four vertices in a counter-clockwise order.

Two observations, though. First, as Disch pointed out, this is an old way of doing things in OpenGL. You're essentially relying on old methods that use fixed-function pipelines. These more or less went out the window when OpenGL 2.0 came into play little under a decade ago. My advice would be to take a look at the arcsynthesis link Disch posted. It's one of the better OpenGL tutorials.

Second, if you're not sure what vertices are then I'd say you've skipped ahead a few chapters in OpenGL. You'd probably benefit from taking it back a couple of steps. My advice, again, is to read Disch's link. There are geometry primers in there that will help with stuff like this.
Last edited on
Yeah ... iam an idiot ...
Topic archived. No new replies allowed.