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.


Messages - bonsairobo

Pages: [1]
1
Window / Re: X360 controller triggers on linux
« on: July 13, 2013, 07:50:53 pm »
Hey thanks! I actually just got it working with sudo xboxdrv --detach-kernel-driver --mimic-xpad. I don't own an X360 controller so I had to emulate one with my Dualshock 3. This way I was actually able to split the triggers between the Z and R axes.

2
Window / Re: X360 controller triggers on linux
« on: July 13, 2013, 04:02:04 am »
Then I'm out of luck? None of the sf::Joystick axes map to the triggers.

3
Window / X360 controller triggers on linux
« on: July 12, 2013, 10:56:17 pm »
I'm currently trying to figure out how the triggers on an X360 controller are defined in sf::Joystick. Running jstest-gtk shows that the triggers each belong to an axis. However, I don't think those axes are exposed to SFML. X and Y are used for the left analog stick, U and V for the right analog stick, and Z and R are not defined, according to sf::Joystick::hasAxis(0, sf::Joystick::Z/R). The only other option would be that they are interpreted as buttons, and I'm not sure which ones to check.

4
Oh wow.  Thanks!  I guess I need to start using -Wall.

5
Here is the library I wrote with SFML:

#include <string>
#include "SFML/Graphics.hpp"

class Window
{
public:
        sf::RenderWindow window;
        sf::Event event;

        Window(int width, int height, std::string title)
        {
                window.create(sf::VideoMode(width, height, 32), title);
        }

        void display()
        {
                window.display();
        }

        bool pollEvents()
        {
                while(window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                        {
                                window.close();
                                return false;
                        }
                        else
                                return true;
                }
        }

        void clear()
        {
                window.clear();
        }
};

extern "C" Window* new_Window(int width, int height, char title[])
{
        return new Window(width, height, title);
}

extern "C" void display_Window(Window* window)
{
        window->display();
}

extern "C" void clear_Window(Window* window)
{
        window->clear();
}

extern "C" bool pollEvents_Window(Window* window)
{
        return window->pollEvents();
}

And here is the python wrapper:

from ctypes import *
windowLib = CDLL("./Window.so")

class Window(object):
        def __init__(self, width, height, title):
                self.obj = windowLib.new_Window(width, height, bytes(title, "ascii"))
               
        def display(self):
                windowLib.display_Window(self.obj)
               
        def clear(self):
                windowLib.clear_Window(self.obj)
               
        def pollEvents(self):
                return windowLib.pollEvents_Window(self.obj)
               
window = Window(800, 600, "Title")

windowIsOpen = True
while windowIsOpen:
        windowIsOpen = window.pollEvents()
        print(windowIsOpen)
        window.clear()
        window.display()

This python script works for opening the window, but the window closes shortly afterwords.  The print function manages to print "1 1 1 0" before the window closes itself.  I'm not sure what's causing my pollEvents function to return 0.

7
This might be something funky with my own computer, but I sent one of my programs to a friend and he had the same problem.

Whenever I poll for an event as written in the code below, my program will close if I circle my mouse cursor around the top or bottom left corners of the window.

The problem is illustrated in this video: http://youtu.be/PD7-y1_H6qo?t=15s

You can try it yourself by downloading my pong game here: http://www.mediafire.com/?6xrvvtbr7qc03jo, but the same problem occurs in any program I make using the method below.

while(tetris.isOpen())
        {
                sf::Event event;
                while(tetris.pollEvent(event))
                {
                        if (event.key.code == sf::Keyboard::Escape)
                                tetris.close();
                }
        }
 

8
Graphics / Re: Can't draw text or use text constructor [Solved]
« on: January 22, 2013, 08:29:32 pm »
Thanks for the help BTW  :)

9
Graphics / Re: Can't draw text or use text constructor
« on: January 22, 2013, 08:26:02 pm »
OK loading a font from a ttf file worked.  I did NOT need to clear the screen to see the text, but adding tetris.clear() made the text less "fuzzy".  Obviously I will clear the screen once I start making my game.

This code worked for me:

sf::Font arial;
arial.loadFromFile("arial.ttf");
sf::Text text("hello", arial, 30);
text.setPosition(0, 0);
text.setStyle(sf::Text::Bold);
text.setColor(sf::Color(255, 0 , 255));
 

10
Graphics / Re: Can't draw text or use text constructor
« on: January 22, 2013, 08:09:39 pm »
I compiled SFML with cmake and nmake from the "SFML 2.0 Snapshot" on the downloads page of this site.

I wasn't aware the default font was removed.  The documentation here (http://www.sfml-dev.org/documentation/2.0/classsf_1_1Text.php) suggests you can pass only a string to the constructor.

Clearing the window shouldn't be necessary for the code I've written since I'm not moving any draw-able objects.

I will try setting a font and come back with my results.

11
Graphics / Can't draw text or use text constructor [Solved]
« on: January 22, 2013, 07:55:38 pm »
#include <SFML\Graphics.hpp>
#include <iostream>
using namespace std;

#define RENDERHEIGHT 800
#define RENDERWIDTH 400

int main()
{
        sf::RenderWindow tetris(sf::VideoMode(RENDERWIDTH, RENDERHEIGHT, 32), "TETRIS");
        tetris.setFramerateLimit(60);
        tetris.setMouseCursorVisible(false);

        sf::Text text;
        text.setString("hello");
        text.setPosition(0, 0);
        text.setCharacterSize(30);
        text.setStyle(sf::Text::Bold);
        text.setColor(sf::Color::Red);

        while(tetris.isOpen())
        {
                sf::Event event;
                while(tetris.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed || event.key.code == sf::Keyboard::Escape)
                                tetris.close();
                }

                tetris.draw(text);
                tetris.display();
        }

        return 0;
}
 

I'm using SFML 2.0.  That is my exact code, which compiles, but no text is visible.  I've tried setting different positions, loading my own font (which gave me a runtime error), and on top of that, the text constructor won't accept string arguments.

sf::Text text("hello"); does not compile as VS doesn't think the constructor takes string arguments.

Any help?

Pages: [1]