Question

I'm trying to create an openGL ES objects at run time, meaning let the user select the texture for certain objects, and later use the created object again with the same texture chosen (The user can select where to place the texture, kind of masking the texture and using the masked part for the object's texture).

For this, saving the mesh (Vertices) will not do. Is there anyway to save the entire thing?

Im using openGL ES 2.0.

Was it helpful?

Solution

What you see onscreen is just the result of a bunch of inputs (VBOs, textures, other attribs and uniforms) that you passed to OpenGL from the Objective-C program you have running on the CPU. You must already have a shader set up that takes inputs based on the users' touches to allow the user to pick where to place the texture in the first place. So, whatever the values you passed to the shader last are what you want to save.

Just save the value of those attribs and uniforms that need to persist to the disk, along with the texture and vertices, and then use that data to reconstitute the object.

OTHER TIPS

OpenGL is just a drawing API. Sort of like brushes, pencils and a palette you use to draw on the canvas given to your program by the operating system.

What you ask for is like asking the brush to understand the picture of a face drawn on a canvas. OpenGL can't do it. Period.

What you actually should do is ask yourself: "What inputs did I combine in my program in which way, to actually draw that image? What's the minimal set of parameters required to recreate those steps?" And then you write those to a file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top