Jump to content
  • Advertisement
Sign in to follow this  
chibitotoro0_0

OpenGL Textures in Multitheaded Environment

This topic is 4064 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!