render textures in texture.c
authorDana Jansens <danakj@orodu.net>
Mon, 2 Jun 2003 01:48:03 +0000 (01:48 +0000)
committerDana Jansens <danakj@orodu.net>
Mon, 2 Jun 2003 01:48:03 +0000 (01:48 +0000)
render2/paint.c
render2/planar.c
render2/texture.c
render2/texture.h

index 7b00f59b808b728691ad3b1e5a0bf6a818aa830b..7b8730ea5e74222880fac0cb8b27d942282f653f 100644 (file)
@@ -43,7 +43,7 @@ void RrPaint(struct RrSurface *sur)
 {
     struct RrInstance *inst;
     struct RrSurface *p;
-    int ok;
+    int ok, i;
     int surx, sury;
     GSList *it;
 
@@ -96,5 +96,8 @@ void RrPaint(struct RrSurface *sur)
         break;
     }
 
+    for (i = 0; i < sur->ntextures; ++i)
+        RrTexturePaint(sur, &sur->texture[i]);
+
     glXSwapBuffers(RrDisplay(inst), RrSurfaceWindow(sur));
 }
index e01b67e8a874659010fc8185d696c4bb02741875..4afd7140f94e9da43562fd77b3ac37e297d71a15 100644 (file)
@@ -1,7 +1,6 @@
 #include "planar.h"
 #include "surface.h"
 #include "texture.h"
-#include "glft/glft.h"
 #include "color.h"
 #include "debug.h"
 #include "font.h"
@@ -80,7 +79,6 @@ void RrPlanarPaint(struct RrSurface *sur, int absx, int absy)
 {   
     struct RrColor *pri, *sec, avg;
     int x, y, w, h;
-    int i;
 
     copy_parent(sur);
 
@@ -298,26 +296,6 @@ void RrPlanarPaint(struct RrSurface *sur, int absx, int absy)
         glEnd();
         break;
     }
-    for (i = 0; i < sur->ntextures; i++) {
-        struct RrTextureText *t;
-        glEnable(GL_TEXTURE_2D);
-        switch (sur->texture[i].type) {
-        case RR_TEXTURE_NONE:
-            break;
-        case RR_TEXTURE_TEXT:
-            t = &sur->texture[i].data.text;
-            printf("text %s\n", t->string);
-            glColor3f(1.0, 1.0, 1.0);
-            if (t->font == NULL) {
-                glDisable(GL_TEXTURE_2D);
-                return;
-            }
-            GlftRenderString(t->font->font, t->string, 
-                             strlen(t->string), 0, 0);
-            break;
-        }
-    }
-    glDisable(GL_TEXTURE_2D);
 }
 
 void RrPlanarMinSize(struct RrSurface *sur, int *w, int *h)
index 4d6aaa532c7c0b1807e918bb31ad039f75dd5919..0e0cac87dd300c0bd304029ca7bd41bfe78fea3f 100644 (file)
@@ -1,7 +1,10 @@
 #include "instance.h"
 #include "texture.h"
 #include "surface.h"
+#include "font.h"
+#include "glft/glft.h"
 #include <stdlib.h>
+#include <assert.h>
 #include <string.h>
 
 void RrTextureFreeContents(struct RrTexture *tex)
@@ -80,3 +83,26 @@ void RrTextureSetNone(struct RrSurface *sur,
     if (!tex) return;
     RrTextureFreeContents(tex);
 }
+
+void RrTexturePaint(struct RrSurface *sur, struct RrTexture *tex)
+{
+    struct GlftColor col;
+
+    glEnable(GL_TEXTURE_2D);
+    
+    switch (tex->type) {
+    case RR_TEXTURE_NONE:
+        break;
+    case RR_TEXTURE_TEXT:
+        printf("text %s\n", tex->data.text.string);
+        assert(tex->data.text.font);
+        col.r = tex->data.text.color.r;
+        col.g = tex->data.text.color.g;
+        col.b = tex->data.text.color.b;
+        col.a = tex->data.text.color.a;
+        GlftRenderString(tex->data.text.font->font, tex->data.text.string, 
+                         strlen(tex->data.text.string), &col, 0, 0);
+        break;
+    }
+    glDisable(GL_TEXTURE_2D);
+}
index 9e1e08bb3fcd935c3d7b32e7bdef7fe7fe6115b0..5d535e3befe50a2fc5b5f79f23a5501189cbae66 100644 (file)
@@ -39,4 +39,6 @@ struct RrTexture {
     union RrTextureData data;
 };
 
+void RrTexturePaint(struct RrSurface *sur, struct RrTexture *tex);
+
 #endif