opengl rendering in worker thread
No replies to this topic
Members - Reputation: 122
Posted 20 June 2001 - 08:17 AM
I make a component by creating an ATL Object in VC,my component supplys a window in which a terrain is rendered using opengl,the component supports mouse and keyboard input to let you walkthrough the terrain.I render the terrain in "OnTimer" event handler and get a poor FPS,so i decided to create a worker thread and put the opengl rendering code in it then the problem came out. Since i put the textures loading code in the component''s main thread not in the worker thread so when i render the terrain in the worker thread i can''t see the texture effect.That is,you can''t use the textures created in another thread though you can get the texture handle.I was confused that the threads in a process can share the process''s data,but they can''t share opengl state and data,why? I know that if i put the texture loading code in my worker thread then everything will be ok,but the component structure just prevent me from doing it.For details,you can drag the component in your VB form at design time,then at runtime when the form is loading,you tell the component to load textures and terrain data through the Interface the component support.the interface implementing code resides in the main thread and cann''t be put into the worker thread,what can i do? So anyone could give an advice i''ll be very appreciate of it,thx!