glc_imageplane.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  Version 2.0.0, packaged on July 2010.
00006 
00007  http://glc-lib.sourceforge.net
00008 
00009  GLC-lib is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU Lesser General Public License as published by
00011  the Free Software Foundation; either version 3 of the License, or
00012  (at your option) any later version.
00013 
00014  GLC-lib is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU Lesser General Public License for more details.
00018 
00019  You should have received a copy of the GNU Lesser General Public License
00020  along with GLC-lib; if not, write to the Free Software
00021  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 *****************************************************************************/
00024 
00026 #include "glc_imageplane.h"
00027 #include "glc_viewport.h"
00028 #include "../glc_openglexception.h"
00029 #include "../glc_factory.h"
00030 #include <QtDebug>
00031 
00033 // Constructor Destructor
00035 
00036 GLC_ImagePlane::GLC_ImagePlane(const QGLContext *pContext, const QString& ImageName)
00037 : m_Material()
00038 {
00039         GLC_Texture* pImgTexture= GLC_Factory::instance(pContext)->createTexture(ImageName);
00040         pImgTexture->setMaxTextureSize(pImgTexture->imageOfTexture().size());
00041         m_Material.setTexture(pImgTexture);
00042 }
00043 
00044 GLC_ImagePlane::GLC_ImagePlane(const QGLContext *pContext, const QImage& image)
00045 : m_Material()
00046 {
00047         GLC_Texture* pImgTexture= GLC_Factory::instance(pContext)->createTexture(image);
00048         pImgTexture->setMaxTextureSize(image.size());
00049         m_Material.setTexture(pImgTexture);
00050 }
00051 
00052 GLC_ImagePlane::~GLC_ImagePlane()
00053 {
00054 
00055 }
00056 
00058 // OpenGL Functions
00060 
00061 void GLC_ImagePlane::render()
00062 {
00063         m_Material.glExecute();
00064         // Display info area
00065         glMatrixMode(GL_PROJECTION);
00066         glPushMatrix();
00067         glLoadIdentity();
00068         glOrtho(-1,1,-1,1,-1,1);
00069         glMatrixMode(GL_MODELVIEW);
00070         glPushMatrix();
00071         glLoadIdentity();
00072 
00073         glDisable(GL_BLEND);
00074         glDisable(GL_DEPTH_TEST);
00075         glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
00076         glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
00077         glBegin(GL_QUADS);
00078 
00079                 glNormal3d(0.0, 0.0, 1.0);      // Z
00080                 glTexCoord2f(0.0f, 0.0f); glVertex3d(-1.0, -1.0, 0.0);
00081                 glTexCoord2f(1.0f, 0.0f); glVertex3d(1.0, -1.0, 0.0);
00082                 glTexCoord2f(1.0f, 1.0f); glVertex3d(1.0, 1.0, 0.0);
00083                 glTexCoord2f(0.0f, 1.0f); glVertex3d(-1.0, 1.0, 0.0);
00084 
00085         glEnd();
00086         glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
00087         glEnable(GL_DEPTH_TEST);
00088 
00089         glPopMatrix();
00090         glMatrixMode(GL_PROJECTION);
00091         glPopMatrix();
00092         glMatrixMode(GL_MODELVIEW);
00093 }

SourceForge.net Logo

©2005-2010 Laurent Ribon