Added demonstration of texture co-ordinate generation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
diff --git a/demo/FTGLDemo.cpp b/demo/FTGLDemo.cpp
index e17bc24..908366f 100644
--- a/demo/FTGLDemo.cpp
+++ b/demo/FTGLDemo.cpp
@@ -53,6 +53,13 @@ wchar_t myString[16];
static FTFont* fonts[6];
static FTGLPixmapFont* infoFont;
+static float texture[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
+
+static GLuint textureID;
+
void SetCamera(void);
void setUpLighting()
@@ -90,12 +97,10 @@ void setUpLighting()
glColor4fv(front_diffuse);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
- glEnable(GL_CULL_FACE);
glColorMaterial(GL_FRONT, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_LIGHTING);
- glShadeModel(GL_SMOOTH);
}
@@ -251,10 +256,11 @@ void renderFontInfo()
break;
}
- glRasterPos2f( 20.0f , 20.0f + infoFont->Ascender() - infoFont->Descender());
+ glRasterPos2f( 20.0f , 20.0f + infoFont->LineHeight());
infoFont->Render(fontfile);
}
+
void do_display (void)
{
switch( current_font)
@@ -264,12 +270,16 @@ void do_display (void)
case FTGL_OUTLINE:
break;
case FTGL_POLYGON:
+ glEnable( GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, textureID);
glDisable( GL_BLEND);
setUpLighting();
break;
case FTGL_EXTRUDE:
glEnable( GL_DEPTH_TEST);
glDisable( GL_BLEND);
+ glEnable( GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, textureID);
setUpLighting();
break;
case FTGL_TEXTURE:
@@ -339,7 +349,9 @@ void myinit( const char* fontfile)
glFrontFace( GL_CCW);
glEnable( GL_DEPTH_TEST);
-
+ glEnable(GL_CULL_FACE);
+ glShadeModel(GL_SMOOTH);
+
glEnable( GL_POLYGON_OFFSET_LINE);
glPolygonOffset( 1.0, 1.0); // ????
@@ -349,6 +361,16 @@ void myinit( const char* fontfile)
tbAnimate( GL_FALSE);
setUpFonts( fontfile);
+
+ glGenTextures(1, &textureID);
+ glBindTexture(GL_TEXTURE_2D, textureID);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, GL_FLOAT, texture);
+
+
}