Share textures between sharpgl .net forms controls

Jun 21, 2014 at 10:08 AM

I'm working on a kind of an editor using .net windows forms + sharpgl. I'm loving sharpgl so far, but I want to be able to reuse current loaded textures between different sharpgl controls, is there a way to do that? or do I have to load twice the same textures??

Thanks in advance!
Jun 22, 2014 at 5:37 PM

I'm afraid that due to the fact that each control has it's own Render Context, you'll have to recreate the textures in each case. As far as OpenGL is concerned, they're totally isolated environments - sorry about that! It's an OpenGL thing rather than a SharpGL thing, with a lot of work there might be some way to hack around it, but it's probably going to be more straightforward to recreate the materials.

If you have a more complex case, such as having genuinely one scene and geometry etc with multiple viewports on it, there is some work going on for SharpGL 3 that might help, but it's a way from being ready.

Good luck!
Jun 23, 2014 at 5:02 AM
As an aside, you could just load the textures into Bitmap/Image objects in the program when it loads and then load into each glControl individually from the texture objects. Each one would have its own set of IDs, but you could share the code across each...during render, glControl1 might have a TextureID of 12 and glControl2 might have a TextureID of 3 depending on what else is loaded...
Jun 24, 2014 at 10:03 AM
First of all thanks for your support!

@dwmkerr ok no problem, I'm doing some changes on the interface to avoid recreating textures and such.

@fvapres Yeah I thought something like that, but I'm using like 8 glcontrols and I think that would be very cumbersome... for now I've been splitting the project into two different solutions, and I've been able to use only one gl control on the side of my editor instead of having one in each of the tabs. But I would really like to have at least another gl control acting like a "preview". Anyway I guess that having only 2 gl controls is gonna fine regarding performance, so I'll keep my work in this direction.