Sign in to follow this  
chibitotoro0_0

OpenGL Textures in Multitheaded Environment

Recommended Posts

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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this