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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Gallaecio

Pages: [1]
1
Window / Re: Black screen during fullscreen
« on: October 21, 2012, 07:53:26 am »
After reading the topic opengl and fullscreen, I tried executing the OpenGL code of the reshape() function right after entering fullscreen mode. Now it works! :)

The code in question, displayed in my original post, was:

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    gluPerspective(90.0f, (GLfloat)width/(GLfloat)height, 1.0f, 1000.0f);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
 

2
Window / Re: Black screen during fullscreen
« on: October 21, 2012, 07:27:45 am »
The OpenGL example works perfectly well, but it does not use fullscreen. My OpenGL code works too. The problem is only during fullscreen.

I posted so much code just in case, the relevant part should just be:

    bool fullscreen = false;
    while (window.isOpen())
    {
        // [OpenGL Code Runs here, omitted]
        window.display();

        sf::Event event;
        while(window.pollEvent(event))
        {
            if (event.type == sf::Event::KeyReleased)
            {
                if (event.key.code == sf::Keyboard::F)
                {
                    fullscreen = !fullscreen;
                    if (fullscreen)
                    {
                        VideoMode videoMode = sf::VideoMode::getDesktopMode();
                        window.create(videoMode, appName, sf::Style::Fullscreen);
                    }
                    else
                    {
                        VideoMode videoMode(width, height, color);
                        window.create(videoMode, appName);
                    }
                }
            }
            else if (event.type == sf::Event::Resized)
            {
                app.reshape((GLsizei) event.size.width, (GLsizei) event.size.height);
            }
            else if (event.type == sf::Event::Closed)
            {
                window.close(); break;
            }
        }
    }
 

Anyone sees something wrong in that code? The application does go fullscreen, but does not show the OpenGL figures, which are drawn based on the height and width of the screen (so they should appear).

3
Window / Black screen during fullscreen
« on: October 20, 2012, 04:53:22 pm »
This is my code:

// Project.
#include "main.hpp"

// Third-Party Libraries.

    // OpenGL.
    #include "GL/glu.h"

    // SFML.
    #include "SFML/Window.hpp"

using sf::VideoMode;
using sf::Window;
using std::string;

Main::Main(GLsizei width, GLsizei height)
{
    glEnable(GL_DEPTH_TEST);
    reshape(width, height);
}

void Main::reshape(GLsizei width, GLsizei height)
{
    m_width = width;
    m_height = height;

    glViewport(0, 0, width, height);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90.0, width/height, 1.0, 100.0);

    glMatrixMode(GL_MODELVIEW);
}

void Main::render()
{
    glLoadIdentity();
    gluLookAt(0.0, 1.0, 6.0,
              0.0, 0.0, 0.0,
              0.0, 1.0, 0.0);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glBegin(GL_TRIANGLES);
        glColor3f(1.0, 0.0, 0.0);
        glVertex3f(2.0, 2.5, -1.0);
        glColor3f(0.0, 1.0, 0.0);
        glVertex3f(-3.5, -2.5, -1.0);
        glColor3f(0.0, 0.0, 1.0);
        glVertex3f(2.0, -4.0, 0.0);
    glEnd();

    glBegin(GL_POLYGON);
        glColor3f(1.0, 1.0, 1.0);
        glVertex3f(-1.0, 2.0, 0.0);
        glColor3f(1.0, 1.0, 0.0);
        glVertex3f(-3.0, -0.5, 0.0);
        glColor3f(0.0, 1.0, 1.0);
        glVertex3f(-1.5, -3.0, 0.0);
        glColor3f(0.0, 0.0, 0.0);
        glVertex3f(1.0, -2.0, 0.0);
        glColor3f(1.0, 0.0, 1.0);
        glVertex3f(1.0, 1.0, 0.0);
    glEnd();
}


/**
 * Main function.
 */

int main(int argc, char* argv[])
{
    GLsizei width = 1600;
    GLsizei height = 900;
    GLsizei color = 32;

    bool fullscreen = false;

    string appName = "OpenGL Tests";

    // Create the application window with an OpenGL context to draw on.
    Window window(VideoMode(width, height, color), appName);
    window.setVerticalSyncEnabled(true);

    // Interface initialization.
    Main app(width, height);

    // Main loop.
    while (window.isOpen())
    {

        app.render();
        glFlush();
        window.display();

        // Event handling.
        sf::Event event;
        while(window.pollEvent(event))
        {
            if (event.type == sf::Event::KeyReleased)
            {
                if (event.key.code == sf::Keyboard::F)
                {
                    fullscreen = !fullscreen;
                    if (fullscreen)
                    {
                        VideoMode videoMode = sf::VideoMode::getDesktopMode();
                        if (videoMode.isValid())
                        {
                            window.create(videoMode, appName, sf::Style::Fullscreen);
                        }
                    }
                    else
                    {
                        VideoMode videoMode(width, height, color);
                        if (videoMode.isValid())
                        {
                            window.create(videoMode, appName);
                        }
                    }
                }
            }
            else if (event.type == sf::Event::Resized)
            {
                app.reshape((GLsizei) event.size.width, (GLsizei) event.size.height);
            }
            else if (event.type == sf::Event::Closed)
            {
                window.close(); break;
            }
        }

    }

  return 0;
}
 

It works just fine in windowed mode, but when I turn on the fullscreen mode by pressing F, the screen turns black and the figures rendered with OpenGL are not there. I can only see the system cursor.

Then, I press F again and I get back to the windowed mode normally. I can still see the figures, and I can resize the window and get them repainted correctly.

I am working under Chakra Linux using SFML 2.0 RC 1.

4
Window / Re: X error on program exit
« on: May 18, 2012, 08:22:30 pm »
I run into this, and found out how to solve it. It was quite simple, actually.

I was doing this:

while (window.IsOpened())
{
  sf::Event event;
  while(window.GetEvent(event))
  {
    // Window-broad event handling.
    if (event.Type == sf::Event::Closed)  window.Close();
    // [More event handling]
  }

  // [OpenGL Rendering]
  window.Display();
}

Now, I am doing this instead:

while (window.IsOpened())
{
  // [OpenGL Rendering]
  window.Display();

  sf::Event event;
  while(window.GetEvent(event))
  {
    // Window-broad event handling.
    if (event.Type == sf::Event::Closed)  { window.Close(); break; }
    // [More event handling]
  }
}

Before, I was closing the window and later calling window.Display(), which I guess was triggering the error. Now, upon close action on the user side, I close the window, break the event handling (any additional event will not matter since the application is being closed), and since the event handling is now at the end of the loop, there is no further call to window.Display().

Now the output is clean when leaving the application :)

5
Feature requests / Distribute CMake configuration file
« on: September 05, 2011, 05:18:28 pm »
I though there was no officially-maintained FindSFML.cmake file, and so I reported in CMake, linking a file someone had done in SFML forums.

They answered me. It turns out you do distribute a FindSFML.cmake file, but you should distribute a package configuration file instead. That's what I understood from the answer from a CMake guy, who also included documentation in his answers to do the thing.

So, it's up to you. As a SFML user, I already got what I was looking for :)

Pages: [1]
anything