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

Pages: 1 2 [3] 4
31
Graphics / Making a shape with textures, how?
« on: April 10, 2011, 03:35:14 pm »
Okey, I've been toying around with shaders for a couple of days getting nowhere.. So now over to the next idea.

I was thinking some thing along texture splatting(For those not familar with the conecpt; http://en.wikipedia.org/wiki/Texture_splatting). Using texture splatting I would try to achive something like this;



I'll get back later today with some questions and maybe some tricks.

If any of you got tips for better performance with SFML + alphamap then please repley :)

32
Window / [Solved] Cant get SFML2 to work with Qt!
« on: April 08, 2011, 12:05:13 am »
Solved;

Put the MyCanvas into a .cpp and .h file like any other class and add the Q_OBJECT.

If your using Qt Creator, Clean project, build -> works :D

33
Window / [Solved] Cant get SFML2 to work with Qt!
« on: April 07, 2011, 02:50:42 pm »
Okey, posting from my android atm - Im at the store.

Well, last thing I tested before I left was that the
Code: [Select]

g_guiMainFrame->connect( g_guiBtn , SIGNAL(pressed()) , g_guiSFML , SLOT(hide()));


That made the SFML window go away(as it should), but my own declared slots doesn't work.

34
Window / [Solved] Cant get SFML2 to work with Qt!
« on: April 07, 2011, 02:19:29 pm »
Well, as far as I understand this should be right

Code: [Select]

    g_guiBtn = new QPushButton( "Test Button" , g_guiMainFrame );
    g_guiBtn->show();

    g_guiBtn->connect( g_guiBtn , SIGNAL(clicked()) , g_guiSFML , SLOT(MYEVENT()) );


and inside MyCanvas
Code: [Select]

public slots:
    void MYEVENT()
    {
        this->g_Draw = false;
        this->g_ClearColor = sf::Color::Red;
    }


still clear color dosen't change..

35
Window / [Solved] Cant get SFML2 to work with Qt!
« on: April 07, 2011, 01:35:02 pm »
Thanks Tank, forgot to mention that sorry :/

Well, lets say I want to execute the function "Clicked()" which is declared inside the "MyCanvas" class when the pushbutton is clicked.

Need more info?

36
Window / [Solved] Cant get SFML2 to work with Qt!
« on: April 07, 2011, 11:27:34 am »
Okey, got it working now.

But now I am having trouble registering events.

Ex. a button
Code: [Select]

int main(int argc, char **argv)
{
    QApplication App(argc, argv);

    // Create the main frame
    QFrame* MainFrame = new QFrame;
    MainFrame->setWindowTitle("Qt SFML");
    MainFrame->resize(15+200+800, 610);
    MainFrame->show();

    // Create a SFML view inside the main frame
    MyCanvas* SFMLView = new MyCanvas(MainFrame, QPoint(210, 5), QSize(800, 600));
    SFMLView->show();

    QPushButton* btn = new QPushButton(MainFrame);
    btn->resize( 100 , 100 );
    btn->move( 0 , 0 );
    btn->show();

    return App.exec();
}

37
Window / [Solved] Cant get SFML2 to work with Qt!
« on: April 06, 2011, 09:37:52 pm »
Okey, did some more research. This seems to be the first 7 lines the logger puts out.. after that it just spams the last message..

Code: [Select]

&"warning: GDB: Failed to set controlling terminal: Invalid argument\n"
Failed to get the window attributes
Failed to get the window attributes
Failed to activate the window's context
Failed to activate the window's context
Failed to activate the window's context

38
Window / [Solved] Cant get SFML2 to work with Qt!
« on: April 06, 2011, 07:18:23 pm »
Project (at the left side) -> Build Env. Click the details button, add it.


Now I get "Failed to activate the window's context" in the log, while the program is running. And in the SFML context there is only a frozen picture of the images behind the context @ startup.

39
Window / [Solved] Cant get SFML2 to work with Qt!
« on: April 06, 2011, 12:31:17 am »
Nevermind this post.

Edit:
Tried to compile the example only, just editing a few things.. Now I get

Code: [Select]

Starting /home/agrualon/LekeLand/QtGuiTest-build-desktop/LekeLand...
/home/agrualon/LekeLand/QtGuiTest-build-desktop/LekeLand: error while loading shared libraries: libsfml-graphics.so.2.0: cannot open shared object file: No such file or directory
/home/agrualon/LekeLand/QtGuiTest-build-desktop/LekeLand exited with code 127


which I think is cause of some errors in here
Code: [Select]

QT += core gui

TARGET = LekeLand
TEMPLATE = app

SOURCES += graphics-qt.cpp \
    QSFMLCanvas.cpp

HEADERS  += \
    QSFMLCanvas.hpp

INCLUDEPATH += /home/agrualon/SFML-2.0-build/include

LIBS += -L/home/agrualon/SFML-2.0-build/lib -lsfml-graphics -lsfml-window -lsfml-network -lsfml-audio -lsfml-system



Am I rite?

40
Window / [Solved] Cant get SFML2 to work with Qt!
« on: April 06, 2011, 12:01:42 am »
Ah, didn't see that tab-control.

Here is the compiler outpur

Code: [Select]

Running build steps for project LekeLand...
Configuration unchanged, skipping qmake step.
Starting: "/usr/bin/make" -w
make: Entering directory `/home/agrualon/LekeLand/LekeLand-build-desktop'
/usr/bin/qmake-qt4 -spec /usr/share/qt4/mkspecs/linux-g++ CONFIG+=debug -o Makefile ../LekeLand/LekeLand.pro
make: Leaving directory `/home/agrualon/LekeLand/LekeLand-build-desktop'
make: Entering directory `/home/agrualon/LekeLand/LekeLand-build-desktop'
g++  -o LekeLand main.o widget.o QSFMLCanvas.o    -L/usr/lib -L/home/agrualon/SFML-2.0-build/lib -lsfml-graphics -lsfml-window -lsfml-network -lsfml-audio -lsfml-system -lQtGui -lQtCore -lpthread
widget.o:(.rodata._ZTV6Widget[vtable for Widget]+0x7c): undefined reference to `Widget::paintEvent(QPaintEvent*)'
widget.o:(.rodata._ZTV6Widget[vtable for Widget]+0xe0): undefined reference to `Widget::OnInit()'
widget.o:(.rodata._ZTV6Widget[vtable for Widget]+0xe4): undefined reference to `Widget::OnUpdate()'
collect2: ld returned 1 exit status
make: Leaving directory `/home/agrualon/LekeLand/LekeLand-build-desktop'
make: *** [LekeLand] Error 1
The process "/usr/bin/make" exited with code %2.
Error while building project LekeLand (target: Desktop)
When executing build step 'Make'

41
Window / [Solved] Cant get SFML2 to work with Qt!
« on: April 05, 2011, 03:27:40 pm »
Hi

Is there a way to attach files?

Anyway, here is my current code:

QSFMLCanvas.h
Code: [Select]
#ifndef QSFMLCANVAS_H
#define QSFMLCANVAS_H

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <Qt/qwidget.h>
#include <Qt/qtimer.h>


////////////////////////////////////////////////////////////
/// QSFMLCanvas allows to run SFML in a Qt control
////////////////////////////////////////////////////////////
class QSFMLCanvas : public QWidget, public sf::RenderWindow
{
public :

    ////////////////////////////////////////////////////////////
    /// Construct the QSFMLCanvas
    ///
    /// \param Parent :    Parent of the widget
    /// \param Position :  Position of the widget
    /// \param Size :      Size of the widget
    /// \param FrameTime : Frame duration, in milliseconds (0 by default)
    ///
    ////////////////////////////////////////////////////////////
    QSFMLCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime = 0);

    ////////////////////////////////////////////////////////////
    /// Destructor
    ///
    ////////////////////////////////////////////////////////////
    virtual ~QSFMLCanvas();

private :

    ////////////////////////////////////////////////////////////
    /// Notification for the derived class that moment is good
    /// for doing initializations
    ///
    ////////////////////////////////////////////////////////////
    virtual void OnInit();

    ////////////////////////////////////////////////////////////
    /// Notification for the derived class that moment is good
    /// for doing its update and drawing stuff
    ///
    ////////////////////////////////////////////////////////////
    virtual void OnUpdate();

    ////////////////////////////////////////////////////////////
    /// Called when the widget is shown ;
    /// we use it to initialize our SFML window
    ///
    ////////////////////////////////////////////////////////////
    virtual void showEvent(QShowEvent*);

    ////////////////////////////////////////////////////////////
    /// Called when the widget needs to be painted ;
    /// we use it to display a new frame
    ///
    ////////////////////////////////////////////////////////////
    virtual void paintEvent(QPaintEvent*);

    ////////////////////////////////////////////////////////////
    // Member data
    ////////////////////////////////////////////////////////////
    QTimer myTimer;       ///< Timer used to update the view
    bool   myInitialized; ///< Tell whether the SFML window has been initialized or not
};


#endif // QSFMLCANVAS_H


QSFMLCanvas.cpp
Code: [Select]


////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include "QSFMLCanvas.h"

// Platform-specific headers
#ifdef Q_WS_X11
    #include <Qt/qx11info_x11.h>
    #include <X11/Xlib.h>
#endif


////////////////////////////////////////////////////////////
/// Construct the QSFMLCanvas
////////////////////////////////////////////////////////////
QSFMLCanvas::QSFMLCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime) :
QWidget       (Parent),
myInitialized (false)
{
    // Setup some states to allow direct rendering into the widget
    setAttribute(Qt::WA_PaintOnScreen);
    setAttribute(Qt::WA_NoSystemBackground);

    // Setup the widget geometry
    move(Position);
    resize(Size);

    // Setup the timer
    myTimer.setInterval(FrameTime);
}


////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////
QSFMLCanvas::~QSFMLCanvas()
{
    // Nothing to do...
}


////////////////////////////////////////////////////////////
/// Notification for the derived class that moment is good
/// for doing initializations
////////////////////////////////////////////////////////////
void QSFMLCanvas::OnInit()
{
    // Nothing to do by default...
}


////////////////////////////////////////////////////////////
/// Notification for the derived class that moment is good
/// for doing its update and drawing stuff
////////////////////////////////////////////////////////////
void QSFMLCanvas::OnUpdate()
{
    // Nothing to do by default...
}


////////////////////////////////////////////////////////////
/// Called when the widget is shown ;
/// we use it to initialize our SFML window
////////////////////////////////////////////////////////////
void QSFMLCanvas::showEvent(QShowEvent*)
{
    if (!myInitialized)
    {
        // Create the SFML window with the widget handle
        Create(winId());

        // Let the derived class do its specific stuff
        OnInit();

        // Setup the timer to trigger a refresh at specified framerate
        connect(&myTimer, SIGNAL(timeout()), this, SLOT(repaint()));
        myTimer.start();

        myInitialized = true;
    }
}


////////////////////////////////////////////////////////////
/// Called when the widget needs to be painted ;
/// we use it to display a new frame
////////////////////////////////////////////////////////////
void QSFMLCanvas::paintEvent(QPaintEvent*)
{
    // Let the derived class do its specific stuff
    OnUpdate();

    // Display on screen
    Display();
}


main.cpp
Code: [Select]


////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include "QSFMLCanvas.h"
#include <Qt/qapplication.h>
#include <Qt/qframe.h>


////////////////////////////////////////////////////////////
/// Custom SFML canvas
////////////////////////////////////////////////////////////
class MyCanvas : public QSFMLCanvas
{
public :

    ////////////////////////////////////////////////////////////
    /// Construct the canvas
    ///
    ////////////////////////////////////////////////////////////
    MyCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size) :
    QSFMLCanvas(Parent, Position, Size)
    {

    }

private :

    ////////////////////////////////////////////////////////////
    /// /see QSFMLCanvas::OnInit
    ///
    ////////////////////////////////////////////////////////////
    void OnInit()
    {
        // Change the background color

    }

    ////////////////////////////////////////////////////////////
    /// /see QSFMLCanvas::OnUpdate
    ///
    ////////////////////////////////////////////////////////////
    void OnUpdate()
    {

    }

    ////////////////////////////////////////////////////////////
    /// Member data
    ////////////////////////////////////////////////////////////
};


////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main(int argc, char **argv)
{
    QApplication App(argc, argv);

    // Create the main frame
    QFrame* MainFrame = new QFrame;
    MainFrame->setWindowTitle("Qt SFML");
    MainFrame->resize(400, 400);
    MainFrame->show();

    // Create a SFML view inside the main frame
    MyCanvas* SFMLView = new MyCanvas(MainFrame, QPoint(20, 20), QSize(360, 360));
    SFMLView->show();

    return App.exec();
}


My Qt Creator project file:
Code: [Select]

#-------------------------------------------------
#
# Project created by QtCreator 2011-04-05T12:51:44
#
#-------------------------------------------------

QT       += core gui

TARGET = LekeLand
TEMPLATE = app


SOURCES += main.cpp\
        widget.cpp \
    QSFMLCanvas.cpp

HEADERS  += widget.h \
    QSFMLCanvas.h

FORMS    += widget.ui

INCLUDEPATH += /home/agrualon/SFML-2.0-build/include
LIBS += /home/agrualon/SFML-2.0-build/lib/libsfml-system.so \
    /home/agrualon/SFML-2.0-build/lib/libsfml-window.so \
    /home/agrualon/SFML-2.0-build/lib/libsfml-graphics.so \
    /home/agrualon/SFML-2.0-build/lib/libsfml-audio.so \
    /home/agrualon/SFML-2.0-build/lib/libsfml-network.so


The problem is that when I build it, it returns:
Code: [Select]

collect2: id returned 1 exit status


Nothing more..

I created the project using Qt Creator, File -> New File or Project -> Qt C++ Project. In the wizard I selected QWidget as my base-class..

Any halp?

42
Feature requests / Shaders, vertex shaders?
« on: April 05, 2011, 02:35:05 am »
Well, there is a bunch of functions that the fragment shader don't have, and vice versa.

And sometimes when building more complicated shaders the vertex shader needs to pass some info over to the fragment shader..

43
Feature requests / Shaders, vertex shaders?
« on: April 04, 2011, 08:46:40 pm »
Hi!

Any possibility to expand the shader class some more? Why doesn't SFML support vertex shaders? Is there ever going to be support for vertex shader?

Seems like all new games(even 2d indie games) uses some advanced "shading"..

44
Graphics / Making a shape with textures, how?
« on: April 04, 2011, 08:09:48 pm »
I'm sorry, but I don't really know - just recompiled for the 4th time and it worked  :?:

45
Graphics / Making a shape with textures, how?
« on: April 04, 2011, 06:34:58 pm »
Okey, got a shader working, or at least in the WYSWIG editor.. What now?

How do I apply a shader to only one shape? or sprite?

Edit: Didn't see the Draw( sprite , shader ) when I read the src the first time, sorry.

Pages: 1 2 [3] 4