Click here to Skip to main content
15,891,908 members
Articles / Desktop Programming / MFC

PicZoom: A Photo Viewer Created in OpenGL

Rate me:
Please Sign up or sign in to vote.
4.86/5 (63 votes)
16 Feb 2011CPOL16 min read 160.8K   11.6K   150  
PicZoom: A Photo Viewer created in OpenGL
#pragma once

/*
// There is a change in opengl coordinate representation, and the windows coordinate 
// representation. This change is applied only to achieve zoom functionality. When applying
// zoom( glScale), the scale should be equally applied to all coordinates.
// The expected output can only be achieved by making 0,0 as center point.
// We need to convert the window coordinate to opengl based on window region.

(0,0)--------------------------(Width,0)|
|                                       |
|                                       |
|           Normal Coordinate           |
|                                       |
|                                       |
(0,Height)------------------(Width,Heght)


// Opengl coordiante used in this project.
(-Wid/2,Hei/2)---------------(Wid/2,Hei/2)
|                   |                    |
|                   |                    |
|                   |                    |
|-----------------(0,0)------------------|
|                   |                    |
|                   |                    |
|                   |                    |
(-Wid/2,-Hei/2)--------------(Wid/2,-Hei/2)

This class holds current window region, and it convert the 
window coordinate to opengl coordinate. This can be used for vertex buffer
creation with window coordinates.
*/
class CoordConverter
{
public: 

    static CoordConverter& GetInstance()
    {
        return m_MyStatiInstance;
    }

    void SetWindowRegion( const int nWidth_i, const int nHeight_i );
    void WindowToGL( POINT& ptPoint_io );

private:

    CoordConverter(void);
    ~CoordConverter(void);

private:

    int m_nXOffset;
    int m_nYOffset;
    static CoordConverter m_MyStatiInstance;
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions