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

Pages: [1]
1
Graphics / Re: Setting up Rendering In a Separate Thread.
« on: May 20, 2012, 07:17:47 pm »
This is what I tried putting into a thread;

void Render(void * data)
{
        sf::RenderWindow &window = *(static_cast<sf::RenderWindow*>(data));
       
        while(window.isDone())
        {
                // Render 3D
                glLoadIdentity();
                glTranslatef( 0, 0, -5 );

                glBegin(GL_QUADS);
                          glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, 1.0f );
                          glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, 1.0f );
                          glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f,  1.0f, 1.0f );
                          glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f,  1.0f, 1.0f );

                          glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f, -1.0f );
                          glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f,  1.0f, -1.0f );
                          glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f,  1.0f, -1.0f );
                          glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f, -1.0f, -1.0f );

                          glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f,  1.0f, -1.0f );
                          glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f,  1.0f,  1.0f );
                          glTexCoord2f( 0.0f, 0.0f ); glVertex3f(  1.0f,  1.0f,  1.0f );
                          glTexCoord2f( 0.0f, 1.0f ); glVertex3f(  1.0f,  1.0f, -1.0f );

                          glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f, -1.0f, -1.0f );
                          glTexCoord2f( 1.0f, 1.0f ); glVertex3f(  1.0f, -1.0f, -1.0f );
                          glTexCoord2f( 1.0f, 0.0f ); glVertex3f(  1.0f, -1.0f,  1.0f );
                          glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f,  1.0f );

                          glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 1.0f, -1.0f, -1.0f );
                          glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 1.0f,  1.0f, -1.0f );
                          glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 1.0f,  1.0f,  1.0f );
                          glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 1.0f, -1.0f,  1.0f );

                          glTexCoord2f( 1.0f, 0.0f ); glVertex3f( -1.0f, -1.0f, -1.0f );
                          glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1.0f, -1.0f,  1.0f );
                          glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1.0f,  1.0f,  1.0f );
                          glTexCoord2f( 1.0f, 1.0f ); glVertex3f( -1.0f,  1.0f, -1.0f );
                        glEnd( );

                glLoadIdentity();


               
                window.display();
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                glMatrixMode(GL_MODELVIEW);
                glLoadIdentity();
        }
}

And the program crashed with the output:

[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
rthread: ../../src/xcb_io.c:273: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Aborted

2
Graphics / Re: Setting up Rendering In a Separate Thread.
« on: May 19, 2012, 09:40:01 pm »
Well I've been reworking my event loop. And I've managed to reduce the amount of necessary event checks to a much smaller amount. And now the mouse move lag is undetectable. Though I'm still open to methods of setting up the rendering code in a separate thread. Currently the program crashes whenever I attempt it.


3
Graphics / Re: Setting up Rendering In a Separate Thread.
« on: May 19, 2012, 08:38:50 pm »
example:
Code: [Select]
if((event.type == sf::Event::MouseButtonPressed) && (event.mouseButton.button == sf::Mouse::Left))
myclass.doThis = true;

I should also mention, I'm using SFML 2.0 RC.
And I didn't experience this in SFML 1.6.

But besides this, I'd still like to know how to set up a separate Render Thread.

4
Graphics / Re: Setting up Rendering In a Separate Thread.
« on: May 19, 2012, 08:20:59 pm »
sf::Event::MouseMoved occurs  about 4-6 times a frame, If thats what you meant. Its a small lag. Hardly
noticeable, yet still noticeable. From what I've seen, the more events I check for in the event loop, whatever they may be, the more sf::Event::MouseMoved events I get. Is it something I'm doing wrong?

5
Graphics / Setting up Rendering In a Separate Thread.
« on: May 19, 2012, 07:54:53 pm »
Hello. I'm experiencing some lag during my program's event loop when I move the mouse. So I was hoping to someone could direct me to a method for separating the event loop from the rendering code with a separate thread.

Pages: [1]