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

Pages: [1]
1
Window / Qt5 window and SFML2
« on: May 22, 2013, 08:30:22 am »
Hi all!

I'm trying to create a Qt application with an SFML canvas as described in the 1.6 tutorial, and it works great under Linux.

However, when compiling on Windows, I get this:

Quote
Code:
sf::RenderWindow::create(winId());

Compile routput:
'void sf::Window::create(sf::WindowHandle,const sf::ContextSettings &)' : cannot convert parameter 1 from 'WId' to 'sf::WindowHandle'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast

Qt5's winId() function returns what in the Qt world is refered to as quintptr (See: qwindowdefs.h)

Has anyone found a solution to this? Is there just a cast missing?

Thanks in advance  :)

2
Graphics / sf::RenderImage problem
« on: June 22, 2011, 01:52:36 am »
Hello there!

I'm trying to use sf::RenderImage with the latest SFML2 version from git.
Here's my code:
Code: [Select]


#include <iostream>
#include <SFML/Graphics.hpp>
#include <sstream>
// #include "board.h"

int main(int argc, char **argv)
{
   
    sf::RenderWindow App(sf::VideoMode(400, 400), "Test", sf::Style::Close);
    App.SetFramerateLimit(100);
   
    sf::Image img;
    sf::Sprite sprite;
    sf::RenderImage r_img;
   
   
    if(!img.LoadFromFile("welcome.png")) //An ordinary image
    {
       std::cout<<"Error"<<std::endl;
       return -1;
    }
   
    sprite.SetImage(img); //Sprite of the above image
    sprite.SetPosition(0.f, 0.f);
   
   
    if(!r_img.Create(App.GetWidth(), App.GetHeight())) //Create the renderimage
    {
       std::cout<<"Error"<<std::endl;
       return -1;
    }

    r_img.Clear(sf::Color::White); //White background
   
    r_img.Draw(sprite); //Draw the above sprite to the renderimage
    sprite.SetPosition(100.f, 100.f); //Move the sprite
    r_img.Draw(sprite); //Draw same sprite to different position
   
   
    sf::Sprite mySprite(r_img.GetImage(), sf::Vector2f(0,0)); //The sprite of the renderimage-image
   
    while(App.IsOpened())
    {
       sf::Event Event;
       while(App.PollEvent(Event))
       {
                   if(Event.Type == sf::Event::Closed)
                       App.Close();
       }

       App.Clear(sf::Color::Green);
       App.Draw(mySprite);
       App.Display();

    }
   
   
    return 0;
}



This code results in the opening of a window which is immediately closed.
I've been playing around with trying to draw images (sprites) and shapes to a RenderImage and then display it like this, but it has either resulted in a complete lock-up or that the application exits (no errors or anything).

I'm using an up-to-date version of Archlinux 64-bit, Intel GMA4500 with latest drivers.
glxgears runs perfectly with ~60fps (due to VSync)

Now.. Have I completely missed the purpose of sf::RenderImage, am I doing something wrong or is there something wrong with other software (like drivers or Xorg)?

Also, there seems to be no sf::RenderImage::IsAvailable()

3
Graphics / X Error (Cannot isolate problem)
« on: March 04, 2011, 04:00:46 pm »
Hello, I have an exact copy of the QT-integration tutorial source code and I'm trying to run it.
The application starts and all, but I cannot see the SFML-widget, and this is the output:

Code: [Select]
Starting: /home/ftp4/cpp/projects/qsnake/build/qsnake
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x5c0000a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x5c0000a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 8 (X_MapWindow)
  Resource id:  0x5c0000a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 2 (X_ChangeWindowAttributes)
  Resource id:  0x5c0000a
X Error: RenderBadPicture (invalid Picture parameter) 175
  Extension:    153 (RENDER)
  Minor opcode: 7 (RenderFreePicture)
  Resource id:  0x15a
X Error: BadWindow (invalid Window parameter) 3
  Major opcode: 4 (X_DestroyWindow)
  Resource id:  0x5c0000a
*** Exited normally ***


And if I try to run a simple non-qt SFML app such as

Code: [Select]

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

int main(int argc, char **argv) {
   
    sf::VideoMode Vid = sf::VideoMode::GetDesktopMode();
    Vid.Height = 600;
    Vid.Width = 400;
   
    sf::RenderWindow App(Vid,"Test", sf::Style::Close);
   
    sf::Event Event;
   
    while(App.IsOpened())
    {
while(App.GetEvent(Event)) {
   if(Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Escape)
App.Close();
}

App.Clear(sf::Color::Black);
    }

    return 0;
}



it just freezes (not really freezes, it takes all CPU power there is in the universe).

Any ideas what might be wrong?

Graphics drivers are up to date and all necessary libraries for X is installed.  
Same problem in SFML 1.6 and SFML 2 :(

4
Network / Text encoding problem
« on: December 18, 2010, 03:30:19 pm »
Hello fellow programmers!  :)

I'm using SFML2

I've been extending the functionality of MrX's irc-bot and I have a problem regarding the sf::TcpSocket::Receive(), or at least so I think..

I'm reading the incoming data from the server with
Code: [Select]

sf::TcpSocket::Receive(Buffer, 0, 4096)

where Buffer is a char Buffer[4096];

I then convert all the incoming data to a std::string and then continue to process what it contains etc.

The problem lies within the encoding of the text in the string. In the event of a name-list being received from the server I add them to a vector containing a custom class CUser.
But it seems that when the usernames contain the letters å, ä & ö, it fails totally.

If I try to output a username containing å, ä or ö into the console, the letter shows up as � and I'm not really sure what to do to help this.

Any ideas are welcome :)

5
System / sf::Thread and class
« on: December 13, 2010, 03:09:59 pm »
Hello, I know there are similar threads as this one, but none of them quite answer my question, or perhaps I am unable to comprehend the answer.

However my question is if it's possible to use a thread to run a member function of a class?

Something like this:

Code: [Select]

class A
{
    public:

        A() {
            sf::Thread Thr(&myFunction);
            Thr.Launch();
        }

    private:

        void myFunction()
        {
            // .... Do some stuff ... //
         }

};


Or is there perhaps other solutions?

6
Graphics / Possible sf::Shape positioning bug
« on: July 16, 2010, 01:19:32 pm »
This code, where shape is an sf::Shape, sets the position of shape to 200, 200. But it's still rotating around 12, 12..

Code: [Select]
   
       // Generates a triangle
    shape.AddPoint(12.f, 0.f, color, color);
    shape.AddPoint(0.f, 24.f, color, color);
    shape.AddPoint(24.f, 24.f, color, color);

    shape.EnableFill(false);
    shape.EnableOutline(true);
    shape.SetOutlineWidth(2.f);

    shape.SetCenter(12.f, 12.f);

    shape.Move(200.f, 200.f);


Is this a bug or am I missing something?

Thanks / xarxer  :)

7
Graphics / Inherit drawable?
« on: February 23, 2010, 06:52:59 pm »
Hi all..
I created a thread a while ago concerning almost the same thing.

The thing is I just cannot let this go, look at this piece of code:
http://codepad.org/LPxddsRq

As seen, object inherits from sf::Drawable and CSquare inherits from object.
To make CSquare drawable via App.Draw(mysquare);, the function void Render(sf::RenderTarget& Target) const   { Target.Draw(square); } is needed in CSquare.

But CSquare also has the functions SetPosition(), SetRotation(), SetScale() and so on inherited from sf::Drawable, but these functions won't actually do anything since they don't affect the sf::Sprite square in CSquare.

Is there any way to solve this nicely or is the ONLY way to use a reference to a sf::RenderWindow and make a function CSquare::Draw();?

Thanks in advance!  :)

8
Graphics / Inherit or contain?
« on: January 17, 2010, 03:50:20 pm »
Hi, I'm going to try to explain this correctly..

Let's say I have a class CEntity, like this:
Code: [Select]

class CEntity : public sf::Drawable
{
      private:
            int mX, mY;   //An entity always has a position
};


And then I have a class CObject, like this:
Code: [Select]

class CObject : public CEntity //Derived from CEntity
{
      private:
            sf::Sprite mTexture;    // An object always has a texture

      public:
            //We want to draw this object via sf::RenderWindow::Draw()
            virtual void Render(RenderTarget& Target) const
            {
                  Target.Draw(mTexture);
            }
};


Now, is this a bad thing to do?
And how should I do instead?

Let's say I call upon CObject::SetPosition(), there is no position to set?

I'm sorry if it's a bad example, but it was all that I could think of at the moment..

9
Audio / SetLoop(true) doesn't work
« on: October 18, 2009, 07:04:03 pm »
Hi guys and gals, this is my first post so bare with me..

It seems as if SetLoop(true) doesn't make sf::Music to loop, here's an example:

Code: [Select]

int main()
{
sf::Music Music;
Music.OpenFromFile("music\\hum.ogg");
Music.SetLoop(true);
Music.Play();

while(1)
{
sf::Sleep(1.0f);
}

return 0;
}


The music plays once, and everything goes quiet and the loop continues forever..

I'm running Windows XP, using Visual Studio 2008 and am using SFML1.5.

Thanks!  :)

Pages: [1]
anything