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

Pages: [1]
1
Graphics / Trouble with views
« on: July 18, 2008, 04:50:28 pm »
This isn't necessarily a problem with SFML, but more a request for help. what I'm trying to do is create a 352x352 pixel view inside of a 640x480 window in the top left corner that can scroll separately from the main window.

The obvious solution to me would be to use an sf::View, but I don't understand views at all. What exactly are the "Center" and "Half Width" parameters? I assumed they were the position of the "window" into whatever I'm drawing after the view is set, so I did something like this:

Code: [Select]
View LevelView(Vector2f(176,176), Vector2f(176, 176));

while (SFMLApp.IsOpened()) {
//Process events
while (SFMLApp.GetEvent(input)) {
//(...)
}

SFMLApp.SetView(LevelView);
SFMLApp.Draw(testlevel);
SFMLApp.Draw(Player);
SFMLApp.SetView(SFMLApp.GetDefaultView());
}


Instead what I get is this:



As you can see, the content of the view is stretched in strange ways. I read the View tutorial a few times, read the source for it a few times, and as far as I can tell there's no way to make a view that only takes up part of the screen. Is that true? Are views incomplete or am I misunderstanding their purpose? :?

2
Window / sf::RenderWindow fullscreen switch problem
« on: July 15, 2008, 05:33:46 am »
Hi! I'm just starting with SFML and I just want to say great job! I really like the concept and implementation of SFML, and the pre-built mingw libraries are a godsend for me. Usually I have to build my own from .dlls and .libs. :|

Anyway, after reading the tutorials I decided to try a simple test to really get comfortable with the library, but I've run into a small problem:

I'm using the RenderWindow::Create function to toggle between fullscreen and windowed modes, and it works beautifully going from the initial windowed mode to fullscreen, but when switching back the window remains the same size as my desktop, and as far as I can tell from reading the documentation and searching these forums there's no way to resize the window.

I'm using Code::Blocks and MinGW. Can anyone tell me what I'm doing wrong? Is this a quirk with the Windows/MinGW implementation or a bug/limitation in SFML? And if so is there a workaround or should I go ahead and dive into SFML's source? Any help is appreciated! :)

My source:
Code: [Select]
#include <SFML/Graphics.hpp>
using namespace sf;

int main() {
Event input;
bool fullscreen;
RenderWindow App(VideoMode(640, 480, 16), "SFML Test");

while (App.IsOpened()) {
        //Process events
        while (App.GetEvent(input)) {
            //Exit
            if (input.Type == Event::Closed) App.Close();
            if ((input.Type == Event::KeyPressed) && (input.Key.Code == Key::Escape)) App.Close();
            //Fullscreen toggle
            if ((input.Type == Event::KeyPressed) && (input.Key.Code == Key::F)) {
fullscreen = !fullscreen;
App.Create(VideoMode(640, 480, 16), "SFML Test", (fullscreen ? Style::Fullscreen : Style::Resize|Style::Close));
}
        }

        App.Display();
}

return EXIT_SUCCESS;
}


P.S. It seems that it's not just the window size that's off, but the video mode. Displaying a 640x480 image in the window results in a large black space around it after switching to fullscreen and back.

Edit: I knew I was forgetting something. I'm using the latest stable version of SFML: 1.3.

Pages: [1]
anything