Textures in Multitheaded Environment

Started by
-1 comments, last by chibitotoro0_0 16 years, 10 months ago
Hi everyone, I'm making my own game engine for an MMORPG game right now and I came by a problem that stumped me. In the first version of my engine it was strictly designed to work on one computer (one thread). In my current version I'm working on I implemented networking and enabled multithreading. So after my client logs into the server, the server gives the client its ID and the client starts at a thread for its character and generates a sprite with a texture for it. I'm doing this in OpenGL. Using VC++ 6.0. In my first version (offline mode), I create the texture in my main program using glGenTextures(1, &texture) which works fine and dandy. With one texture I get texture back as "1" In the current version the texture is created in a thread. As I figure the texture does not need to be loaded unless there is a character to draw after logging in. After a call of glGenTextures(1, &texture), texture returns a really large value. ie. "3452816845". NOTE: texture is of type UINT. Thus as a result in my current version, the textures do not load. But if I move the code which creates the character to one line above where the thread is created, the texture is loaded. I was wondering if this is a problem because glGenTextures allocates space using the process's memory locations. If I called it in a thread, it allocates memory from a different place and thus cannot be bounded using glBindTexture(GL_TEXTURE_2D, texture). Is there a way around this? or should I just load all the textures in the main process space to begin with and attach it dynamically when the thread is created? Sorry for the long post, and thanks for all the help!

This topic is closed to new replies.

Advertisement