dos3d

diff src/scene.c @ 19:c10f62b2bd56

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 30 Nov 2011 07:17:09 +0200
parents 1e9f0b3616fa
children
line diff
     1.1 --- a/src/scene.c	Wed Nov 30 00:06:28 2011 +0200
     1.2 +++ b/src/scene.c	Wed Nov 30 07:17:09 2011 +0200
     1.3 @@ -3,6 +3,7 @@
     1.4  #include <string.h>
     1.5  #include <ctype.h>
     1.6  #include <errno.h>
     1.7 +#include <assert.h>
     1.8  #include "scene.h"
     1.9  #include "cvec.h"
    1.10  #include "palman.h"
    1.11 @@ -159,11 +160,12 @@
    1.12  			vnarr = cvec_append(vnarr, &v);
    1.13  
    1.14  		} else if(strcmp(tok, "vt") == 0) {
    1.15 -			vec3_t v;
    1.16 +			vec2_t v;
    1.17  
    1.18 -			if(!rest || sscanf(rest, "%f %f %f\n", &v.x, &v.y, &v.z) != 3) {
    1.19 +			if(!rest || sscanf(rest, "%f %f\n", &v.x, &v.y) != 2) {
    1.20  				continue;
    1.21  			}
    1.22 +			v.y = 1.0 - v.y;
    1.23  			vtarr = cvec_append(vtarr, &v);
    1.24  
    1.25  		} else if(strcmp(tok, "f") == 0) {
    1.26 @@ -338,6 +340,45 @@
    1.27  		mesh_draw(m);
    1.28  		m = m->next;
    1.29  	}
    1.30 +
    1.31 +#if 0
    1.32 +	{
    1.33 +		int i;
    1.34 +		struct palm_color *pal = palm_palette();
    1.35 +		float dx = 1.8 / 256;
    1.36 +		struct material *mtl = scn->matlist;
    1.37 +
    1.38 +		glMatrixMode(GL_MODELVIEW);
    1.39 +		glPushMatrix();
    1.40 +		glLoadIdentity();
    1.41 +		glMatrixMode(GL_PROJECTION);
    1.42 +		glPushMatrix();
    1.43 +		glLoadIdentity();
    1.44 +
    1.45 +		glPushAttrib(GL_ENABLE_BIT);
    1.46 +		glDisable(GL_LIGHTING);
    1.47 +		glDisable(GL_DEPTH_TEST);
    1.48 +
    1.49 +		glBegin(GL_QUADS);
    1.50 +		for(i=0; i<255; i++) {
    1.51 +			float x = i * dx - 0.9;
    1.52 +			glColor3ub(pal[i].r, pal[i].g, pal[i].b);
    1.53 +			glVertex2f(x, 0.98);
    1.54 +			glVertex2f(x, 0.9);
    1.55 +			glColor3ub(pal[i + 1].r, pal[i + 1].g, pal[i + 1].b);
    1.56 +			glVertex2f(x + dx, 0.9);
    1.57 +			glVertex2f(x + dx, 0.98);
    1.58 +		}
    1.59 +		glEnd();
    1.60 +
    1.61 +		glPopAttrib();
    1.62 +
    1.63 +		glMatrixMode(GL_PROJECTION);
    1.64 +		glPopMatrix();
    1.65 +		glMatrixMode(GL_MODELVIEW);
    1.66 +		glPopMatrix();
    1.67 +	}
    1.68 +#endif
    1.69  }
    1.70  
    1.71  /* --- material --- */
    1.72 @@ -421,6 +462,7 @@
    1.73  
    1.74  #ifdef USE_GL
    1.75  	if(mtl->tex) {
    1.76 +		assert(mtl->tex->pixels);
    1.77  		glEnable(GL_TEXTURE_2D);
    1.78  		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    1.79  		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    1.80 @@ -443,7 +485,7 @@
    1.81  	}
    1.82  #else
    1.83  	if(mtl->tex) {
    1.84 -		/*mgl_enable(MGL_TEXTURE_2D);*/
    1.85 +		mgl_enable(MGL_TEXTURE_2D);
    1.86  		mgl_teximage(mtl->tex->width, mtl->tex->height, mtl->tex->pixels);
    1.87  	} else {
    1.88  		mgl_index(mtl->kd_base);