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

Pages: [1]
1
Window / [Linux] [SFML2] Another Threading Question ...
« on: March 14, 2011, 03:58:41 pm »
Sure, no problem.  I'll be sure to check out the source and try again once you do.

2
Window / [Linux] [SFML2] Another Threading Question ...
« on: March 14, 2011, 03:20:00 pm »
Sorry it took me a while to respond, I didn't have any alternate computers readily available.  I tested the same code under Windows and it works.  Don't have a Mac on hand so cannot verify whether the same problem persists in OS-X.  It would seem to be a Linux issue though.  What would you recommend?  I can dump any system info from the Linux box into this thread if you feel it might be helpful?

3
Window / [Linux] [SFML2] Another Threading Question ...
« on: March 13, 2011, 11:35:27 am »
Weird.  If I comment out the Display call, I can incrementally add back in the event handling and it works.  Conversely, I can comment GetEvent and incrementally add in the rendering and it works.  So exclusively one of either Display or GetEvent in the code works fine. e.g. both of the following work:

Thread #1: Create window, loop calling GetEvent
Thread #2: Empty infinite loop

Thread #1: Create window, empty infinite loop
Thread #2: loop calling Display

However as soon as I try to use both simultaneously, I receive the aforementioned errors.

Any thoughts? :-/

4
Window / [Linux] [SFML2] Another Threading Question ...
« on: March 13, 2011, 10:19:51 am »
Oops, sorry.  I had run a first pass minimalization but here's a second go.  I hope this is better.  It removes just about everything while maintaining the functionality I want to use (namely threading member functions).  The following snippets should give a full working example that produces the errors I'm seeing on my end.  Cutting out the extra rendering and event handling squashed the 3rd error but the first two still remain.

Errors:

Quote

xcb_io.c:221: poll_for_event: Assertion `(((long) (event_sequence) - (long) (dpy->request)) <= 0)' failed.

xcb_io.c:140: dequeue_pending_request: Assertion `req == dpy->xcb->pending_requests' failed.


Header (engine.hh):

Code: [Select]

#ifndef FRAMEWORK_ENGINE_HH_
#define FRAMEWORK_ENGINE_HH_

namespace sf { class Window; }

class Engine {
public:

Engine(void);
void start(void);

private:

void render(void);

bool running;
sf::Window* surface;

};

#endif // FRAMEWORK_ENGINE_HH_


Implementation (engine.cc):

Code: [Select]

#include <SFML/Window.hpp>
#include "framework/engine.hh"

Engine::Engine(void) : running(false), surface(0) {}

void Engine::render(void)
{
surface->SetActive(true);

while(running == true) {
surface->Display();
}

surface->SetActive(false);
}

void Engine::start(void)
{
running = true;
surface = new sf::Window(sf::VideoMode(640,480,32),"OpenGL Demo");
surface->SetActive(false);

sf::Thread thread(&Engine::render,this);
thread.Launch();

while (running == true) {
sf::Event event;
while (surface->GetEvent(event)) {}
}

}


And finally (main.cc):

Code: [Select]

#include "framework/engine.hh"

int main(int argc, char** argv)
{
Engine engine; engine.start();
return 0xdead;
}


If there's anything else I can do to help, let me know.  I'm very eager to get this working. :)

5
Window / [Linux] [SFML2] Another Threading Question ...
« on: March 13, 2011, 12:01:51 am »
First off I want to say that I'm really enjoying SFML after having tried several other windowing solutions over the past months.

As per this thread, I'm trying to separate rendering from input (and yes, I'm confident this is something I want to do).  I create and poll for events within the main thread and do all OpenGL'y things in another.  However like this second thread, Linux is complaining about the same things.  I'm pretty sure I've read through just about every post regarding separation of rendering from logic, but cannot fathom what I'm doing wrong.

I was originally receiving these errors in SFML 1.6 and moved up to 2.0 hoping it would fix everything.  It did not. :(

The errors: (Each time I make and run, I get one of these three errors.  The order and frequency with which I receive the three appears to be non-deterministic.)

Quote

xcb_io.c:221: poll_for_event: Assertion `(((long) (event_sequence) - (long) (dpy->request)) <= 0)' failed.

xcb_io.c:140: dequeue_pending_request: Assertion `req == dpy->xcb->pending_requests' failed.

*** glibc detected *** double free or corruption (fasttop): 0x000000000160c710 ***
======= Backtrace: =========
/lib/libc.so.6(+0x72985)[0x7fe7452cb985]
/lib/libc.so.6(cfree+0x6c)[0x7fe7452d08bc]
/usr/lib/libX11.so.6(_XReply+0x200)[0x7fe7448c1520]
//usr/lib64/opengl/xorg-x11/lib/libGL.so.1(+0x54832)[0x7fe744e13832]
//usr/lib64/opengl/xorg-x11/lib/libGL.so.1(+0x52659)[0x7fe744e11659]
/usr/lib64/dri/i965_dri.so(+0x39377)[0x7fe742883377]
/usr/lib64/dri/i965_dri.so(+0x39985)[0x7fe742883985]
/usr/lib64/dri/i965_dri.so(+0x389ec)[0x7fe7428829ec]
./pax[0x401fb2]
/usr/lib/libsfml-system.so.2.0(_ZN2sf4priv10ThreadImpl10EntryPointEPv+0x18)[0x7fe745f9ee98]
/lib/libpthread.so.0(+0x6d4c)[0x7fe745042d4c]
/lib/libc.so.6(clone+0x6d)[0x7fe74532fc5d]



The header:

Code: [Select]

#ifndef FRAMEWORK_ENGINE_HH_
#define FRAMEWORK_ENGINE_HH_

namespace sf { class Window; }
namespace sf { class Input; }
namespace sf { class Event; }

class Engine {
public:

Engine(void);
~Engine(void);

void start(void);

private:

void render(void);
void handleEvent(sf::Event const* event);
void handleKeyPressed(sf::Event const* event);
void handleKeyReleased(sf::Event const* event);

bool running;
sf::Window* surface;

};
#endif // FRAMEWORK_ENGINE_HH_


And implementation:

Code: [Select]

Engine::Engine(void) : running(false), surface(0) {}

Engine::~Engine(void)
{
if (surface) delete surface;
}

void Engine::handleEvent(sf::Event const* event)
{
switch(event->Type) {
case sf::Event::Closed: running = false; break;
default: break;
}
}

void Engine::render(void)
{

surface->SetActive(true);

glClearColor(0.0f,0.0f,0.0f,0.0f);
glViewport(0,0,640,480);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,640.0,480.0,0.0,1.0,-1.0);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
glLoadIdentity();

while(running == true) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glBegin(GL_QUADS);
glColor3f(1.0f,0.0f,0.0f); glVertex3f(0.0f,0.0f,0.0f);
glColor3f(1.0f,1.0f,0.0f); glVertex3f(100.0f,0.0f,0.0f);
glColor3f(1.0f,0.0f,1.0f); glVertex3f(100.0f,100.0f,0.0f);
glColor3f(1.0f,1.0f,1.0f); glVertex3f(0.0f,100.0f,0.0f);
glEnd();
surface->Display();
}

surface->SetActive(false);

}

void Engine::start(void)
{

running = true;
surface = new sf::Window(sf::VideoMode(640,480,32),"OpenGL Demo");
surface->SetActive(false);

sf::Thread thread(&Engine::render,this);
thread.Launch();

while (running == true) {
sf::Event event;
while (surface->GetEvent(event)) handleEvent(&event);
}

thread.Wait();

}


Any help would be very much appreciated.  Thanks!

Pages: [1]