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

SourceForge.net Logo

©2005-2011 Laurent Ribon