From: rgaitan Date: Sun, 30 Aug 2009 00:12:25 +0000 (+0200) Subject: estructura inicial de la demo X-Git-Url: http://slack.codemaniacs.com/git/?a=commitdiff_plain;h=ba158dfd4a78194326ce133598d65d0e9118ff0b;p=fov120.git estructura inicial de la demo --- diff --git a/main.c b/main.c index 74711c8..8752b84 100644 --- a/main.c +++ b/main.c @@ -9,8 +9,67 @@ //#define sqrt(x) __builtin_sqrtf(x) //#define expf(x) __builtin_expf(x) +#define SCREEN_WIDTH 1280 +#define SCREEN_HEIGHT 720 + float current_t; +#define renderTexture 1 + +typedef struct +{ + float s,t,aux1,aux2; // tex coords + float c1,c2,c3,c4; // color + float n1,n2,n3; // normal + float v1,v2,v3,aux3; // vertice +} VertexInfo; + +#define MODEL_SIZE 1000000 + +VertexInfo gurru1[MODEL_SIZE]; +VertexInfo gurru2[MODEL_SIZE]; + +void initTextures() +{ + fn.glEnable(GL_TEXTURE_2D); +} + +void initModels() +{ + // init gurrus + for(float u=0.0;u<10.0;u++) + { + for(float v=0.0;v<10.0;v++) + { + // calc superquadric for gurru1 + // calc superquadric for gurru2 + } + } +} + +void endRenderTexture() +{ + fn.glBindTexture(renderTexture); + fn.glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); +} + +void drawScene() +{ + if(current_t<10.0) + { + fn.glRotatef(current_t,1.0,1.0,1.0); + fn.glInterleavedArrays(GL_T4F_C4F_N3F_V4F,0,gurru1); + } + else if(current_t>=10.0 && current_t<20.0) + { + fn.glInterleavedArrays(GL_T4F_C4F_N3F_V4F,0,gurru2); + } +} + +void drawPostProcess() +{ +} + #ifdef DEBUG int main() #else @@ -23,9 +82,12 @@ void __attribute__((externally_visible)) _start(void) fn.SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO); fn.SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); fn.SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL,1); - fn.SDL_SetVideoMode(1280,960,32,SDL_OPENGL); + fn.SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,32,SDL_OPENGL); fn.SDL_ShowCursor(0); + initTextures(); + initModels(); + while(1) { current_t = fn.SDL_GetTicks()/1000.0f; @@ -34,6 +96,9 @@ void __attribute__((externally_visible)) _start(void) if (event.type == SDL_KEYDOWN) goto end; } + drawScene(); + endRenderTexture(); + drawPostProcess(); fn.SDL_GL_SwapBuffers(); }