Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 10 of 10

Thread: rotate Image on openGL

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2014
    Posts
    26

    rotate Image on openGL

    Hi,

    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?

    Thanks

  2. #2
    Junior Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    151
    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?
    Last edited by Agent D; 03-24-2014 at 01:36 AM.

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2014
    Posts
    26
    yes , so I see my model execly as it is but reversed.
    How can I fixed it ?

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2014
    Posts
    26
    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...

  5. #5
    Junior Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    151
    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

  6. #6
    Junior Member Newbie
    Join Date
    Mar 2014
    Posts
    26
    I am using this func by Assimp::Importer Importer
    How can I change the scaling?


    bool Mesh::LoadMesh(const std::string& Filename)
    {
    Clear();

    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;
    }

  7. #7
    Junior Member Newbie
    Join Date
    Mar 2014
    Posts
    26
    maybe I should use this commands: glTranslatef, glRotatef?

  8. #8
    Junior Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    151
    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 )

  9. #9
    Junior Member Newbie
    Join Date
    Mar 2014
    Posts
    26
    I tried this and nothing change.I still see the model rotated to the X axis...

  10. #10
    Junior Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Location
    Innsbruck, Austria
    Posts
    151
    What did you try?

    Somewhere in your code, there must be a function like this:
    Code :
    void export_image( ... )
    {
        ......
        glReadPixels( .... );
        .....
        write_to_tiff_file_somehow( .... );
    }

    What you have to do here is to flip the image upside down before exporting:
    Code :
        .....
        for( y=0; y<height/2; ++y )
        {
            swap_scanlines( image, y, y-height-1 );
        }
        .....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •