GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_imageplane.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21 *****************************************************************************/
22 
24 #include "glc_imageplane.h"
25 #include "glc_viewport.h"
26 #include "../glc_openglexception.h"
27 #include "../glc_factory.h"
28 #include "../glc_context.h"
29 #include <QtDebug>
30 
32 // Constructor Destructor
34 
35 GLC_ImagePlane::GLC_ImagePlane(const QString& ImageName)
36 : m_Representation(GLC_Factory::instance()->createRectangle(2.0, 2.0))
37 {
38  GLC_Texture* pImgTexture= GLC_Factory::instance()->createTexture(ImageName);
39  pImgTexture->setMaxTextureSize(pImgTexture->imageOfTexture().size());
40  m_Representation.geomAt(0)->addMaterial(new GLC_Material(pImgTexture));
41 }
42 
43 GLC_ImagePlane::GLC_ImagePlane(const QImage& image)
44 : m_Representation(GLC_Factory::instance()->createRectangle(2.0, 2.0))
45 {
46  GLC_Texture* pImgTexture= GLC_Factory::instance()->createTexture(image);
47  pImgTexture->setMaxTextureSize(image.size());
48  m_Representation.geomAt(0)->addMaterial(new GLC_Material(pImgTexture));
49 }
50 
52 {
53 
54 }
55 
57 // OpenGL Functions
59 
61 {
62  GLC_Context::current()->glcMatrixMode(GL_PROJECTION);
65  GLC_Context::current()->glcOrtho(-1,1,-1,1,-1,1);
66  GLC_Context::current()->glcMatrixMode(GL_MODELVIEW);
67 
68  glDisable(GL_BLEND);
69  glDisable(GL_DEPTH_TEST);
70  glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
71 
73 
74  glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
75  glEnable(GL_DEPTH_TEST);
76 
77  GLC_Context::current()->glcMatrixMode(GL_PROJECTION);
79  GLC_Context::current()->glcMatrixMode(GL_MODELVIEW);
80 }

©2005-2013 Laurent Ribon