|
From: julien r. <jul...@us...> - 2005-12-11 22:16:23
|
Update of /cvsroot/epfl/engine In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26830 Modified Files: Makefile defs.h glrenderer.cc image.cc image.h material_manager.cc Log Message: buxfix lightmaps, bugfix deplacements Index: material_manager.cc =================================================================== RCS file: /cvsroot/epfl/engine/material_manager.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** material_manager.cc 7 Dec 2005 22:23:49 -0000 1.3 --- material_manager.cc 11 Dec 2005 22:16:00 -0000 1.4 *************** *** 69,73 **** } } else { //sinon on ajoute la texture direct ! //#define ALL_TEXTURES #ifdef ALL_TEXTURES tgMaterial* mat = new tgMaterial("data/"+name+".tga"); --- 69,73 ---- } } else { //sinon on ajoute la texture direct ! #define ALL_TEXTURES #ifdef ALL_TEXTURES tgMaterial* mat = new tgMaterial("data/"+name+".tga"); Index: image.h =================================================================== RCS file: /cvsroot/epfl/engine/image.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** image.h 7 Dec 2005 22:23:49 -0000 1.2 --- image.h 11 Dec 2005 22:16:00 -0000 1.3 *************** *** 38,49 **** //unsigned short int GetAlphaDepth () { return iAlphaDepth; } //unsigned short int GetPixelDepth () { return iPixelDepth; } ! unsigned short GetColorMode () { return iColorMode; } ! unsigned int GetWidth () { return iWidth; } ! unsigned int GetHeight () { return iHeight; } ! unsigned char* GetPixels () {return pData; } inline operator bool() const { return bLoaded; } protected: ! struct TGAHeader { uint8 IDLength; uint8 colorMapType; --- 38,49 ---- //unsigned short int GetAlphaDepth () { return iAlphaDepth; } //unsigned short int GetPixelDepth () { return iPixelDepth; } ! unsigned short GetColorMode () { return /*iColorMode;*/type; } ! unsigned int GetWidth () { return /*iWidth;*/w; } ! unsigned int GetHeight () { return /*iHeight;*/h; } ! unsigned char* GetPixels () {return /*pData;*/ data;} inline operator bool() const { return bLoaded; } protected: ! /*struct TGAHeader { uint8 IDLength; uint8 colorMapType; *************** *** 74,79 **** unsigned int iBpp; unsigned int iWidth; ! unsigned int iHeight; ! bool bLoaded; }; --- 74,83 ---- unsigned int iBpp; unsigned int iWidth; ! unsigned int iHeight;*/ ! //SDL_Surface* image; ! unsigned char* data; ! int w; ! int h; ! int type; bool bLoaded; }; Index: defs.h =================================================================== RCS file: /cvsroot/epfl/engine/defs.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** defs.h 7 Dec 2005 22:23:49 -0000 1.2 --- defs.h 11 Dec 2005 22:16:00 -0000 1.3 *************** *** 29,32 **** --- 29,33 ---- #include <sys/stat.h> #include <SDL/SDL.h> + #include <SDL/SDL_image.h> using namespace std; Index: Makefile =================================================================== RCS file: /cvsroot/epfl/engine/Makefile,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Makefile 24 Nov 2005 20:47:12 -0000 1.1.1.1 --- Makefile 11 Dec 2005 22:16:00 -0000 1.2 *************** *** 1,5 **** CC = g++ CFLAGS = -DTGLINUX -I/usr/include/SDL -I./interface -I../game/interface -Wall -DDEBUG -DMEMORY_DEBUG -ggdb ! LDFLAGS = -ldl -lSDL -lm -lGL -lGLU -ggdb -L../ -ltglib -pg TARGET = ../tg OBJ_EXT = o --- 1,5 ---- CC = g++ CFLAGS = -DTGLINUX -I/usr/include/SDL -I./interface -I../game/interface -Wall -DDEBUG -DMEMORY_DEBUG -ggdb ! LDFLAGS = -ldl -lSDL -lSDL_image -lm -lGL -lGLU -ggdb -L../ -ltglib TARGET = ../tg OBJ_EXT = o Index: image.cc =================================================================== RCS file: /cvsroot/epfl/engine/image.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** image.cc 7 Dec 2005 22:23:49 -0000 1.2 --- image.cc 11 Dec 2005 22:16:00 -0000 1.3 *************** *** 22,29 **** */ #include "image.h" tgImage::tgImage(const tgstring& filename) { ! pData = NULL; iColorMode = 0; iWidth = 0; --- 22,68 ---- */ #include "image.h" + inline Uint32 getpixel(SDL_Surface *surface, int x, int y) { + Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * + surface->format->BytesPerPixel; + return (*(Uint32 *)p); + } tgImage::tgImage(const tgstring& filename) { ! SDL_Surface* image = IMG_Load(filename.data()); ! if(!image) { ! bLoaded = false; ! return; ! } ! bLoaded = true; ! w = image->w; ! h = image->h; ! type = GL_RGBA; ! int dim = w*h*4; // RGBA ! data = new unsigned char[dim]; ! int pos = 0; ! for(int y=(h-1); y>-1; y--) { ! for(int x=0; x<w; x++) { ! Uint8 r,g,b,a; ! //Uint32 color = getpixel(img, x,y); ! //Uint32 color = (Uint32)image->pixels[x+y*w]; ! Uint32 color = getpixel(image,x,y); ! ! /* if(!alpha) ! SDL_GetRGB(color, img->format, &r,&g,&b); ! else*/ ! SDL_GetRGBA(color, image->format, &r,&g,&b,&a); ! ! data[pos] = r; pos++; ! data[pos] = g; pos++; ! data[pos] = b; pos++; ! //if(alpha) { ! data[pos] = a; pos++; ! //} ! } ! } ! SDL_FreeSurface(image); ! ! /* pData = NULL; iColorMode = 0; iWidth = 0; *************** *** 37,48 **** bLoaded = false; } ! } tgImage::~ tgImage() { ! delete [] pData; } ! bool tgImage::_LoadTGA(const tgstring& filename) { --- 76,88 ---- bLoaded = false; } ! */ } tgImage::~ tgImage() { ! delete [] data; ! /* delete [] pData;*/ } ! /* bool tgImage::_LoadTGA(const tgstring& filename) { *************** *** 198,201 **** delete [] colorbuffer; return true; ! } --- 238,241 ---- delete [] colorbuffer; return true; ! }*/ Index: glrenderer.cc =================================================================== RCS file: /cvsroot/epfl/engine/glrenderer.cc,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** glrenderer.cc 10 Dec 2005 23:58:26 -0000 1.4 --- glrenderer.cc 11 Dec 2005 22:16:00 -0000 1.5 *************** *** 482,489 **** tgglActiveTexture(GL_TEXTURE1); if (pMesh->lightmapID>=0) ! glBindTexture (GL_TEXTURE_2D, l->pLightMaps[pMesh->lightmapID]); else { ! //glBindTexture (GL_TEXTURE_2D, pTexManager->GetWhite()); ! glDisable(GL_TEXTURE_2D); } --- 482,489 ---- tgglActiveTexture(GL_TEXTURE1); if (pMesh->lightmapID>=0) ! tgglBindTexture (GL_TEXTURE_2D, l->pLightMaps[pMesh->lightmapID]); else { ! // glBindTexture (GL_TEXTURE_2D, pTexManager->GetWhite()); ! tgglDisable(GL_TEXTURE_2D); } *************** *** 497,500 **** --- 497,505 ---- glDrawElements (GL_TRIANGLES, pMesh->numOfMeshVerts, GL_UNSIGNED_INT, &l->pMeshIndices[pMesh->firstMeshIndex]); numMeshRend++; + //au cas ou on l'aurait disable ci-dessus + if (pMesh->lightmapID<0) { + tgglActiveTexture(GL_TEXTURE1); + tgglEnable(GL_TEXTURE_2D); + } } } |