View Full Version : rotate Image on openGL

03-24-2014, 01:10 AM

I am loading a model on opengl.
when I save the model to a tiff file, I can see it as a mirror pic of the X axis .

How can I change it so I can see it as it loads on OpenGL?


Agent D
03-24-2014, 01:27 AM
I'm not sure what exactly you are trying to do, but please be aware that in OpenGL(R), the origin is at the bottom left with the Y axis going up, while most image file formats have the origin at the top left with the Y axis going down, so a simple frame buffer image dump will look upside down. Is this what you meant by mirrored around the X axis?

03-24-2014, 01:36 AM
yes , so I see my model execly as it is but reversed.
How can I fixed it ?

03-24-2014, 01:43 AM
so I can see my model in the irfan View as I see it in the openGL?
when I open irfan View my model is seen like a mirror toward down...

Agent D
03-24-2014, 01:48 AM
If you are using some library for exporting the framebuffer image, tell the library to store the image in reverse order.

If that is for some reason not possible, you will have to iterate over half of the image scanlines and swap scanline y with scanline height-y-1

03-24-2014, 02:01 AM
I am using this func by Assimp::Importer Importer
How can I change the scaling?

bool Mesh::LoadMesh(const std::string& Filename)

bool Ret = false;
Assimp::Importer Importer;

const aiScene* pScene = Importer.ReadFile(Filename.c_str(), aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs);

if (pScene) {
Ret = InitFromScene(pScene, Filename);
else {
printf("Error parsing '%s': '%s'\n", Filename.c_str(), Importer.GetErrorString());

return Ret;

03-24-2014, 03:00 AM
maybe I should use this commands: glTranslatef, glRotatef?

Agent D
03-24-2014, 08:32 AM
WRONG end of the rendering pipeline.

What I suggested is flipping the exported image, not the entire scene.

Btw: The only input transformation that would do the job would be glScalef( 1.0, -1.0, 1.0 )

03-25-2014, 02:07 AM
I tried this and nothing change.I still see the model rotated to the X axis...

Agent D
03-25-2014, 10:13 AM
What did you try?

Somewhere in your code, there must be a function like this:

void export_image( ... )
glReadPixels( .... );
write_to_tiff_file_somehow( .... );

What you have to do here is to flip the image upside down before exporting:

for( y=0; y<height/2; ++y )
swap_scanlines( image, y, y-height-1 );