main program in a thread & opengl in another
I just want to do a simple thing:
Make a program that have two threads, the first will be the ''main'' program, where i will enter with the coordinates of some vertexes, for example; and in the other thread, will appear the opengl window with the vertexes that i have inputed.
This is a simple example, but what i want to do is more ''bigger'' than this... And i want to run in different threads because i need to show the ''3d object'' that we are making with the data inputed by the user, rotating in real time (the user enter with the first vertex, i draw it, and the second, i draw with a line linking the first to this one)...
I tried to do this with C but i have no success... My knowledge in pthread isn''t enought...
And i dont want to use microsoft threads...
Somebody can help me??
Well, I would do the graphic work on the main thread, but you don''t need several threads for what you describe, you just have to use non blocking input, that is, you don''t wait for a key to be pressed, you have a loop where you draw and check if a key has been pressed (if no key has been pressed go on, that''s the point in non blocking), you don''t need a separate thread to process input, or you think every single game is multithreaded? 
And if you are using threads, you better use your enviroment''s threads
you shouldn''t have a problem finding a basic tutorial.

And if you are using threads, you better use your enviroment''s threads

Take a look in the archives, I know several of us have touched on threaded programming before. I would definitely say if you''re going to attack the problem this way, you''re going to want to use a Model-View-Controler type architecture (or you''ll go crazy).
I agree with Angasule that this might be over-complicating it, but then again it may not depending on what your "big-picture" plan for the app is.
If you''re hoping to have a view of the model, and the user able to manipulate the data in real-time, then you might want to think about creating a "model" source that your view uses to render, and your data-entry (controller) thread adds data to (you''ll have to use some sort of locking to make sure that your data is valid when the render thread it looking at it).
Most windowing environments spawn each window in a new thread, allowing your application to create a window for data entry, a window for rendering, and a data-source. Only Modal dialogs block the execution of the caller.
Don''t know if this helps. Good luck.
- sighuh?
I agree with Angasule that this might be over-complicating it, but then again it may not depending on what your "big-picture" plan for the app is.
If you''re hoping to have a view of the model, and the user able to manipulate the data in real-time, then you might want to think about creating a "model" source that your view uses to render, and your data-entry (controller) thread adds data to (you''ll have to use some sort of locking to make sure that your data is valid when the render thread it looking at it).
Most windowing environments spawn each window in a new thread, allowing your application to create a window for data entry, a window for rendering, and a data-source. Only Modal dialogs block the execution of the caller.
Don''t know if this helps. Good luck.
- sighuh?
- sighuh?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement