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 - akhena

Pages: [1]
1
Window / Fullscreen mode not working
« on: June 09, 2012, 04:47:27 pm »
Hello everyone,

I would be glad to get some help here with my problem. It seems like I can't go in fullscreen mode without problems.

So first here is my minimal code :

#include <SFML/Graphics.hpp>

 int main()
 {
     // Create the main window
     sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window", sf::Style::Fullscreen);

     // Create a graphical text to display

     sf::Text text("Hello SFML", sf::Font::getDefaultFont(), 50);


     // Start the game loop
     while (window.isOpen())
     {
         // Process events
         sf::Event event;
         while (window.pollEvent(event))
         {
             // Close window : exit
             if (event.type == sf::Event::Closed)
                 window.close();
         }

         // Clear screen
         window.clear(sf::Color(200,200,128));

         // Draw the string
         window.draw(text);

         // Update the window
         window.display();
     }

     return EXIT_SUCCESS;
 }
 

When I run this, I get a black screen and nothing seems to work anymore. There are no response from keyboard inputs. I tried Ctrl-Alt-Del to no avail.

I'm on windows 7. Compiled with the latest SFML from GitHub. Tried to link on both release and debug dll.

I tried to debug to see how far I can go, but it stops at
void WindowImplWin32::switchToFullscreen(const VideoMode& mode)
{
    DEVMODE devMode;
    devMode.dmSize       = sizeof(devMode);
    devMode.dmPelsWidth  = mode.width;
    devMode.dmPelsHeight = mode.height;
    devMode.dmBitsPerPel = mode.bitsPerPixel;
    devMode.dmFields     = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;

    // Apply fullscreen mode
    if (ChangeDisplaySettings(&devMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
 
this last line.

Might be obvious as it will indeed go in fullscreen.

If you see anything I could do to find what's wrong, that would be of great help.

PS : I realize this should have gone in the Window forum. If a mod wants to move it, be my guest. :)

2
Graphics / Text rendering problem
« on: September 04, 2011, 03:59:28 pm »
Hello,

I finally made a "minimal" code to show the bug I had when displaying some text. I know this problem doesn't happen on all computers, as it doesn't on my laptop. Nevertheless, I thought it might be of interest.

If anyone has an idea to help me find the culprit, I would appreciate.

Code: [Select]
#include <iostream>
#include <list>
#include <vector>
#include <SFML/Graphics.hpp>

using namespace std;

int main()
{
    sf::Font font;
    // Create a window and its view
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
    // Load font
    if (!font.LoadFromFile("comic.ttf"))
        {
            std::cout << "Could not load font." << std::endl;
            return EXIT_FAILURE;
        }

    typedef std::list<std::string> StringList;
    StringList stringList;

    stringList.push_back("Test avec le texte");
    stringList.push_back("éèàêzZaA ù");
    stringList.push_back("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    stringList.push_back("abcdefghijklmnopqrstuvwxyz");
    stringList.push_back("éèàê");

    std::vector<sf::Text> textLines;
    float lastLinePosition = 0.f;

    for(std::list<std::string>::iterator line = stringList.begin(); line != stringList.end();
            ++ line)
    {
        sf::Text textLine(*line, font, 20);
        textLine.SetColor(sf::Color::Red);
        sf::Vector2f position;
        position.x = 10.f;
        position.y = std::floor(10.f + lastLinePosition + 0.5);
        textLine.SetPosition(position);
        textLines.push_back(textLine);
        lastLinePosition += font.GetLineSpacing(20);
    }

    // Start the game loop
    while (window.IsOpened())
    {
        // Process events
        sf::Event event;
        while (window.PollEvent(event))
        {
            // Close window : exit
            if (event.Type == sf::Event::Closed)
                window.Close();
        }

        // Clear screen
        window.Clear();
        for(std::vector<sf::Text>::iterator line = textLines.begin(); line != textLines.end();
                    ++line)
        {
            window.Draw(*line);
        }
        // Update the window
        window.Display();

    }
    return EXIT_SUCCESS;

}

Of course you'll need comic.ttf in your folder. But I guess this font can be found on most computers...

I'm running this on an AMD 2400++ with an ATI Radeon 9600 graphic card. I already tried to install the latest driver, with no success.

You can find my print screen here : http://imageshack.us/f/684/sfmltext.jpg
The problem appears on the 4th line.

3
Graphics / sf::View
« on: August 22, 2011, 03:58:23 pm »
I'm starting to use SFML2. I'm a bit surprised that the View in a RenderWindow is not a reference to an external view, but a copy of the View passed to the SetView method. I was expecting that one could use some code like this :

Code: [Select]

sf::RenderWindow window(sf::VideoMode(800, 600), "SFML test");
sf::View camera(sf::FloatRect(0.f, 0.f, 800.f, 600.f));
camera.SetViewport(sf::FloatRect(0.f, 0.f, 1.f, 1.f));
window.SetView(camera);

//and then later on
camera.Move(20.f, 0.f);
//But nothing happen until I call
window.SetView(camera);


Did I miss something ? Is there a design reason for not holding a reference but a local copy of the View object ? Thanks for clarifying.  :)

Pages: [1]
anything