0

I would like some entry level information about the OpenGI library which converts a 3D mesh to a 2D texture map.

http://opengi.sourceforge.net/doc/index.html

At this point i have implemented an example on a specific mesh and it seems to work perfectly. I would like to process this image further and i need to export it as a bmp file.

I have imported a mesh and created:

  1. texture with the parameterized geometry
  2. texture with the normals

At this point i am confused how to handle them. They are stored as OpenGL textures.

Here's the source code:

glBindTexture(GL_TEXTURE_2D, uiTex[0]); 
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);  
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, res, res, 0, GL_RGBA, GL_FLOAT, NULL);
giGenImages(3, gim); 
giBindImage(gim[0]); 
giImageGLTextureData(res, res, 4, GL_FLOAT, uiTex[0]);
giAttribImage(0, gim[0]); 
giAttribSamplerParameteri(0, GI_SAMPLING_MODE, GI_SAMPLE_DEFAULT); 
giSample();

How can I export the texture?

jozxyqk
  • 16,424
  • 12
  • 91
  • 180
ionas_
  • 1
  • 1
  • So you have an image but need to know how to export it to a bmp? Could you explain what you've tried so far? – jozxyqk Mar 04 '15 at 14:06
  • i have imported a mesh and created: 1.texture with the parameterized geometry 2. texture with the normals at this point i am confused of how to handle them. They are stored as OpenGL textures. – ionas_ Mar 04 '15 at 14:33
  • Better to edit your post to add code and clarify your question rather than as comments. – jozxyqk Mar 04 '15 at 14:47
  • So you're just after a way to [get and save an opengl texture as an image](http://stackoverflow.com/questions/371665/opengl-into-png)? – jozxyqk Mar 04 '15 at 14:48
  • As i see there are two ways either rendering the scene and using FBOs. Thanks a lot. – ionas_ Mar 04 '15 at 14:55
  • I have no experience with OpenGI, but if it copies the image data out of OpenGL, you'll either have to copy it back and use `glGetTexImage` or find some OpenGI interface to get it directly. Actually it [looks like](http://opengi.sourceforge.net/doc/group__image.html) no copy takes place so just grab it from GL. From there I highly recommend using an image library such as [libpng, SOIL, FreeImage](https://www.opengl.org/wiki/Image_Libraries) as BMP is just awful. – jozxyqk Mar 04 '15 at 15:04
  • bmp is not obligatory! i have implemented pgm (a file format that is readable from matlab). Anyway i hadn't any idea with openGL and openGI and now you showed the way. :-) – ionas_ Mar 04 '15 at 18:45

0 Answers0