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

Pages: [1] 2 3
1
Window / Re: Qt5 window and SFML2
« on: May 22, 2013, 08:44:06 am »
Hi, thanks for the answer!

reinterpret_cast<sf::WindowHandle>(winId()); does not work, any other cast ideas?

It works out of the box for Linux, but not Windows.
Why am I not supposed to get an OS handle with winId()?

Thanks!

Hold on! Actually reinterpret_cast<sf::WindowHandl>(winId()); works just fine!

2
Window / Re: Qt5 window and SFML2
« on: May 22, 2013, 08:38:50 am »
Hi, thanks for the answer!

reinterpret_cast<sf::WindowHandle>(winId()); does not work, any other cast ideas?

It works out of the box for Linux, but not Windows.
Why am I not supposed to get an OS handle with winId()?

Thanks!

3
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  :)

4
Graphics / sf::RenderImage problem
« on: June 22, 2011, 03:34:09 pm »
Hmm that's too bad..

What I'm trying to accomplish is to draw a sprite consisting of a white square onto a black background several times with different positions to get a board of white squares separated with black lines.
Do you have any ideas on how to accomplish this with minimal effort?

Thanks in advance!

5
Graphics / sf::RenderImage problem
« on: June 22, 2011, 02:38:56 pm »
Here's a minimal example that reproduce the problem:

Code: [Select]


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

int main(int argc, char **argv)
{
   
    sf::RenderWindow App(sf::VideoMode(400, 400), "Test", sf::Style::Close);
    App.SetFramerateLimit(100);

    sf::RenderImage r_img;
   
   
    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
   
    while(App.IsOpened())
    {
   sf::Event Event;
   while(App.PollEvent(Event))
   {
           if(Event.Type == sf::Event::Closed)
           App.Close();
   }

   App.Clear(sf::Color::Green);
   App.Display();
    }
   
   
    return 0;
}


If I comment out the line
Code: [Select]
 r_img.Clear(sf::Color::White); //White background
everything works (i.e I see a window with green background).
If it's executed as-is, I just see a window pop in and out of existence, and the return code form the app is 1.

This seems weird to me..

6
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()

7
Graphics / X Error (Cannot isolate problem)
« on: March 04, 2011, 04:34:38 pm »
Yeah you're right. I corrected the simple SFML-app and it works fine.

From this I draw the conclusion that the problem is X-related in some way.. have to do some research, thanks!  :)

8
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 :(

9
Python / PySFML2
« on: December 22, 2010, 01:52:20 am »
I'm also wondering if it'll work soon :)

10
Network / Text encoding problem
« on: December 19, 2010, 11:54:53 pm »
I did like this and thought it would help, obviously I was wrong..  :o

Code: [Select]


void Process_string(std::string& str)
{
    QString myString = QString::fromStdString(str);

    myString.ToUtf8();

    str = myString.ToStdString();
}



Any idea why this doesn't work?

The receiving part looks somewhat like this (not complete code):

Code: [Select]


    sf::TcpSocket Communicator;
    char Buffer[4096];
    size_t length = 0;
    std::string temp1;

    Communicator.Receive(Buffer, 4096m length);

    temp1 = Buffer;

    Process_string(temp1);



So I figured now temp1 would be converted into utf8, no?


EDIT::

Function was faulty, now looks like this, still doesn't do the job though:

Code: [Select]

void Bot::Process_string(std::string& str)
{
    QString myString = QString::fromStdString(str);
   
    str = myString.toUtf8().constData();
}


EDIT 2 ::

Completely ignore this post, I did a major blunder :)
Everything works perfectly now :)

11
Network / Text encoding problem
« on: December 18, 2010, 08:02:29 pm »
Well it seems this will be tricky..

But if what I receive is ISO-8859-1, and my OS locale uses UTF-8, wouldn't all letter be unreadable? and not just å, ä and ö?

I can't see a simple solution to this, lol :)

12
Network / Text encoding problem
« on: December 18, 2010, 06:59:22 pm »
But the bottom line is I should put what I receive in a string, and then change the coding in the string?

EDIT: I think the server is sending iso-8859-1 characters.. is it possible to convert it to utf-8 when I receive the message?

13
Network / Text encoding problem
« on: December 18, 2010, 03:55:28 pm »
Hmm is there any way to find out you think?
Or would I have to ask the server operator?

14
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 :)

15
System / sf::Thread and class
« on: December 13, 2010, 04:54:23 pm »
Aaah, there it is.. I totally missed those examples :)
Thanks :)

Pages: [1] 2 3
anything