473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

pthread and opengl

Hey, i am trying to develop a game, and I am using OpenGL and pthread.
(on Ubuntu, so i also use the X library.) Now i have a problem. I have
initialized OpenGL in the main thread, and i want to repaint 30 times
every second (the usual framerate). Now i programmed a timer, which was
able to wait for 30/1000 seconds. That happens in another thread, and
after the delay (nanosleep, from the time.h header), it calls the paint()
function. And it returned a error message. I found out that it was
because OpenGL can't be painted from a different thread than the
initialising thread. Can anyone help me what to do to fix this? I can't
let the initialising thread delay and repaint, because it has to wait for
X inputs.

(main_thread)
|
\ /

(initialize OpenGL)
|
\ /

(start painting timer)
| \
\ / \
(wait for X events, XNextEvent()) |
\ /
(wait 30/1000 second, and then
call the repaint function)
Can anyone help me please?

grz, Leon
Feb 10 '08 #1
3 3121
On Feb 10, 10:37 am, Leon
<ask.me.if.you.want.my.email.addr...@this.listwrot e:
Hey, i am trying to develop a game, and I am using OpenGL and pthread.
You're better off asking in comp.graphics.api.opengl - this group only
deals with standard C++.

Keep in mind, though, that OpenGL is a big state machine and it's not
thread safe, so you have to manage thread access to the OpenGL
context.
Feb 10 '08 #2
On Sun, 10 Feb 2008 07:46:12 -0800, dave_mikesell wrote:
On Feb 10, 10:37 am, Leon
<ask.me.if.you.want.my.email.addr...@this.listwrot e:
>Hey, i am trying to develop a game, and I am using OpenGL and pthread.

You're better off asking in comp.graphics.api.opengl - this group only
deals with standard C++.

Keep in mind, though, that OpenGL is a big state machine and it's not
thread safe, so you have to manage thread access to the OpenGL context.
Okay, thank you
Feb 10 '08 #3
Leon wrote:
Hey, i am trying to develop a game, and I am using OpenGL and pthread.
Both OpenGL and pthreads are off-topic here. A better newsgroup for your
question is comp.graphics.api.opengl.
I found out that it was because OpenGL can't be painted from a different
thread than the initialising thread. Can anyone help me what to do to fix
this?
Most OpenGL implementations aren't thread-safe. You must do all the OpenGL
calls in one thread.

Feb 10 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Rick Muller | last post by:
I have a problem that I would like to get some advice on from other Pythonistas. I currently manage a (soon to be) open source project for displaying molecular graphics for a variety of different...
15
by: oracle411 | last post by:
Hi I'm new to OpenGL, but have an OpenGL application written in CPP that I would like to display on a web browser. Was wondering how this could be done? Thank you very much
7
by: lokb | last post by:
Hi, I am creating a detach thread as shown below and caling pthread_create in a while loop where the file names in the directory are fetched and is passed as a parmater to pthread create. The...
3
by: john townsley | last post by:
Hi I want to do some OpenGl stuff with c++ on a winXP (home) machine. I have Borland c++ 5, MVS c++ 5 What C++ do you recommend (any others?)and where do you get the OpenGL stuff. thanks
10
by: Bad_Kid | last post by:
which is better for what?
10
by: noleander | last post by:
I've got an application that uses Pthread to do threading. Mostly Im using Condition Variables and the associated function calls: - pthread_cond_wait() - pthread_cond_signal() -...
4
by: tobfon | last post by:
I'm creating a scientific visualization application with rather high demands on performance. I've created a nice rendering engine for it in C++/OpenGL and a python interface to the rendering...
3
by: jg.campbell.ng | last post by:
I'm beginning learning Python and OpenGL in Python. Python fine. But difficulties with OpenGL; presumably with the installation of OpenGL. OS = Linux FC5. Python program gl_test.py: from...
9
by: Achim Domma | last post by:
Hi, I'm developing a GUI app in Python/C++ to visualize numerical results. Currently I'm using Python 2.4 with wx and PyOpenGLContext, but there are no windows binaries for Python 2.5 for quite...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.