diff --git a/CMakeLists.txt b/CMakeLists.txt index 90ca295..0f40550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,5 +44,11 @@ link_libraries(m) include_directories(include) +link_libraries(GLdc) + add_executable(nehe02 samples/nehe02/main.c) -target_link_libraries(nehe02 GLdc) +add_executable(blend_test samples/blend_test/main.c) +add_executable(depth_funcs samples/depth_funcs/main.c) +add_executable(depth_funcs_alpha_testing samples/depth_funcs_alpha_testing/main.c samples/depth_funcs_alpha_testing/gl_png.c) + + diff --git a/GL/platforms/software.c b/GL/platforms/software.c index f965bd3..052f517 100644 --- a/GL/platforms/software.c +++ b/GL/platforms/software.c @@ -14,6 +14,8 @@ static Matrix4x4 MATRIX; static SDL_Window* WINDOW = NULL; static SDL_Renderer* RENDERER = NULL; +static uint8_t BACKGROUND_COLOR[3] = {0, 0, 0}; + GPUCulling CULL_MODE = GPU_CULLING_CCW; @@ -129,7 +131,7 @@ void InitGPU(_Bool autosort, _Bool fsaa) { } void SceneBegin() { - SDL_SetRenderDrawColor(RENDERER, 0, 0, 0, 0); + SDL_SetRenderDrawColor(RENDERER, BACKGROUND_COLOR[0], BACKGROUND_COLOR[1], BACKGROUND_COLOR[2], 0); SDL_RenderClear(RENDERER); } @@ -256,7 +258,9 @@ void GPUSetPaletteEntry(uint32_t idx, uint32_t value) { } void GPUSetBackgroundColour(float r, float g, float b) { - + BACKGROUND_COLOR[0] = r * 255.0f; + BACKGROUND_COLOR[1] = g * 255.0f; + BACKGROUND_COLOR[2] = b * 255.0f; } void GPUSetAlphaCutOff(uint8_t v) { diff --git a/GL/state.c b/GL/state.c index 6665d1a..9487e6a 100644 --- a/GL/state.c +++ b/GL/state.c @@ -421,9 +421,12 @@ GLAPI void APIENTRY glClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { if(b > 1) b = 1; if(a > 1) a = 1; - CLEAR_COLOUR[0] = r * a; - CLEAR_COLOUR[1] = g * a; - CLEAR_COLOUR[2] = b * a; + /* FIXME: The background-poly doesn't take an alpha value */ + _GL_UNUSED(a); + + CLEAR_COLOUR[0] = r; + CLEAR_COLOUR[1] = g; + CLEAR_COLOUR[2] = b; } /* Depth Testing */ diff --git a/samples/blend_test/main.c b/samples/blend_test/main.c index 2635e9b..191bbe9 100644 --- a/samples/blend_test/main.c +++ b/samples/blend_test/main.c @@ -4,9 +4,9 @@ * output and incorrect depth testing */ -#include "gl.h" -#include "glu.h" -#include "glkos.h" +#include "GL/gl.h" +#include "GL/glu.h" +#include "GL/glkos.h" /* A general OpenGL initialization function. Sets all of the initial parameters. */ void InitGL(int Width, int Height) // We call this right after our OpenGL window is created. diff --git a/samples/depth_funcs/main.c b/samples/depth_funcs/main.c index aab0184..fe90f35 100644 --- a/samples/depth_funcs/main.c +++ b/samples/depth_funcs/main.c @@ -1,6 +1,6 @@ -#include "gl.h" -#include "glu.h" -#include "glkos.h" +#include "GL/gl.h" +#include "GL/glu.h" +#include "GL/glkos.h" /* A general OpenGL initialization function. Sets all of the initial parameters. */ void InitGL(int Width, int Height) // We call this right after our OpenGL window is created. diff --git a/samples/depth_funcs_alpha_testing/gl_png.c b/samples/depth_funcs_alpha_testing/gl_png.c index 05dedc4..d72e011 100644 --- a/samples/depth_funcs_alpha_testing/gl_png.c +++ b/samples/depth_funcs_alpha_testing/gl_png.c @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/samples/depth_funcs_alpha_testing/gl_png.h b/samples/depth_funcs_alpha_testing/gl_png.h index 21070b7..29b312f 100644 --- a/samples/depth_funcs_alpha_testing/gl_png.h +++ b/samples/depth_funcs_alpha_testing/gl_png.h @@ -2,7 +2,7 @@ #define __GL_PNG_H__ #include -#include +#include #include typedef struct _texture { diff --git a/samples/depth_funcs_alpha_testing/main.c b/samples/depth_funcs_alpha_testing/main.c index 5bdbaad..c0e7e81 100644 --- a/samples/depth_funcs_alpha_testing/main.c +++ b/samples/depth_funcs_alpha_testing/main.c @@ -1,11 +1,11 @@ -#include "gl.h" -#include "glu.h" -#include "glkos.h" +#include "GL/gl.h" +#include "GL/glu.h" +#include "GL/glkos.h" #include "gl_png.h" //$KOS_BASE/utils/texconv/texconv --in disk.png --format ARGB4444 --preview disk_preview.png --out disk.dtex -extern uint8 romdisk[]; +extern uint8_t romdisk[]; KOS_INIT_ROMDISK(romdisk); texture t; int blendActive = -1; diff --git a/samples/nehe02/main.c b/samples/nehe02/main.c index aeaa8b8..ae6a0d0 100644 --- a/samples/nehe02/main.c +++ b/samples/nehe02/main.c @@ -16,7 +16,7 @@ void InitGL(int Width, int Height) // We call this right after our OpenG gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f); // Calculate The Aspect Ratio Of The Window - glMatrixMode(GL_MODELVIEW); + glMatrixMode(GL_MODELVIEW); } /* The function called when our window is resized (which shouldn't happen, because we're fullscreen) */