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
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
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
00060
00061 void GLC_ImagePlane::render()
00062 {
00063 m_Material.glExecute();
00064
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);
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 }