diff --git a/GL/lighting.c b/GL/lighting.c index eb95b17..249a389 100644 --- a/GL/lighting.c +++ b/GL/lighting.c @@ -225,6 +225,7 @@ static float FPOW(float b, float p) { return FEXP(FLOG(b) * p); } +void calculateLightingContribution(const GLint light, const GLfloat* pos, const GLfloat* normal, GLfloat* colour) __attribute__((optimize("fast-math"))); void calculateLightingContribution(const GLint light, const GLfloat* pos, const GLfloat* normal, GLfloat* colour) { LightSource* l = &LIGHTS[light]; diff --git a/GL/state.c b/GL/state.c index dac06cc..044b3d8 100644 --- a/GL/state.c +++ b/GL/state.c @@ -428,3 +428,21 @@ void APIENTRY glGetIntegerv(GLenum pname, GLint *params) { break; } } + +const GLbyte *glGetString(GLenum name) { + switch(name) { + case GL_VENDOR: + return "KallistiOS / Kazade"; + + case GL_RENDERER: + return "PowerVR2 CLX2 100mHz"; + + case GL_VERSION: + return "GLdc 1.x"; + + case GL_EXTENSIONS: + return "GL_ARB_framebuffer_object, GL_ARB_multitexture, GL_ARB_texture_rg"; + } + + return "GL_KOS_ERROR: ENUM Unsupported\n"; +} diff --git a/Makefile b/Makefile index 4da1644..f2711c1 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ TARGET = libGL.a OBJS = gl-rgb.o gl-fog.o gl-sh4-light.o gl-light.o gl-clip.o gl-clip-arrays.o OBJS += gl-pvr.o gl-matrix.o gl-api.o glu-texture.o -OBJS += gl-framebuffer.o gl-cap.o gl-error.o +OBJS += gl-framebuffer.o gl-error.o OBJS += GL/draw.o GL/flush.o GL/framebuffer.o GL/immediate.o GL/lighting.o GL/state.o GL/texture.o OBJS += GL/matrix.o diff --git a/README.md b/README.md index f4fbb93..c4c7834 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,13 @@ features via extensions. Things left to (re)implement: - - Fog - - Near-Z clipping - - Spotlights and point lights - - Framebuffer extension + - Fog (Trivial) + - Near-Z clipping (Tricky) + - Spotlights (Trivial) + - Framebuffer extension (Trivial) + - Multitexturing (Trivial) + - Texture Matrix (Trivial) + - Mipmapping (Trivial) Things I'd like to do: diff --git a/gl-cap.c b/gl-cap.c deleted file mode 100644 index 63996ad..0000000 --- a/gl-cap.c +++ /dev/null @@ -1,188 +0,0 @@ -/* KallistiGL for KallistiOS ##version## - - libgl/gl-cap.c - Copyright (C) 2014 Josh Pearson - - KOS Open GL Capabilty State Machine Implementation. -*/ - -#include "gl.h" -#include "gl-api.h" - -//===============================================================================// -//== Enable Bit Flags ==// - -#define GL_KOS_ENABLE_DEPTH_TEST (1<<0) -#define GL_KOS_ENABLE_SCISSOR_TEST (1<<1) -#define GL_KOS_ENABLE_CULLING (1<<2) -#define GL_KOS_ENABLE_FOG (1<<3) -#define GL_KOS_ENABLE_LIGHTING (1<<4) -#define GL_KOS_ENABLE_ZCLIPPING (1<<5) -#define GL_KOS_ENABLE_SUPERSAMPLE (1<<6) -#define GL_KOS_ENABLE_TEXTURE2D (1<<7) -#define GL_KOS_ENABLE_BLENDING (1<<8) -#define GL_KOS_ENABLE_TEXTURE_MAT (1<<9) - -static GLbitfield GL_KOS_ENABLE_CAP = 0; - -//===============================================================================// -//== External API Functions ==// - -//void APIENTRY glEnable(GLenum cap) { -// if(cap >= GL_LIGHT0 && cap <= GL_LIGHT15) return _glKosEnableLight(cap); - -// switch(cap) { -// case GL_TEXTURE_2D: -// GL_KOS_ENABLE_CAP |= GL_KOS_ENABLE_TEXTURE2D; -// break; - -// case GL_BLEND: -// GL_KOS_ENABLE_CAP |= GL_KOS_ENABLE_BLENDING; -// _glKosVertexBufSwitchTR(); -// break; - -// case GL_DEPTH_TEST: -// GL_KOS_ENABLE_CAP |= GL_KOS_ENABLE_DEPTH_TEST; -// break; - -// case GL_LIGHTING: -// GL_KOS_ENABLE_CAP |= GL_KOS_ENABLE_LIGHTING; -// break; - -// case GL_KOS_NEARZ_CLIPPING: -// GL_KOS_ENABLE_CAP |= GL_KOS_ENABLE_ZCLIPPING; -// break; - -// case GL_SCISSOR_TEST: -// GL_KOS_ENABLE_CAP |= GL_KOS_ENABLE_SCISSOR_TEST; -// break; - -// case GL_FOG: -// GL_KOS_ENABLE_CAP |= GL_KOS_ENABLE_FOG; -// break; - -// case GL_CULL_FACE: -// GL_KOS_ENABLE_CAP |= GL_KOS_ENABLE_CULLING; -// break; - -// case GL_KOS_TEXTURE_MATRIX: -// GL_KOS_ENABLE_CAP |= GL_KOS_ENABLE_TEXTURE_MAT; -// break; -// } -//} - -//void APIENTRY glDisable(GLenum cap) { -// if(cap >= GL_LIGHT0 && cap <= GL_LIGHT15) return _glKosDisableLight(cap); - -// switch(cap) { -// case GL_TEXTURE_2D: -// GL_KOS_ENABLE_CAP &= ~GL_KOS_ENABLE_TEXTURE2D; -// break; - -// case GL_BLEND: -// GL_KOS_ENABLE_CAP &= ~GL_KOS_ENABLE_BLENDING; -// _glKosVertexBufSwitchOP(); -// break; - -// case GL_DEPTH_TEST: -// GL_KOS_ENABLE_CAP &= ~GL_KOS_ENABLE_DEPTH_TEST; -// break; - -// case GL_LIGHTING: -// GL_KOS_ENABLE_CAP &= ~GL_KOS_ENABLE_LIGHTING; -// break; - -// case GL_KOS_NEARZ_CLIPPING: -// GL_KOS_ENABLE_CAP &= ~GL_KOS_ENABLE_ZCLIPPING; -// break; - -// case GL_SCISSOR_TEST: -// GL_KOS_ENABLE_CAP &= ~GL_KOS_ENABLE_SCISSOR_TEST; -// break; - -// case GL_FOG: -// GL_KOS_ENABLE_CAP &= ~GL_KOS_ENABLE_FOG; -// break; - -// case GL_CULL_FACE: -// GL_KOS_ENABLE_CAP &= ~GL_KOS_ENABLE_CULLING; -// break; - -// case GL_KOS_TEXTURE_MATRIX: -// GL_KOS_ENABLE_CAP &= ~GL_KOS_ENABLE_TEXTURE_MAT; -// break; -// } -//} - - -void APIENTRY glGetFloatv(GLenum pname, GLfloat *params) { - switch(pname) { - case GL_MODELVIEW_MATRIX: - case GL_PROJECTION_MATRIX: - case GL_TEXTURE_MATRIX: - glKosGetMatrix(pname - GL_MODELVIEW_MATRIX + 1, params); - break; - - default: - _glKosThrowError(GL_INVALID_ENUM, "glGetFloatv"); - _glKosPrintError(); - break; - } -} - -const GLbyte *glGetString(GLenum name) { - switch(name) { - case GL_VENDOR: - return "KallistiOS / Kazade"; - - case GL_RENDERER: - return "PowerVR2 CLX2 100mHz"; - - case GL_VERSION: - return "KGL 1.x"; - - case GL_EXTENSIONS: - return "GL_ARB_framebuffer_object, GL_ARB_multitexture, GL_ARB_texture_rg"; - } - - return "GL_KOS_ERROR: ENUM Unsupported\n"; -} - -//===============================================================================// -//== Internal API Functions ==// - -GLubyte _glKosEnabledDepthTest() { - return GL_KOS_ENABLE_CAP & GL_KOS_ENABLE_DEPTH_TEST; -} - -GLubyte _glKosEnabledScissorTest() { - return GL_KOS_ENABLE_CAP & GL_KOS_ENABLE_SCISSOR_TEST; -} - -GLubyte _glKosEnabledCulling() { - return GL_KOS_ENABLE_CAP & GL_KOS_ENABLE_CULLING; -} - -GLubyte _glKosEnabledFog() { - return GL_KOS_ENABLE_CAP & GL_KOS_ENABLE_FOG; -} - -GLubyte _glKosEnabledLighting() { - return GL_KOS_ENABLE_CAP & GL_KOS_ENABLE_LIGHTING; -} - -GLubyte _glKosEnabledNearZClip() { - return GL_KOS_ENABLE_CAP & GL_KOS_ENABLE_ZCLIPPING; -} - -GLubyte _glKosEnabledTexture2D() { - return GL_KOS_ENABLE_CAP & GL_KOS_ENABLE_TEXTURE2D; -} - -GLubyte _glKosEnabledBlend() { - return (GL_KOS_ENABLE_CAP & GL_KOS_ENABLE_BLENDING) >> 8; -} - -GLubyte _glKosEnabledTextureMatrix() { - return (GL_KOS_ENABLE_CAP & GL_KOS_ENABLE_TEXTURE_MAT) >> 9; -}