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

Pages: [1]
1
General / Re: SFML 2.0 with gtkmm-2.4
« on: June 17, 2012, 06:51:10 pm »
After lots and lots of trial and error :/ I finally managed to get it work. I just ended up integrating the GTK+ alongside the GTKmm code, so I'm able to draw the whole user interface using Gtkmm but the SFML window is written for GTK+, I guess this will have to do :P

#include <SFML/Graphics.hpp>
#include <gtkmm.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
using namespace std;

sf::RenderWindow prog;

gboolean on_exposed(GtkWidget *widget,GdkEvent *event, gpointer user) {
        prog.clear(sf::Color(255,255,255));
        prog.display();
        gtk_widget_queue_draw(widget);
        return true;
}

class HelloWorld : public Gtk::Window {
        public:
                HelloWorld();
        protected:
                virtual bool on_expose();
                Gtk::Widget *area;
};

HelloWorld::HelloWorld(){
        set_title("SFML!");
        GtkWidget* carea;
        carea = gtk_drawing_area_new();
        area = Glib::wrap(carea);

        add(*area);

        GdkEventMask mask;
        mask = GDK_ALL_EVENTS_MASK;

        gtk_widget_add_events(area->gobj(),mask);
        gtk_widget_set_can_focus(area->gobj(),true);
        gtk_widget_set_size_request(area->gobj(),640,480);
        gtk_widget_realize(area->gobj());
        gtk_widget_set_double_buffered(area->gobj(),false);
#ifdef WINDOWS
        prog.create(GDK_WINDOW_HWND(area->gobj()->window));
#else
        prog.create(GDK_WINDOW_XID(area->gobj()->window));
#endif

        g_signal_connect(area->gobj(),"expose-event",G_CALLBACK(on_exposed),NULL);


        show_all_children();
}

bool HelloWorld::on_expose() {
        prog.clear(sf::Color(255,255,255));
        prog.display();
        area->queue_draw();
        return true;

}

int main(int argc,char *argv[]) {
        Gtk::Main kit(argc,argv);

        HelloWorld helloworld;

        Gtk::Main::run(helloworld);
}

2
General / Re: [SFML 2.0] sf::Event::MouseMoveEvent problems
« on: June 17, 2012, 05:08:54 am »
Hey Harsay, you don't need to declare an sf::Event:MouseMoveEvent, as I believe that is static. When you call window.pollEvent(event) you send all the event data to the event variable. So in order to get the mouse's x all you need to do is call it from the event variable.

if (event.type == sf::Event:MouseMove) {
 int x = event.mouseMove.x;
 paletka.setPosition(x, 5);
 std::cout << x << std::endl;
}
 

3
General / SFML 2.0 with gtkmm-2.4
« on: June 17, 2012, 04:12:58 am »
Hey! I've been trying to get SFML to work with gtkmm-2.4. I've managed to get SFML to work with GTK+ following this, but I would much rather use gtkmm. I was looking at this for creating an SFML widget with gtkmm but I couldn't get it to compile. (I did change the outdated SFML code to SFML 2.0 code)

It would be very helpful if anyone could show me anything about setting up SFML 2.0 with gtkmm 2.4.

Pages: [1]