[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/libs/kgllib/examples/spinninglogos
From: Rivo Laks <rivolaks () hot ! ee>
Date: 2008-02-04 15:26:44
Message-ID: 1202138804.410266.32097.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 770870 by rivol:
Add some comments here as well
M +13 -4 logos.cpp
--- trunk/playground/libs/kgllib/examples/spinninglogos/logos.cpp #770869:770870
@@ -29,6 +29,8 @@
using namespace Eigen;
+// Vertex and texcoord arrays for a logo. We'll create a Mesh object using
+// those arrays
static Vector3f logoShapeVertices[] =
{ Vector3f(-1.0f, -1.0f, 0.0f), Vector3f( 1.0f, -1.0f, 0.0f),
Vector3f( 1.0f, 1.0f, 0.0f), Vector3f(-1.0f, 1.0f, 0.0f) };
@@ -63,13 +65,14 @@
if (!mKDELogoTex->isValid() || !mQtLogoTex->isValid()) {
return setErrorText("Data couldn't be loaded");
}
- // We only draw logos once, so set a GL_CLAMP wrap mode for them
+ // We don't want the textures to repeat (tile), so set a GL_CLAMP wrap mode
+ // for them.
mKDELogoTex->setWrapMode(GL_CLAMP);
mQtLogoTex->setWrapMode(GL_CLAMP);
- // This cuts away surfaces that doesn't face us. This way we can render
- // both logos at the same place without worrying about them intersecting
- // with each other
+ // This cuts away surfaces that doesn't face the camera (called backfacing
+ // surfaces). This way we can render both logos at the same place without
+ // worrying about them intersecting with each other
glEnable(GL_CULL_FACE);
// Enable blending so that transparent parts of the logo blend with the background
@@ -79,12 +82,15 @@
// Use yellow background
setClearColor(Vector4f(1.0, 1.0, 0.0, 0.0));
+ // Create the logo meshes
mKDELogoMesh = createLogo(mKDELogoTex);
mQtLogoMesh = createLogo(mQtLogoTex);
}
Mesh* Logos::createLogo(Texture* tex)
{
+ // Create new mesh, using the vertex and texcoord arrays defined at the
+ // beginning of the file.
Mesh* logo = new Mesh();
logo->setVertexCount(logoShapeVertexCount);
logo->setVertices(logoShapeVertices);
@@ -118,13 +124,16 @@
void Logos::renderLogo(KGLLib::Texture* tex)
{
+ // This both enables texturing as well as binds the texture.
tex->enable();
+ // Now render the logo
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1, -1, 0);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1, -1, 0);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1, 1, 0);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1, 1, 0);
glEnd();
+ // And finally disable texturing.
tex->disable();
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic