Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Get no picture by sing opengl  (Read 2157 times)

0 Members and 1 Guest are viewing this topic.

Ninjasturm

  • Newbie
  • *
  • Posts: 16
    • View Profile
Get no picture by sing opengl
« on: October 20, 2010, 03:39:54 pm »
Hello Community,

i want to use OpenGL
but when i run this modfied example.

Code: [Select]

#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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Get no picture by sing opengl
« Reply #1 on: October 20, 2010, 03:52:26 pm »
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.
Laurent Gomila - SFML developer

Ninjasturm

  • Newbie
  • *
  • Posts: 16
    • View Profile
Get no picture by sing opengl
« Reply #2 on: October 20, 2010, 03:55:57 pm »
I used the example but now i want try it at my own.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Get no picture by sing opengl
« Reply #3 on: October 20, 2010, 04:10:06 pm »
Of course, but you can use it to see what's wrong in your code.
Laurent Gomila - SFML developer