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.
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.
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.
#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_
#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)) {}
}
}
#include "framework/engine.hh"
int main(int argc, char** argv)
{
Engine engine; engine.start();
return 0xdead;
}
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]
#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_
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();
}