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

Pages: [1]
Window / help setting fullscreen resolution with view.
« on: February 29, 2012, 07:44:17 pm »

In window mode, I create the window, then I can scale it with setsize, and it scales the internal view perfectly. Allowing me to initially create a window to the size of my background and images, then have them all scaled up. In full screen mode I am struggling to do the same.

Here is my code;
Code: [Select]

// Headers
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>

/// Entry point of application
/// \return Application exit code
int main()
sf::Texture texBack;
sf::Sprite sprBack;

//current video mode
sf::VideoMode DesktopMode = sf::VideoMode::GetDesktopMode();

    // Create the main rendering window
sf::RenderWindow App; //(sf::VideoMode(320, 224, 32), "SFML Graphics", sf::Style::None);
sf::View view;
App.Create(sf::VideoMode(320, 220, DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::None);
view = App.GetView();
//App.Create(sf::VideoMode(DesktopMode.Width / 2, DesktopMode.Height / 2, DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::Fullscreen);
App.Create(sf::VideoMode(DesktopMode.Width, DesktopMode.Height, DesktopMode.BitsPerPixel), "SFML Graphics", sf::Style::Fullscreen);
[color=red] view.SetSize(320 * 2, 220 * 2);
view.SetCenter(320 , 220 );

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

        // Clear the screen with red color

        // Display window contents on screen

    return EXIT_SUCCESS;

The image is 320, 220, and I want it, so when I go to full screen, it scales with the window, no matter what resolution.

now I can not get it to do this, it always just rebuilds the view and my background is tiny,

UNLESS... I add these
Code: [Select]

[color=red] view.SetSize(320 * 2, 220 * 2);
view.SetCenter(320 , 220 );

320 * 2 is not even my monitor res.....which is 2560x1440

which make no sense to me? and mess up window sizing anyway.

Also if I want to place a sprite at the edge of the window...should I use ;

   return Window.ConvertCoords(Window.GetWidth() , Window.GetHeight());

or the view size?

Feature requests / Better input support
« on: February 14, 2012, 03:02:55 pm »
I thought I would write it here, so it's not forgotten,

maybe a roadmap would be helpful for the website?

While we wait for better keymaps, more keys and maybe better named joystick keys.

Really annoying right now, how can I make anything for release which might fail on its input?

Is there anything that we can do?

Not sure I want to go including a separate input library...not that I actually found one that is not tied to orge :\

General / Trouble loading font ttfs from stream.
« on: February 14, 2012, 02:45:00 pm »
Hey, all my images and data files load from a stream fine. apart from fonts, though they are being done in the same way.

I'm using the physfs class from the wiki.

this loads my font

Code: [Select]
const sf::Font * imageManager::getFont( const sf::String& filename )
if(filename.GetSize() < 1)
return &sf::Font::GetDefaultFont();

// Check, whether the image already exists
std::map<sf::String, sf::Font>::iterator it = fontResources.find(filename);
if(it != fontResources.end())
return &it->second;

CGameEngine &Game = CGameEngine::getInstance();

sf::String fontpath("fonts/");
fontpath += filename;
std::string s(fontpath);

sf::Font font;
sf::physfs fontstream(fontpath.ToAnsiString().c_str());

// Search project's main directory
if( font.LoadFromStream(fontstream) )
fontResources[filename] = font;
//std::cout << "DEBUG_MESSAGE: " << filename << " loading image.\n";
return &fontResources[filename];

Game.consolePrint("Failed loading font \"" + fontpath + "\"");
return &sf::Font::GetDefaultFont();

this fails
Code: [Select]

if( font.LoadFromStream(fontstream) )

fontstream returns TRUE and not NULL.

returns true, it exists.

The images, textures is exactly the same, BUT it loads
Code: [Select]

if(texture.LoadFromStream(imagestream) )

This is what loads the file:

Code: [Select]

sf::physfs::physfs(const char *filename){
    file = PHYSFS_openRead(filename);
    error = false;
    if (file == NULL){
        sf::Err() << PHYSFS_getLastError() << std::endl;
        error = true;

PHYSFS_openRead, file is valid.

Any suggestions?

I tried loading the font from file, works fine.

General / Extend keyboard input keys
« on: February 11, 2012, 10:01:19 pm »
Hey everyone.

I would like to add some keys, namely the ` key

that's the little one next to the 1 key, `

As I would like it for my console bind, all my keys have a custom bind system, but that key I really miss having for console.

General / Change mouse cursor?
« on: January 21, 2012, 03:19:24 am »

is it possible through sfml to change the mouse cursor? Ive no idea how standard this is

Graphics / ARGB to RGBA or another method?
« on: December 23, 2011, 05:57:01 pm »
Hello I have a buffer in ARGB format. I am trying to bind it to a texture, sprite for display.

bitmap_in = sourceBuffer    
ARGB buffer with width/height of sourceBufferRect
Code: [Select]

if (!Image.LoadFromPixels(bitmap_rect.width(),bitmap_rect.height(), bitmap_in))
    // Error...

LoadFromPixels(w, h, PointerToPixelsInMemory);
Please note that when you load an image from memory, pixels must have a specific format, which is 32-bits RGBA.

I think I can bind them to opengl textures, but I don't regally want to do taht.

Is there a way in SF to load, translate the format?

anyone know of a good way, I am struggling to find much conversion information.

Edit: you know I'm sure you can do this at opengl level with parameters...maybe there is a way in SFML to just supply those parameters?


void glReadPixels(   GLint     x,
    GLint     y,
    GLsizei     width,
    GLsizei     height,
    GLenum     format,
    GLenum     type,
    GLvoid *     data);

though not looked how loadpixel works. I assume it just sets a format?

Pages: [1]