Click here to Skip to main content
Click here to Skip to main content
Articles » Multimedia » OpenGL » General » Downloads
 
Add your own
alternative version
Go to top

Zoom An Image With Different Interpolation Types

, 21 Sep 2011
Implementation of different interpolations[Bi-Linear and Bi-Cubic] with OpenGL.
ZoomInterpolationApplication.zip
ZoomInterpolation.exe
ZoomInterpolation_Application.zip
ZoomInterpolation.exe
ZoomInterpolation_Code.zip
ZoomInterpolation
pixel_shader_Bell.cg
pixel_shader_BiCubic.cg
pixel_shader_BiLinear.cg
pixel_shader_BSpline.cg
pixel_shader_CatMull.cg
res
Flower.bmp
ZoomInterpolation.ico
ZoomInterpolation.dsp
ZoomInterpolation.dsw
ZoomInterpolation_Source.zip
pixel_shader_Bell.cg
pixel_shader_BiCubic.cg
pixel_shader_BiLinear.cg
pixel_shader_BSpline.cg
pixel_shader_CatMull.cg
Flower.bmp
ZoomInterpolation.ico
ZoomInterpolation.dsp
ZoomInterpolation.dsw
#include "StdAfx.h"
#include "GLSetup.h"

GLSetup::GLSetup(void)
{
	m_hRenderContext = 0;
	m_hDeviceContext = 0;
	m_hRenderWindow = 0;
}

GLSetup::~GLSetup(void)
{
	Exit();
}

// Function for creating a rendering context and make it as current rendering context.
bool GLSetup::InitGL( HWND pRenderWindow_i )
{
	m_hRenderWindow = pRenderWindow_i;
	GLuint PixelFormat;

	PIXELFORMATDESCRIPTOR pfd;
	memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));

	pfd.nSize      = sizeof(PIXELFORMATDESCRIPTOR);
	pfd.nVersion   = 1;
	pfd.dwFlags    = PFD_DRAW_TO_WINDOW |PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
	pfd.iPixelType = PFD_TYPE_RGBA;
	pfd.cColorBits = 16;
	pfd.cDepthBits = 16;

	m_hDeviceContext = ::GetDC( m_hRenderWindow );
	PixelFormat = ChoosePixelFormat( m_hDeviceContext, &pfd );
	SetPixelFormat( m_hDeviceContext, PixelFormat, &pfd);
	m_hRenderContext = wglCreateContext( m_hDeviceContext );
	wglMakeCurrent( m_hDeviceContext, m_hRenderContext );

    RECT Region;
    ::GetClientRect( m_hRenderWindow, &Region );

    //glMatrixMode(GL_PROJECTION);
    //glLoadIdentity();
//    int nWidth = (float)Region.right / 2;
//    int nHeight = (float)Region.bottom/ 2;
//    glOrtho( -nWidth, nWidth, -nHeight, nHeight, 0.0, 5.0 );

    //glMatrixMode( GL_MODELVIEW );
    //glLoadIdentity();
 
	// Check opengl error before exiting.
	return( GL_NO_ERROR == glGetError());
}

bool GLSetup::CheckExtension( const CHAR* pExtensionToCheck_i )
{
    const CHAR* pExtension = (const CHAR*)glGetString( GL_EXTENSIONS );
    if( 0 == pExtension )
    {
        return false;
    }
    if( 0 < strstr( pExtension, pExtensionToCheck_i ))
    {
        return true;
    }
    return false;
}
    

void GLSetup::Exit()
{
	if( m_hRenderContext != NULL )
	{
		wglMakeCurrent( NULL, NULL );
		wglDeleteContext( m_hRenderContext );
		m_hRenderContext = NULL;
	}

	if( m_hDeviceContext != NULL )
	{
		ReleaseDC( m_hRenderWindow, m_hDeviceContext );
		m_hDeviceContext = NULL;
	}
}

void GLSetup::Draw()
{
	SwapBuffers( m_hDeviceContext );
}

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)

Share

About the Author

Santhosh G_

India India
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140921.1 | Last Updated 21 Sep 2011
Article Copyright 2011 by Santhosh G_
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid