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

Pages: [1] 2
1
General / [Solved] Crashing within sf::RenderWindow constructor.
« on: May 03, 2013, 11:36:56 pm »
I just downloaded the latest SFML 2, and now I have mysterious crashes when going over the sf::RenderWindow constructor.  With this makefile and code, "test 1" is displayed, then the program crashes.  I am not very familiar with static linking, so that could be the cause.  Any help would be greatly appreciated.

compile = -c -Wall -std=c++0x -g # -mwindows
link = -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -g  # -mwindows -lsfml-main
objects = sfmlTesting.o

all: $(objects)
        g++ $(objects) $(link) -o sfmlTesting.exe

sfmlTesting.o: sfmlTesting.cpp
        g++ sfmlTesting.cpp $(compile)

check-syntax:
        g++ -Wall -o nul -std=c++0x -S ${CHK_SOURCES}
 

#define SFML_STATIC

#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
    std::cout << "test 1" << std::endl;
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    std::cout << "test 2" << std::endl;
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
 

2
Graphics / TextureRect changes without function call?
« on: July 14, 2012, 11:45:39 pm »
When I move my sprite to the right or left, there are random flashes of the line of pixels to the right of it on the sprite map.  Just as if the width of the texture rect were increased by one for one frame.  During this movement, the setTextureRect function is not called.  Would this have anything to do with giving the sprite float co-ordinates?

3
General / How to do real-time input with sfml 2?
« on: April 20, 2012, 11:16:26 pm »
In sfml 1.6 this was handled by the sf::input class, but I can't seem to find it or an equivalent in the sfml 2 documentation.  Could someone help me out?

4
General / Trouble linking with SFML 2 release candidate
« on: April 16, 2012, 04:20:49 am »
My program seems to compile fine, but when it gets to the linking step, a bunch of errors pop up.

This code:
Code: [Select]
#include <SFML/Graphics.hpp>

int main ()
{
    sf::RenderWindow window (sf::VideoMode (800, 600, 32), "SFML_Testing");

    sf::RectangleShape rect (sf::Vector2f (19, 19));

    sf::Event event;

    while (window.isOpen ())
    {
        int x = 0;
        int y = 0;
       
        while (window.pollEvent (event))
        {
           
            if (event.type == sf::Event::Closed)
                window.close ();

            if (event.type == sf::Event::KeyPressed)
            {
                if (event.key.code == sf::Keyboard::Left)
                    x -= 1;
                if (event.key.code == sf::Keyboard::Right)
                    x += 1;
                if (event.key.code == sf::Keyboard::Down)
                    y += 1;
                if (event.key.code == sf::Keyboard::Up)
                    y -= 1;
            }
        }
        rect.move (x, y);
        window.clear (sf::Color::Black);
        window.draw (rect);
        window.display ();
    }
               

    return 0;
}

these errors:

Code: [Select]
mingw32-make -k
g++ -Wall -c sfml_testing.cpp
g++ -o sfml_testing.exe sfml_testing.o -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lsfml-main -DSFML_STATIC
sfml_testing.o:sfml_testing.cpp:(.text+0x9f): undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
sfml_testing.o:sfml_testing.cpp:(.text+0xe3): undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKSsjRKNS_15ContextSettingsE'
sfml_testing.o:sfml_testing.cpp:(.text+0x13e): undefined reference to `_imp___ZN2sf14RectangleShapeC1ERKNS_7Vector2IfEE'
sfml_testing.o:sfml_testing.cpp:(.text+0x174): undefined reference to `_imp___ZN2sf6Window5closeEv'
sfml_testing.o:sfml_testing.cpp:(.text+0x1e5): undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
sfml_testing.o:sfml_testing.cpp:(.text+0x219): undefined reference to `_imp___ZN2sf13Transformable4moveEff'
sfml_testing.o:sfml_testing.cpp:(.text+0x220): undefined reference to `_imp___ZN2sf5Color5BlackE'
sfml_testing.o:sfml_testing.cpp:(.text+0x233): undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
sfml_testing.o:sfml_testing.cpp:(.text+0x23a): undefined reference to `_imp___ZN2sf12RenderStates7DefaultE'
sfml_testing.o:sfml_testing.cpp:(.text+0x258): undefined reference to `_imp___ZN2sf12RenderTarget4drawERKNS_8DrawableERKNS_12RenderStatesE'
sfml_testing.o:sfml_testing.cpp:(.text+0x266): undefined reference to `_imp___ZN2sf6Window7displayEv'
sfml_testing.o:sfml_testing.cpp:(.text+0x274): undefined reference to `_imp___ZNK2sf6Window6isOpenEv'
sfml_testing.o:sfml_testing.cpp:(.text+0x29e): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
sfml_testing.o:sfml_testing.cpp:(.text+0x2cf): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
sfml_testing.o:sfml_testing.cpp:(.text+0x30f): undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
sfml_testing.o:sfml_testing.cpp:(.text$_ZN2sf14RectangleShapeD1Ev[sf::RectangleShape::~RectangleShape()]+0xb): undefined reference to `_imp___ZTVN2sf14RectangleShapeE'
sfml_testing.o:sfml_testing.cpp:(.text$_ZN2sf14RectangleShapeD1Ev[sf::RectangleShape::~RectangleShape()]+0x19): undefined reference to `_imp___ZTVN2sf14RectangleShapeE'
sfml_testing.o:sfml_testing.cpp:(.text$_ZN2sf14RectangleShapeD1Ev[sf::RectangleShape::~RectangleShape()]+0x2a): undefined reference to `_imp___ZN2sf5ShapeD2Ev'
collect2: ld returned 1 exit status
mingw32-make: *** [all] Error 1

5
General / Getting rid of the console on windows with mingw
« on: April 16, 2012, 02:12:30 am »
I want to be able to get rid of the console window, but still be able to use the same code on linux.  I am using SFML 1.6 and g++ with mingw on windows.  All of the explanations I have found have either been for code::blocks or visual studio.  Any help would be greatly appreciated.

6
General / sfml 2 static linking confusion
« on: April 09, 2012, 04:40:44 am »
I downloaded SFML 2 precompiled from sfml coder (the mingw one), I've copied the stuff in the include folder to my path, but what do I do to statically link sfml?  From guesswork, I have a makefile that looks like this:
Code: [Select]
all: sfml_testing.o
g++ -o sfml_testing.exe sfml_testing.o -l libsfml-graphics-s.a -l libsfml-window-s.a -l libsfml-system-s.a

sfml_testing.o:
g++ -c sfml_testing.cpp

This provides this error message:

Code: [Select]
mingw32-make -k
g++ -o sfml_testing.exe sfml_testing.o -l libsfml-graphics-s.a -l libsfml-window-s.a -l libsfml-system-s.a
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -llibsfml-graphics-s.a
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -llibsfml-window-s.a
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/bin/ld.exe: cannot find -llibsfml-system-s.a
collect2: ld returned 1 exit status
mingw32-make: *** [all] Error 1

I gather that I am either not naming the libraries correctly or not putting them in the right place, probably both. 
So what exactly am I doing wrong?

by the way, my cpp file is this:
#include <SFML/Window.hpp>
#include <iostream>

int main ()
{
    sf::Window App (sf::VideoMode (800, 600, 32), "SFML_Testing");

    int x;
    std::cin >> x;

    return 0;
}
 

7
General / SFML 1.6 problem on ubuntu
« on: October 16, 2011, 07:11:44 am »
I have sfml 1.6 working on windows, I made a little test program with a moving rotating square.  When I use that exact same code in ubuntu, the window simply copies what is behind it at the time of creation and draws nothing else.  There are no compile time errors and the input seems to be working, using <escape> to close the window anyway.

Does anyone know what I could have done wrong?

8
Graphics / Some clarification please
« on: October 06, 2011, 03:56:15 am »
What is the correct way to create a green square that is 15 * 15 pixels, and rotate it 180 degrees around its exact centre pixel?

I seem to be getting something wrong.

9
Graphics / All sprites shifted down and right when resizing the window
« on: August 05, 2011, 07:09:09 am »
I am using window resizing by factors of 2 and 3 for zooming in, and I have noticed that whenever the window is resized by a factor of 2 or 3 (I have not tried other sizes), All of the sprites are shifted down and right by exactly one pixel.  Here is some code showing the problem, what do I do?

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

int main()
{
    // Create main window
    sf::RenderWindow App(sf::VideoMode(200, 200),
                         "SFML Testing",
                         sf::Style::Titlebar | sf::Style::Close);

    sf::Font myFont;
    if (!myFont.LoadFromFile ("6x13font.ttf", 12))
    {
        // Error
    }

    sf::Image spriteSheet;
    spriteSheet.LoadFromFile ("Go_sprites.png");
    spriteSheet.SetSmooth (false);

    sf::Sprite mySprite;
    mySprite.SetImage (spriteSheet);
    while (App.IsOpened())
    {
        // Here we process the events list
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Space)
            {
                App.SetSize (400, 400);
            }

        }

        // Clear the screen with a color
        App.Clear(sf::Color::Black);

        // Here you will draw all stuff in the frame buffer
        App.Draw (mySprite);
        // Render the frame on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}

10
Graphics / How do I display a string while typing it?
« on: August 04, 2011, 09:08:14 pm »
I realize that this probably involves myString.GetText () and Event.Type.TextEvent, but I am a bit fuzzy on the details.  Could someone help me out?

11
Window / ".SetSize (x, y)" acting strangely
« on: July 27, 2011, 06:04:00 am »
The window resizing that is supposed to happen at lines 191-207 (right near the bottom) does nothing, and when I compile this on my ubuntu laptop, none of the window resizing does anything.  Did I do something wrong?

Code: [Select]
#include <iostream>
#include <SFML/Graphics.hpp>
#include "Go.h"


int main()
{
    // The zoom multiplyer, default : 1
    int zoomLevel = 1;

    // Load the spritesheet
    sf::Image spriteSheet;
    if (!spriteSheet.LoadFromFile("Go_sprites.png"))
    {
        // Error
    }
    // Get rid of the blurring effect
    spriteSheet.SetSmooth(false);
    // Make magenta see-through
    spriteSheet.CreateMaskFromColor(sf::Color::Magenta);

    // Load the font
    sf::Font myFont;
    if (!myFont.LoadFromFile ("6x13font.ttf", 36))
    {
        // Error
    }

        // Create main window
    sf::RenderWindow App(sf::VideoMode(245 * zoomLevel, 129 * zoomLevel),
                         "Go",
                         sf::Style::Titlebar | sf::Style::Close);

    // Reduce CPU usage by setting a max fps
    App.SetFramerateLimit(30);

    // TEMPORARY, Set a board size for testing
    int boardXDim = 9;
    int boardYDim = 9;

    // The main program loop
    // Closes when the window is closed
    while (App.IsOpened())
    {

        // Put all the menu stuff here

        Board myBoard (App, myFont, spriteSheet, boardXDim, boardYDim, zoomLevel);
        // The board loop
        // Exits when the window is closed or the game is exited
        while ((myBoard.inGame == true) && (App.IsOpened ()))
        {

            // Process the events list
            sf::Event Event;
            while (App.GetEvent (Event) && myBoard.inGame == true && App.IsOpened ())
            {
                // Close window : exit
                if (Event.Type == sf::Event::Closed)
                {
                    App.Close ();
                }

                // If the left mouse button was pressed
                if ((Event.Type == sf::Event::MouseButtonPressed) && (Event.MouseButton.Button == sf::Mouse::Left))
                {
                    // Clear the alerts
                    myBoard.clearAlerts ();

                    // if the mouse's x and y co-ordinates are on the pass button
                    if (myBoard.onPassButton ((((Event.MouseButton.X + 1) / zoomLevel) - 1), (((Event.MouseButton.Y + 1) / zoomLevel) - 1)))
                    {
                        myBoard.pass ();

                    }
                    // if the mouse's x and y co-ordinates are on a space on the board
                    if ((((((((Event.MouseButton.X + 1) / zoomLevel) - 1) - 1) % 14) > 0) && ((((Event.MouseButton.X + 1) / zoomLevel) - 1) <= (myBoard.gridToPixel (myBoard.xMax) + 6))) && (((((((Event.MouseButton.Y + 1) / zoomLevel) - 1) - 1) % 14) > 0) && ((((Event.MouseButton.Y + 1) / zoomLevel) - 1) <= (myBoard.gridToPixel (myBoard.yMax) + 6))))
                    {
                        // If the piece is sucessfully placed at the co-ordinates
                        if (myBoard.placePiece (myBoard.pixelToGrid (((Event.MouseButton.X + 1) / zoomLevel) - 1), myBoard.pixelToGrid (Event.MouseButton.Y / zoomLevel)))
                        {
                            // Move the selector to where the piece was placed
                            myBoard.selectorX = myBoard.pixelToGrid (((Event.MouseButton.X + 1) / zoomLevel) - 1);
                            myBoard.selectorY = myBoard.pixelToGrid (((Event.MouseButton.Y + 1) / zoomLevel) - 1);
                        }
                    }
                }

                // If a button was pressed act depending on which button
                if (Event.Type == sf::Event::KeyPressed)
                {
                    // If the key was escape, close the window
                    if (Event.Key.Code == sf::Key::Escape)
                    {
                        App.Close ();
                    }

                    // If the key was an arrow key ,vim key, or wasd key, move the selector accordingly
                    if ((Event.Key.Code == sf::Key::K) || (Event.Key.Code == sf::Key::Up) || (Event.Key.Code == sf::Key::W))
                    {
                        myBoard.moveSelector (0, -1);
                        myBoard.clearAlerts ();
                    }
                    if ((Event.Key.Code == sf::Key::H) || (Event.Key.Code == sf::Key::Left) || (Event.Key.Code == sf::Key::A))
                    {
                        myBoard.moveSelector (-1, 0);
                        myBoard.clearAlerts ();
                    }
                    if ((Event.Key.Code == sf::Key::L) || (Event.Key.Code == sf::Key::Right) || (Event.Key.Code == sf::Key::D))
                    {
                        myBoard.moveSelector (1, 0);
                        myBoard.clearAlerts ();
                    }
                    if ((Event.Key.Code == sf::Key::J) || (Event.Key.Code == sf::Key::Down) || (Event.Key.Code == sf::Key::S))
                    {
                        myBoard.moveSelector (0, 1);
                        myBoard.clearAlerts ();
                    }

                    // If space or enter was pressed, try to place a piece
                    if ((Event.Key.Code == sf::Key::Space) || (Event.Key.Code == sf::Key::Return))
                    {
                        myBoard.placePiece (myBoard.selectorX, myBoard.selectorY);
                    }

                    // If 'p' was pressed, pass
                    if (Event.Key.Code == sf::Key::P)
                    {
                        myBoard.pass ();
                        myBoard.clearAlerts ();
                    }

                    // If 1 - 3 was pressed change the zoom level
                    if (Event.Key.Code == '1')
                    {
                        zoomLevel = 1;
                        App.SetSize (myBoard.smallWindowWidth * zoomLevel, myBoard.smallWindowHeight * zoomLevel);
                    }

                    if (Event.Key.Code == '2')
                    {
                        zoomLevel = 2;
                        App.SetSize (myBoard.smallWindowWidth * zoomLevel, myBoard.smallWindowHeight * zoomLevel);
                    }

                    if (Event.Key.Code == '3')
                    {
                        zoomLevel = 3;
                        App.SetSize (myBoard.smallWindowWidth * zoomLevel, myBoard.smallWindowHeight * zoomLevel);
                    }
                }
            }
            // If the game is over begin the final counting of points
            if (myBoard.inGame == false)
            {
                // Start the wrap-up phase
                myBoard.inWrapUp = true;

                // Count surrounded space, add markers, update marker strings, and update the alerts string to who won and what to do next
                myBoard.countSpace ();

                // Continues to display until the window is closed, escape is pressed, or enter is pressed
                while ((myBoard.inWrapUp == true) && App.IsOpened ())
                {
                    // Process events for the wrap-up phase
                    sf::Event newEvent;
                    while (App.GetEvent (newEvent) && myBoard.inWrapUp == true && App.IsOpened ())
                    {
                        // Close window : exit
                        if (newEvent.Type == sf::Event::Closed)
                        {
                            App.Close ();
                        }

                        // If a button was pressed
                        if (newEvent.Type == sf::Event::KeyPressed)
                        {
                            // If the escape button was pressed exit the game
                            if (newEvent.Key.Code == sf::Key::Escape)
                            {
                                App.Close ();
                            }

                            // If the enter button was pressed, exit the wrap-up phase
                            if (newEvent.Key.Code == sf::Key::Return)
                            {
                                myBoard.inWrapUp = false;
                            }

                             // If 1 - 3 was pressed change the zoom level
                            if (Event.Key.Code == '1')
                            {
                                zoomLevel = 1;
                                App.SetSize (myBoard.smallWindowWidth * zoomLevel, myBoard.smallWindowHeight * zoomLevel);
                            }

                            if (Event.Key.Code == '2')
                            {
                                zoomLevel = 2;
                                App.SetSize (myBoard.smallWindowWidth * zoomLevel, myBoard.smallWindowHeight * zoomLevel);
                            }

                            if (Event.Key.Code == '3')
                            {
                                zoomLevel = 3;
                                App.SetSize (myBoard.smallWindowWidth * zoomLevel, myBoard.smallWindowHeight * zoomLevel);
                            }
                        }
                    }

                    // Draw and display the board
                    myBoard.drawBoard ();
                }
            }

            // Draw and display the board
            myBoard.drawBoard ();
        }
    }
    return 0;
}

12
Graphics / Sprite rotation help.
« on: July 08, 2011, 07:33:15 pm »
If I do this, will I end up with a 15 * 15 sprite rotated 90 degrees clockwise around the centre pixel?

Code: [Select]
mySprite.SetSubRect (sf::IntRect (62, 0, 76, 14));
mySprite.SetCenter (7, 7);
mySprite.Rotate (90);

13
Graphics / Am I changing the view correctly?
« on: July 07, 2011, 01:00:00 am »
Just to make sure.  If I use this code, each window co-ordinate will be 1 pixel, right?

Code: [Select]
int x = 200;
int y = 300;
myWindow.SetSize (x, y);
myView.SetFromRect (sf::FloatRect (0, 0, x - 1, y - 1));

14
Graphics / contents distorted when the window is resized
« on: July 06, 2011, 04:27:44 am »
When I resize my window, its contents are horribly distorted.  How do I get the contents to remain unchanged and show a bit more space at the bottom right?

15
Graphics / How do I display a variable?
« on: June 23, 2011, 08:18:10 pm »
Let's say that I have the integer "x", how do I display its value on the screen?

Pages: [1] 2