Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Shawn54c

OpenGL OpenGL multiple instance issues

This topic is 5658 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, my problem is rather complicated so ill do my best to describe the issue im having. We have a windows application that contains multiple "pages" ( mainframe windows ) with childframes inside of them, the child frames are then divided into splitterwnd''s. this allows us to put activex controls inside each page ( any number of them ). so here is the problem. i have a 3d plotter that uses opengl . it is it''s own activex control so you can plop several of them on the screen at once. what happens is when we have multiple plotters instatiated in the program and we reevaluate the file to be plotted weird things with the textures start to happen. if i have 2 different measurements (flatness and fit) and say i have 3 plotters on the screen, 2 are displaying flatness and one is displaying fit, when i reevaluate the file the ones for flatness are displaying the texture for the fit plot, and vice versa for the fit plot. it could also happen that the texture doesnt get set at all and the plot is just a shape with a matte grey on it. Then if you go to an individual plot and configure it ( modify things like scale etc, but you dont even have to change anything ) when it redraws it on configure the plot then shows the correct texture. the refreshing for the reevaluate and the configure call the same block of code to create all the necessary stuff. what im doing is generating the data set for the points from a map that is provided, the dataset''s are ALWAYS correct. i then take an object that we have and generate the bitmap of the part which will be used as a texture ( we have tested this extensively by putting the bitmap out to a file etc) and the bitmap that is generated is the correct bitmap for that plot. the bitmap is then padded to be an even power of 2 (just for logistics) and then i generate a texture based on that bitmap. it all seems straightforward to me as to the instantiations of it, also i am deleting EVERYTHING and using new on everything before i redraw (slow but it needs to be done). but what seems to be happening is the plots are getting confused with the textures, it is as if they are swapping their memory. im storing each texture in a GLuint texture[1] by calling the following: if( texturesGenerated ) { glDeleteTextures( 1, texture ); } texturesGenerated = FALSE; glGenTextures(1, texture); // Create The Texture // Typical Texture Generation Using Data From The Bitmap glBindTexture(GL_TEXTURE_2D, texture[0]); // Generate The Texture glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, m_Pow2SizedBitmap->bmWidth, m_Pow2SizedBitmap->bmHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, m_Pow2SizedBitmap->bmBits); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Linear Filtering glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Linear Filtering texturesGenerated = TRUE; glBindTexture( GL_TEXTURE_2D, 0 ); im asking if anyone has any idea of why this is happening.. are the multiple instances of opengl only able to support one texture list and therefore it is getting confused? im totally stumped here and so is my boss. we have tracked this down to the texture issue since i used to color the map using a mathematical formula and set each data point to the color based on height (the bitmap generated is done the same way). but i went back to an earlier version before the textures and it always displays the correct information. help would be greatly appreciated -shawn

Share this post


Link to post
Share on other sites
Advertisement
anyone have any ideas?

ill see if i can add to it to make the problem more understandable.

i tried yesterday to make some things static ( have a static counter for texture number for each 3dplotter to get a different number.. ie 0,1,2,3 ). then i made the texture list static too and made it a set size .. say 4 in this example. and i created a static bool to mark whether or not the texture names got generated so they only got generated once.
then in each separate plotter i set the data for each texture to be the data for that plotter, indexing into the texture array by the first textuer counter variable.

that didnt work either so now im even more stuck.

Share this post


Link to post
Share on other sites
Yes, I have some ideas.

Firstly, are you using a different Render Context per active-x control? Secondly, are you using threading at all? Thirdly, depending on the latter two answers, are you using an in-process active-x control and hence are you accidentally sharing state between controls? (do you use a global singleton in the control).

Share this post


Link to post
Share on other sites
okay to answer your quesitons i need some info.
how do i know/check if im using a different render context for each active-x control?

here is how im obtaining my rendering context
first int my initopengl function in my view class:
hDC = GetDC()->GetSafeHdc();
that gets my device context obviously.
then i do
hRC = wglCreateContext(hDC); to get the rendering context from that device context.
then i do
iReturnCode = wglMakeCurrent(hDC, hRC);
so that im assuming would create different device/rendering contexts for each active-x control since hDC and hRC are both member variables in the COpenGLView class that i use.

i will try to figure out the answers to your other questions as soon as i can.
as far as i know the active-x controls are all contained under one thread.

Share this post


Link to post
Share on other sites

Hopefully, you are executing wglmakecurrent just before rendering into each context? Also, you should not have any global variables at all in your project (this includes things like HDc)...

Share this post


Link to post
Share on other sites
in my render function in the view class i do call
wglmakecurrent( hdc, hrc );
at the start of the function

all member variables are private data memebers to the classes

Share this post


Link to post
Share on other sites
one more thing im not sure if i mentioned this, but if you refreshdata (redraw basically) the correct information will be displayed ( sometimes takes more than one refresh)

Share this post


Link to post
Share on other sites
Are you making sure that when you create textures the correct rendering context is active, and also make sure that you are not using Id's from one context to render in others. You can share textures between context's I think it's a wgl function you need if you want to do this, but I can't remember which.

Edit: perhaps also make a call to glflush/glfinish before starting rendering in the new context?

James

[edited by - jamessharpe on June 18, 2003 11:05:21 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!