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.


Topics - Gallaecio

Pages: [1]
1
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.

2
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]