Add glGetFloatv() for reading matrices as requested in #dreamcastdev on IRC.

This commit also adds a new glKosGetMatrix() function that does the same thing,
but isn't limited to the modelview, projection, and texture matrices, as
glGetFloatv() is.
This commit is contained in:
Lawrence Sebald 2014-08-29 15:38:42 -04:00
parent 0711f10b1f
commit 61b809f5cd
3 changed files with 32 additions and 1 deletions

View File

@ -1,7 +1,8 @@
/* KallistiGL for KallistiOS ##version##
libgl/gl.h
libgl/gl-api.c
Copyright (C) 2013-2014 Josh "PH3NOM" Pearson
Copyright (C) 2014 Lawrence Sebald
Some functionality adapted from the original KOS libgl:
Copyright (C) 2001 Dan Potter
@ -161,6 +162,20 @@ void glGetIntegerv(GLenum pname, GLint *params) {
}
}
void 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:
*params = (GLfloat)GL_INVALID_ENUM;
break;
}
}
static void _glKosInitTextures() {
GLuint i;

View File

@ -2,6 +2,7 @@
libgl/gl-matrix.c
Copyright (C) 2013-2014 Josh "PH3NOM" Pearson
Copyright (C) 2014 Lawrence Sebald
Some functionality adapted from the original KOS libgl:
Copyright (C) 2001 Dan Potter
@ -393,3 +394,10 @@ void _glKosInitMatrix() {
glDepthRange(0.0f, 1.0f);
glViewport(0, 0, vid_mode->width, vid_mode->height);
}
void glKosGetMatrix(GLenum mode, GLfloat *params) {
if(mode < GL_SCREENVIEW || mode > GL_RENDER)
*params = (GLfloat)GL_INVALID_ENUM;
memcpy(params, Matrix + mode, sizeof(GLfloat) * 16);
}

View File

@ -2,6 +2,7 @@
libgl/gl.h
Copyright (C) 2013-2014 Josh "PH3NOM" Pearson
Copyright (C) 2014 Lawrence Sebald
Some functionality adapted from the original KOS libgl:
Copyright (C) 2001 Dan Potter
@ -63,6 +64,10 @@ __BEGIN_DECLS
#define GL_RENDER 0x05
#define GL_MATRIX_COUNT 0x06
#define GL_MODELVIEW_MATRIX 0x0BA6
#define GL_PROJECTION_MATRIX 0x0BA7
#define GL_TEXTURE_MATRIX 0x0BA8
/* Depth buffer */
#define GL_NEVER 0x0200
#define GL_LESS 0x0201
@ -478,6 +483,8 @@ GLAPI void APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
GLAPI void APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
GLAPI void APIENTRY glKosGetMatrix(GLenum mode, GLfloat *params);
/* Fog Functions - client must enable GL_FOG for this to take effect */
GLAPI void APIENTRY glFogi(GLenum pname, GLint param);
@ -506,6 +513,7 @@ GLAPI GLuint APIENTRY glKosMipMapTexSize(GLuint width, GLuint height);
/* glGet Functions */
void glGetIntegerv(GLenum pname, GLint *params);
void glGetFloatv(GLenum pname, GLfloat *params);
/* Multi-Texture Extensions */
GLAPI void APIENTRY glActiveTexture(GLenum texture);