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 "../glc_context.h"
00029 #include <QtDebug>
00030 
00032 // Constructor Destructor
00034 
00035 GLC_ImagePlane::GLC_ImagePlane(const QString& ImageName)
00036 : m_Representation(GLC_Factory::instance()->createRectangle(2.0, 2.0))
00037 {
00038         GLC_Texture* pImgTexture= GLC_Factory::instance()->createTexture(ImageName);
00039         pImgTexture->setMaxTextureSize(pImgTexture->imageOfTexture().size());
00040         m_Representation.geomAt(0)->addMaterial(new GLC_Material(pImgTexture));
00041 }
00042 
00043 GLC_ImagePlane::GLC_ImagePlane(const QImage& image)
00044 : m_Representation(GLC_Factory::instance()->createRectangle(2.0, 2.0))
00045 {
00046         GLC_Texture* pImgTexture= GLC_Factory::instance()->createTexture(image);
00047         pImgTexture->setMaxTextureSize(image.size());
00048         m_Representation.geomAt(0)->addMaterial(new GLC_Material(pImgTexture));
00049 }
00050 
00051 GLC_ImagePlane::~GLC_ImagePlane()
00052 {
00053 
00054 }
00055 
00057 // OpenGL Functions
00059 
00060 void GLC_ImagePlane::render()
00061 {
00062         GLC_Context::current()->glcMatrixMode(GL_PROJECTION);
00063         GLC_Context::current()->glcPushMatrix();
00064         GLC_Context::current()->glcLoadIdentity();
00065         GLC_Context::current()->glcOrtho(-1,1,-1,1,-1,1);
00066         GLC_Context::current()->glcMatrixMode(GL_MODELVIEW);
00067 
00068         glDisable(GL_BLEND);
00069         glDisable(GL_DEPTH_TEST);
00070         glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
00071 
00072         m_Representation.render();
00073 
00074         glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
00075         glEnable(GL_DEPTH_TEST);
00076 
00077         GLC_Context::current()->glcMatrixMode(GL_PROJECTION);
00078         GLC_Context::current()->glcPopMatrix();
00079         GLC_Context::current()->glcMatrixMode(GL_MODELVIEW);
00080 }

SourceForge.net Logo

©2005-2011 Laurent Ribon