From 87b0bdb5e61472d33f4987d92d60c12cc21a6fe6 Mon Sep 17 00:00:00 2001 From: Kyle K Date: Wed, 13 Oct 2010 21:07:28 -0500 Subject: pyramid: enabled fog --- sdl/GL_todo.txt | 2 ++ sdl/glframe.c | 4 ++-- sdl/pyramid.c | 27 ++++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/sdl/GL_todo.txt b/sdl/GL_todo.txt index 845aabd..4466642 100644 --- a/sdl/GL_todo.txt +++ b/sdl/GL_todo.txt @@ -9,3 +9,5 @@ todo: - enable fog - xbox controller - obj loader +- look at mesa's sources and borrow OSD stuff +- GL error checking and extensions diff --git a/sdl/glframe.c b/sdl/glframe.c index da7800e..668f8de 100644 --- a/sdl/glframe.c +++ b/sdl/glframe.c @@ -2,8 +2,8 @@ * * Camera * - * note: we could make these functions to be inlines, but they would need - * to be moved into the header + * note: we could make these functions to be inlined, but they would need + * to be moved into a header * */ diff --git a/sdl/pyramid.c b/sdl/pyramid.c index c7fe00e..fa78477 100644 --- a/sdl/pyramid.c +++ b/sdl/pyramid.c @@ -27,6 +27,11 @@ GLFrame camera; static GLfloat xRot = 0.0f; static GLfloat yRot = 0.0f; +/* few arrays, they could make into the header at some point */ +GLfloat fNoLight[] = { 0.0f, 0.0f, 0.0f, 0.0f }; +GLfloat fLowLight[] = { 0.25f, 0.25f, 0.25f, 1.0f }; +GLfloat fBrightLight[] = { 1.0f, 1.0f, 1.0f, 1.0f }; + static void resize(int w, int h) { printf("window: resizing to %dx%d\n", w, h); @@ -60,6 +65,13 @@ static void SetupRC() GLfloat whiteLight[] = { 0.05f, 0.05f, 0.05f, 1.0f }; GLfloat sourceLight[] = { 0.75f, 0.75f, 0.75f, 1.0f }; GLfloat lightPos[] = { -10.f, 5.0f, 5.0f, 1.0f }; + + /* setup fog */ + glEnable(GL_FOG); + glFogfv(GL_FOG_COLOR, fLowLight); /* set fog color to match background */ + glFogf(GL_FOG_START, 4.0f); + glFogf(GL_FOG_END, 20.0f); + glFogi(GL_FOG_MODE, GL_LINEAR); /* fog equation */ glEnable(GL_DEPTH_TEST); /* hidden surface removal */ glFrontFace(GL_CCW); /* counter clock-wise polygons face out */ @@ -106,6 +118,19 @@ static void SetupRC() /* set the camera to <0,0,0> */ reset_glframe(&camera); + + /* multisampling for polygons */ + //glEnable(GL_MULTISAMPLE); + + /* turn on anti aliasing for points, lines, and polygons */ + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glEnable(GL_POINT_SMOOTH); + glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); + glEnable(GL_LINE_SMOOTH); + glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); + glEnable(GL_POLYGON_SMOOTH); + glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST); } static void keys(SDL_keysym *keysym, unsigned int *keys_held, int flag) @@ -198,7 +223,7 @@ void processEvents() static void draw_ground(void) { - GLfloat fExtent = 10.0f; + GLfloat fExtent = 20.0f; GLfloat fStep = 0.5f; GLfloat y = -0.4f; GLfloat iLine; -- cgit v1.2.3