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

Pages: [1] 2
Graphics / SFML 2RC sf::View Not Updating
« on: April 30, 2012, 02:46:42 am »
I am trying to zoom and pan my view with the keyboard. I can manipulate the view when I first create my window... just not during the loop.  Am I doing this the wrong way?

#include <stdexcept>
#include <iostream>
#include <vector>
#include <stdlib.h>

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

using namespace std;

int main(int argc, char** argv) {
        //set up a clock to keep track of time
        sf::Clock clock;

        sf::RenderWindow *window;       //sfml window object

        //create a new SFML rendering window
        window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "SFML Test");
        sf::View *view;
        view = const_cast<sf::View*>( &window->getView() );

        //prevent crazy frame rates (and make the framerate pseudo-sync with the physics stepping, though this is a crappy method of doing so)
        sf::Texture texture;
        if (!texture.loadFromFile("./images/blah.jpg")) throw runtime_error("could not load blah.png");
        sf::Sprite sprite;
        sf::Vector2f spriteSize = sf::Vector2f(sprite.getLocalBounds().width, sprite.getLocalBounds().height);
        sprite.setOrigin(spriteSize.x/2, spriteSize.y/2);

        sf::Event sfmlEvent;
        //start the game loop
        while ( window->isOpen() )
                //check for window closing events
                while (window->pollEvent(sfmlEvent)) {
                        if (sfmlEvent.type == sf::Event::Closed) window->close();
                        if (sfmlEvent.type == sf::Event::KeyPressed) {
                                if (sfmlEvent.key.code == sf::Keyboard::Escape) window->close();

                //get the current "frame time" (seconds elapsed since the previous frame, hopefully close to 1/60 since vsync is enabled)
                float frameTime = clock.restart().asSeconds();
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Comma)) ( view->zoom(1.1) );
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Period)) ( view->zoom(0.9) );

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) ( view->move(-1,0) );
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) ( view->move(1,0) );
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) ( view->move(0,1) );
                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) ( view->move(0,-1) );
                //clear the window's rendering area before drawing


                //update the rendering window with all the latest drawn items

        //clean up before exiting
        delete window;
        return EXIT_SUCCESS;

Graphics / Why does rendering time vary?
« on: January 23, 2012, 03:25:34 am »
When I run this app, the first few iterations consistently take much less time compared to latter iterations, can anyone explain why?

Code: [Select]
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>

using namespace std;

int main()
float time = 0;

    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
sf::Image image;
sf::Sprite sprite;

sf::Clock clock;

for(int i=0; i<10; i++)
for(int i=0; i<5000; i++)
time = clock.GetElapsedTime();

printf("time: %f \n", time);

int x;

    return EXIT_SUCCESS;

This is the output I get:

Window / Funny Window Titles
« on: January 22, 2012, 05:03:56 am »
Hi, I just started a new project and started with one of the tutorials as a base, except my window title isnt showing up correctly.  Its showing as random characters. Any ideas?

Pic: https://legacy.sfmluploads.org/cache/pics/196_Capture.PNG

Code: [Select]

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

using namespace std;
int main()
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
    // 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 (fill it with black color)

        // Display window contents on screen

    return EXIT_SUCCESS;

General discussions / Question about rendering performance.
« on: January 14, 2012, 05:03:25 am »
Hello, I am just curious what the performance cost would be if each frame of my animated sprite were a separate png vs setting the sub rect of a large sprite sheet each frame.

General discussions / SFML CMake Linux question
« on: May 02, 2011, 10:13:43 am »
Why does it build 3 copies of each library? Are they different at all?

libsfml-audio.so        libsfml-graphics.so.2.0    libsfml-network.so.2.0.0  libsfml-window.so
libsfml-audio.so.2.0    libsfml-graphics.so.2.0.0  libsfml-system.so         libsfml-window.so.2.0
libsfml-audio.so.2.0.0  libsfml-network.so         libsfml-system.so.2.0     libsfml-window.so.2.0.0
libsfml-graphics.so     libsfml-network.so.2.0     libsfml-system.so.2.0.0

Network / [SFML2] sf::Socket::Status::Done warning/error
« on: April 17, 2011, 03:45:57 am »
Code: [Select]
if(socket.Receive(packet,address,port) == sf::Socket::Status::Done)

gives me this warning in visual c++ 2010:

warning C4482: nonstandard extension used: enum 'sf::Socket::Status' used in qualified name

In linux it actually gives me an error. I would post the error but I dont have access to a linux machine at the moment.

Audio / Sound fails on repeated play
« on: April 07, 2011, 04:49:03 pm »
SFML 2.0

If I repeatedly play a sound it works for a couple seconds then the sound stops altogether. The music keeps going however.

"An internal OpenAL call failed in SoundSource.cpp(39) AL_INVALID_VALUE, a numeric argument is out of range"

"An internal OpenAL call failed in SoundSource.cpp(39) AL_INVALID_NAME, an unacceptable name has been specified"

"An internal OpenAL call failed in Sound.cpp(107) AL_INVALID_NAME, an unacceptable name has been specified"

"An internal OpenAL call failed in Sound.cpp(76) AL_INVALID_NAME, an unacceptable name has been specified"

Window / Changing window mode causes crash in linux.
« on: April 06, 2011, 07:29:02 pm »
SFML 2.0
Works perfectly fine on WinXP.

Code: [Select]

if(Event.Key.Code == sf::Key::Num1)

VideoMode videoMode = sf::VideoMode::GetDesktopMode();
ContextSettings windowSettings = sf::ContextSettings(0,0,0);

if(winMode == FULLSCREEN)
window->Create(videoMode, "GameEngine", sf::Style::Default|sf::Style::Close, windowSettings);
windowMode = WINDOW;
else if(winMode == WINDOW)
window->Create(videoMode, "GameEngine", sf::Style::Fullscreen|sf::Style::Close, windowSettings);
windowMode = FULLSCREEN;

Graphics / Antialias polygon edges.
« on: April 05, 2011, 10:49:27 pm »
Is there a way to anti alias polygon edges? Right now when I draw my tiles they look great other than when the camera moves; the edge pixels cant decide what pixel to draw on so they "flash" on and off of adjacent pixels and its very unattractive.

My current solution was to set everything to smooth and create a transparent border around all of my images such that the edges of the polygons are invisible so you cant see them regardless. This works great for my dynamic objects, however I have yet to come up with a graceful solution for my tile sets. Any ideas?

Window / RenderWindow fullscreen.
« on: April 05, 2011, 08:51:33 pm »
Is there a way to toggle between windowed and fullscreen at run time?

Graphics / SFML 2.0 RenderImage
« on: March 31, 2011, 08:58:08 am »
Is there a limit on the size of a RenderImage?
Also, is this even stable in SFML 2 because im getting lots of strange behavior.

Graphics / Error when closing application?
« on: March 23, 2011, 10:38:13 am »
Heres my call stack. Is this a bug or did I do something stupid?

Code: [Select]
> msvcp100d.dll!std::num_put<char,std::ostreambuf_iterator<char,std::char_traits<char> > >::put(std::ostreambuf_iterator<char,std::char_traits<char> > _Dest, std::ios_base & _Iosbase, char _Fill, unsigned long _Val)  Line 1105 + 0x21 bytes C++
  msvcp100d.dll!std::basic_ostream<char,std::char_traits<char> >::operator<<(unsigned int _Val)  Line 316 + 0x73 bytes C++
  AdventureGun.exe!sf::priv::GLCheckError(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & file, unsigned int line)  Line 104 + 0x9d bytes C++
  AdventureGun.exe!sf::Image::~Image()  Line 88 + 0x31 bytes C++
  AdventureGun.exe!sf::Font::Page::~Page()  + 0x4e bytes C++
  AdventureGun.exe!std::_Pair_base<unsigned int const ,sf::Font::Page>::~_Pair_base<unsigned int const ,sf::Font::Page>()  + 0x19 bytes C++
  AdventureGun.exe!std::pair<unsigned int const ,sf::Font::Page>::~pair<unsigned int const ,sf::Font::Page>()  + 0x16 bytes C++
  AdventureGun.exe!std::pair<unsigned int const ,sf::Font::Page>::`scalar deleting destructor'()  + 0x16 bytes C++
  AdventureGun.exe!std::_Destroy<std::pair<unsigned int const ,sf::Font::Page> >(std::pair<unsigned int const ,sf::Font::Page> * _Ptr)  Line 64 C++
  AdventureGun.exe!std::allocator<std::pair<unsigned int const ,sf::Font::Page> >::destroy(std::pair<unsigned int const ,sf::Font::Page> * _Ptr)  Line 213 + 0x9 bytes C++
  AdventureGun.exe!std::_Dest_val<std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,std::pair<unsigned int const ,sf::Font::Page> >(std::allocator<std::pair<unsigned int const ,sf::Font::Page> > & _Alval, std::pair<unsigned int const ,sf::Font::Page> * _Pdest)  Line 288 C++
  AdventureGun.exe!std::_Tree<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::_Erase(std::_Tree_nod<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::_Node * _Rootnode)  Line 1617 + 0x22 bytes C++
  AdventureGun.exe!std::_Tree<std::_Tmap_traits<unsigned int,sf::Font::Page,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,sf::Font::Page> >,0> >::clear()  Line 1416 C++
  AdventureGun.exe!sf::Font::Cleanup()  Line 298 C++
  AdventureGun.exe!sf::Font::~Font()  Line 70 C++
  AdventureGun.exe!`sf::Font::GetDefaultFont'::`2'::`dynamic atexit destructor for 'font''()  + 0xd bytes C++
  msvcr100d.dll!doexit(int code, int quick, int retcaller)  Line 567 C
  msvcr100d.dll!_cexit()  Line 408 + 0xb bytes C
  msvcr100d.dll!__CRTDLL_INIT(void * hDllHandle, unsigned long dwReason, void * lpreserved)  Line 313 C
  msvcr100d.dll!_CRTDLL_INIT(void * hDllHandle, unsigned long dwReason, void * lpreserved)  Line 217 + 0x11 bytes C
  [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]

General discussions / SFML 2.0 Threads
« on: March 16, 2011, 03:24:08 am »
I tried the examples from 1.6 but I get this error:

error C2512: 'sf::Thread' : no appropriate default constructor available

Code: [Select]
class MyClass : private sf::Thread
public :

    void DoSomething()

private :

    virtual void Run()
        // Do something...

General discussions / vertical sync
« on: March 12, 2011, 09:35:18 am »
I am testing on a number of machines and architectures and my windows 7 machine seems to not limit the frame rate on vsync. Does anyone have any idea why this would be happeneing?

Graphics / SFML 2.0 image constructor
« on: March 12, 2011, 05:56:59 am »
In 1.6 you could do something like
sf::Image *image = new sf::Image(200,100,sf::Color(0,255,0));

how can you achieve this in 2.0?

Edit: Just found the sf::Image::Create() function. Looks like it will work.

Pages: [1] 2