glc_imageplane.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
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
00058
00059 void GLC_ImagePlane::render()
00060 {
00061 m_Material.glExecute();
00062
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);
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 }