summaryrefslogtreecommitdiffstats
path: root/sdl/platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'sdl/platform.c')
-rw-r--r--sdl/platform.c43
1 files changed, 10 insertions, 33 deletions
diff --git a/sdl/platform.c b/sdl/platform.c
index a44bfd4..2d770a8 100644
--- a/sdl/platform.c
+++ b/sdl/platform.c
@@ -26,7 +26,7 @@ const GLfloat fShinyLight[] = { 0.70f, 0.70f, 0.70f, 1.0f };
const GLfloat fBrightLight[] = { 1.0f, 1.0f, 1.0f, 1.0f };
/* light values and coordinates */
-const GLfloat lightPos[] = { -10.f, 5.0f, 5.0f, 1.0f };
+const GLfloat lightPos[] = { -10.f, 5.0f, 5.0f, 1.0f };
/* variables that should be already defined and declared for us by main program */
extern unsigned int xres_w;
@@ -40,8 +40,6 @@ extern unsigned int maxfps_w;
void platform_init(struct platform *p)
{
- memset(p, 0, sizeof(struct platform));
-
/* Lua */
/* create new lua state */
p->L = luaL_newstate();
@@ -49,54 +47,33 @@ void platform_init(struct platform *p)
/* load lua libraries */
luaL_openlibs(p->L);
- /* ToDo: how would you make platform more generic? */
- /* note, this should be already zero'ed out */
- memset(&p->config_table, 0, sizeof(p->config_table));
-
/* initialize SDL, GLEW, and OpenGL */
load_config(p);
p->screen = setup_sdl();
setup_glew();
setup_opengl();
- /* set the camera to <0,0,0> */
- glframe_reset(&p->camera);
- p->textures[0] = gltLoadTGATexture("stone.tga");
- p->textures[1] = gltLoadTGATexture("grass.tga");
-
- /* display list, precompile commands */
- p->ground_list = glGenLists(2);
- p->triangle_list = p->ground_list + 1;
-
- /* a triangle with a texture */
- glNewList(p->triangle_list, GL_COMPILE);
- glBindTexture(GL_TEXTURE_2D, p->textures[0]);
- /* glBindTexture(GL_TEXTURE_2D, p->textures[1]); */
- glColor3f(1.0f, 1.0f, 1.0f);
- glDrawTriangle();
- glEndList();
-
- /* a ground drawn using magneta lines */
- glNewList(p->ground_list, GL_COMPILE);
- glColor3ub(255, 0, 255);
- glDrawGround();
- glEndList();
-
/* add a simple timer / callback function */
p->timer_id = SDL_AddTimer(5000, sdlTimerCallback, &(p->camera));
/* apply a custom cursor */
p->my_cursor = sdlInitCursor(arrow);
SDL_SetCursor(p->my_cursor);
+
+ /* set the camera to <0,0,0> */
+ glframe_reset(&p->camera);
+
+ /* init client */
+ p->client_init(p->c);
}
+/* it's a good idea to destroy things in reverse order */
void platform_destroy(struct platform *p)
{
- glDeleteTextures(2, p->textures);
- glDeleteLists(p->ground_list, 2);
+ /* destroy client */
+ p->client_destroy(p->c);
SDL_FreeSurface(p->screen);
-
lua_close(p->L);
}