Add some more samples and fix background colour

This commit is contained in:
Luke Benstead 2021-04-07 15:27:40 +01:00
parent 43e9508f6a
commit 2cd4c813ad
9 changed files with 31 additions and 19 deletions

View File

@ -44,5 +44,11 @@ link_libraries(m)
include_directories(include) include_directories(include)
link_libraries(GLdc)
add_executable(nehe02 samples/nehe02/main.c) 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)

View File

@ -14,6 +14,8 @@ static Matrix4x4 MATRIX;
static SDL_Window* WINDOW = NULL; static SDL_Window* WINDOW = NULL;
static SDL_Renderer* RENDERER = NULL; static SDL_Renderer* RENDERER = NULL;
static uint8_t BACKGROUND_COLOR[3] = {0, 0, 0};
GPUCulling CULL_MODE = GPU_CULLING_CCW; GPUCulling CULL_MODE = GPU_CULLING_CCW;
@ -129,7 +131,7 @@ void InitGPU(_Bool autosort, _Bool fsaa) {
} }
void SceneBegin() { 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); SDL_RenderClear(RENDERER);
} }
@ -256,7 +258,9 @@ void GPUSetPaletteEntry(uint32_t idx, uint32_t value) {
} }
void GPUSetBackgroundColour(float r, float g, float b) { 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) { void GPUSetAlphaCutOff(uint8_t v) {

View File

@ -421,9 +421,12 @@ GLAPI void APIENTRY glClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
if(b > 1) b = 1; if(b > 1) b = 1;
if(a > 1) a = 1; if(a > 1) a = 1;
CLEAR_COLOUR[0] = r * a; /* FIXME: The background-poly doesn't take an alpha value */
CLEAR_COLOUR[1] = g * a; _GL_UNUSED(a);
CLEAR_COLOUR[2] = b * a;
CLEAR_COLOUR[0] = r;
CLEAR_COLOUR[1] = g;
CLEAR_COLOUR[2] = b;
} }
/* Depth Testing */ /* Depth Testing */

View File

@ -4,9 +4,9 @@
* output and incorrect depth testing * output and incorrect depth testing
*/ */
#include "gl.h" #include "GL/gl.h"
#include "glu.h" #include "GL/glu.h"
#include "glkos.h" #include "GL/glkos.h"
/* A general OpenGL initialization function. Sets all of the initial parameters. */ /* 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. void InitGL(int Width, int Height) // We call this right after our OpenGL window is created.

View File

@ -1,6 +1,6 @@
#include "gl.h" #include "GL/gl.h"
#include "glu.h" #include "GL/glu.h"
#include "glkos.h" #include "GL/glkos.h"
/* A general OpenGL initialization function. Sets all of the initial parameters. */ /* 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. void InitGL(int Width, int Height) // We call this right after our OpenGL window is created.

View File

@ -1,4 +1,3 @@
#include <kos.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -2,7 +2,7 @@
#define __GL_PNG_H__ #define __GL_PNG_H__
#include <stdio.h> #include <stdio.h>
#include <kos.h> #include <stdint.h>
#include <GL/gl.h> #include <GL/gl.h>
typedef struct _texture { typedef struct _texture {

View File

@ -1,11 +1,11 @@
#include "gl.h" #include "GL/gl.h"
#include "glu.h" #include "GL/glu.h"
#include "glkos.h" #include "GL/glkos.h"
#include "gl_png.h" #include "gl_png.h"
//$KOS_BASE/utils/texconv/texconv --in disk.png --format ARGB4444 --preview disk_preview.png --out disk.dtex //$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); KOS_INIT_ROMDISK(romdisk);
texture t; texture t;
int blendActive = -1; int blendActive = -1;

View File

@ -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 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) */ /* The function called when our window is resized (which shouldn't happen, because we're fullscreen) */