SFML community forums
Help => General => Topic started by: Ninjasturm on October 20, 2010, 03:39:54 pm
-
Hello Community,
i want to use OpenGL
but when i run this modfied example.
#include <SFML/Window.hpp>
int main()
{
// Fenster erstellen
sf::Window App(sf::VideoMode(800, 600, 32), "OpenGL");
glClearDepth(1.f);
glClearColor(0.f, 0.f, 0.f, 0.f);
// Z - Buffer
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
// Projektion
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.f, 1.f, 1.f, 500.f);
// Hauptschleife
while (App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
{
App.Close();
}
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
{
App.Close();
}
if (Event.Type == sf::Event::Resized)
{
glViewport(0, 0, Event.Size.Width, Event.Size.Height);
}
}
App.SetActive();
// Fenster leeren
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.f, 0.f, -200.f);
glBegin(GL_POLYGON);
glVertex3f (0, 0, 0);
glVertex3f (25, 0, 0);
glVertex3f (0, 0, 25);
glVertex3f (25, 0, 25);
glEnd();
App.Display();
}
return EXIT_SUCCESS;
}
i get no picture only a black screen.
thx for help
-
This could be a wrong OpenGL state, bad matrices, incorrect vertex order, ... it's hard to tell.
You should start with the Window sample from the SFML SDK, it does exactly the same thing (except that it draws a 3D cube) -- and it works.
-
I used the example but now i want try it at my own.
-
Of course, but you can use it to see what's wrong in your code.