Formatting cleanup, and cleanup on gl-fog.c

This commit is contained in:
Josh Pearson 2015-09-09 11:25:51 -07:00
parent 46ed1d5353
commit 3df4244bc2
10 changed files with 197 additions and 248 deletions

View File

@ -267,8 +267,7 @@ void APIENTRY glColor4fv(const GLfloat *rgba) {
//== Texture Coordinate Submission ==// //== Texture Coordinate Submission ==//
void APIENTRY glTexCoord2f(GLfloat u, GLfloat v) { void APIENTRY glTexCoord2f(GLfloat u, GLfloat v) {
if(_glKosEnabledTextureMatrix()) if(_glKosEnabledTextureMatrix()) {
{
_glKosMatrixLoadTexture(); _glKosMatrixLoadTexture();
mat_trans_texture2_nomod(u, v, GL_KOS_VERTEX_UV[0], GL_KOS_VERTEX_UV[1]); mat_trans_texture2_nomod(u, v, GL_KOS_VERTEX_UV[0], GL_KOS_VERTEX_UV[1]);
@ -282,8 +281,7 @@ void APIENTRY glTexCoord2f(GLfloat u, GLfloat v) {
} }
void APIENTRY glTexCoord2fv(const GLfloat *uv) { void APIENTRY glTexCoord2fv(const GLfloat *uv) {
if(_glKosEnabledTextureMatrix()) if(_glKosEnabledTextureMatrix()) {
{
_glKosMatrixLoadTexture(); _glKosMatrixLoadTexture();
mat_trans_texture2_nomod(uv[0], uv[1], GL_KOS_VERTEX_UV[0], GL_KOS_VERTEX_UV[1]); mat_trans_texture2_nomod(uv[0], uv[1], GL_KOS_VERTEX_UV[0], GL_KOS_VERTEX_UV[1]);
@ -946,32 +944,26 @@ GLuint _glKosVertexColor() {
return GL_KOS_VERTEX_COLOR; return GL_KOS_VERTEX_COLOR;
} }
void glAlphaFunc(GLenum func, GLclampf ref) void glAlphaFunc(GLenum func, GLclampf ref) {
{
; ;
} }
void glLineWidth(GLfloat width) void glLineWidth(GLfloat width) {
{
; ;
} }
void glPolygonOffset(GLfloat factor, GLfloat units) void glPolygonOffset(GLfloat factor, GLfloat units) {
{
; ;
} }
void glGetTexParameteriv(GLenum target, GLenum pname, GLint * params) void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params) {
{
; ;
} }
void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
{
; ;
} }
void glPixelStorei(GLenum pname, GLint param) void glPixelStorei(GLenum pname, GLint param) {
{
; ;
} }

View File

@ -461,12 +461,10 @@ static inline void _glKosElementTexCoord2fU16(pvr_vertex_t *dst, GLuint count) {
GLuint i, index; GLuint i, index;
GLfloat *t = GL_KOS_TEXCOORD0_POINTER; GLfloat *t = GL_KOS_TEXCOORD0_POINTER;
if(_glKosEnabledTextureMatrix()) if(_glKosEnabledTextureMatrix()) {
{
_glKosMatrixLoadTexture(); _glKosMatrixLoadTexture();
for(i = 0; i < count; i++) for(i = 0; i < count; i++) {
{
index = GL_KOS_INDEX_POINTER_U16[i] * GL_KOS_TEXCOORD0_STRIDE; index = GL_KOS_INDEX_POINTER_U16[i] * GL_KOS_TEXCOORD0_STRIDE;
mat_trans_texture2_nomod(t[index], t[index + 1], dst[i].u, dst[i].v); mat_trans_texture2_nomod(t[index], t[index + 1], dst[i].u, dst[i].v);
@ -487,12 +485,10 @@ static inline void _glKosElementTexCoord2fU8(pvr_vertex_t *dst, GLuint count) {
GLuint i, index; GLuint i, index;
GLfloat *t = GL_KOS_TEXCOORD0_POINTER; GLfloat *t = GL_KOS_TEXCOORD0_POINTER;
if(_glKosEnabledTextureMatrix()) if(_glKosEnabledTextureMatrix()) {
{
_glKosMatrixLoadTexture(); _glKosMatrixLoadTexture();
for(i = 0; i < count; i++) for(i = 0; i < count; i++) {
{
index = GL_KOS_INDEX_POINTER_U8[i] * GL_KOS_TEXCOORD0_STRIDE; index = GL_KOS_INDEX_POINTER_U8[i] * GL_KOS_TEXCOORD0_STRIDE;
mat_trans_texture2_nomod(t[index], t[index + 1], dst[i].u, dst[i].v); mat_trans_texture2_nomod(t[index], t[index + 1], dst[i].u, dst[i].v);
@ -1051,12 +1047,10 @@ static inline void _glKosArrayTexCoord2f(pvr_vertex_t *dst, GLuint count) {
GLuint i; GLuint i;
GLfloat *uv = GL_KOS_TEXCOORD0_POINTER; GLfloat *uv = GL_KOS_TEXCOORD0_POINTER;
if(_glKosEnabledTextureMatrix()) if(_glKosEnabledTextureMatrix()) {
{
_glKosMatrixLoadTexture(); _glKosMatrixLoadTexture();
for(i = 0; i < count; i++) for(i = 0; i < count; i++) {
{
mat_trans_texture2_nomod(uv[0], uv[1], dst[i].u, dst[i].v); mat_trans_texture2_nomod(uv[0], uv[1], dst[i].u, dst[i].v);
uv += GL_KOS_TEXCOORD0_STRIDE; uv += GL_KOS_TEXCOORD0_STRIDE;
@ -1064,8 +1058,7 @@ static inline void _glKosArrayTexCoord2f(pvr_vertex_t *dst, GLuint count) {
_glKosMatrixLoadRender(); _glKosMatrixLoadRender();
} }
else else {
{
for(i = 0; i < count; i++) { for(i = 0; i < count; i++) {
dst[i].u = uv[0]; dst[i].u = uv[0];
dst[i].v = uv[1]; dst[i].v = uv[1];

View File

@ -228,10 +228,8 @@ void APIENTRY glGetFloatv(GLenum pname, GLfloat *params) {
} }
} }
const GLbyte* glGetString(GLenum name) const GLbyte *glGetString(GLenum name) {
{ switch(name) {
switch(name)
{
case GL_VENDOR: case GL_VENDOR:
return "KallistiOS"; return "KallistiOS";

View File

@ -11,92 +11,85 @@
#include "gl.h" #include "gl.h"
static GLuint FOG_MODE = GL_EXP; /* GL_LINEAR, GL_EXP, or GL_EXP2 FOG */ static GLuint GL_KOS_FOG_MODE = GL_EXP; /* GL_LINEAR, GL_EXP, or GL_EXP2 FOG */
static GLfloat FOG_DENSITY = 1.0f, /* Density - GL_EXP, or GL_EXP2 FOG */ static GLfloat GL_KOS_FOG_DENSITY = 1.0f, /* Density - GL_EXP, or GL_EXP2 FOG */
FOG_START = 0.0f, /* Linear FOG */ GL_KOS_FOG_START = 0.0f, /* Linear FOG */
FOG_END = 1.0f; /* Linear FOG */ GL_KOS_FOG_END = 1.0f; /* Linear FOG */
void APIENTRY glFogi(GLenum pname, GLint param) { void APIENTRY glFogi(GLenum pname, GLint param) {
switch(pname) { switch(pname) {
case GL_FOG_MODE: case GL_FOG_MODE:
switch(param) { switch(param) {
case GL_LINEAR: case GL_LINEAR:
return pvr_fog_table_linear(FOG_START, FOG_END); pvr_fog_table_linear(GL_KOS_FOG_START, GL_KOS_FOG_END);
break;
case GL_EXP: case GL_EXP:
return pvr_fog_table_exp(FOG_DENSITY); pvr_fog_table_exp(GL_KOS_FOG_DENSITY);
break;
case GL_EXP2: case GL_EXP2:
return pvr_fog_table_exp2(FOG_DENSITY); pvr_fog_table_exp2(GL_KOS_FOG_DENSITY);
break;
default:
return;
} }
default:
return;
} }
} }
void APIENTRY glFogf(GLenum pname, GLfloat param) { void APIENTRY glFogf(GLenum pname, GLfloat param) {
switch(pname) { switch(pname) {
case GL_FOG_START: case GL_FOG_START:
FOG_START = param; GL_KOS_FOG_START = param;
if(FOG_MODE == GL_LINEAR) if(GL_KOS_FOG_MODE == GL_LINEAR)
return pvr_fog_table_linear(FOG_START, FOG_END); pvr_fog_table_linear(GL_KOS_FOG_START, GL_KOS_FOG_END);
return; break;
case GL_FOG_END: case GL_FOG_END:
FOG_END = param; GL_KOS_FOG_END = param;
if(FOG_MODE == GL_LINEAR) if(GL_KOS_FOG_MODE == GL_LINEAR)
return pvr_fog_table_linear(FOG_START, FOG_END); pvr_fog_table_linear(GL_KOS_FOG_START, GL_KOS_FOG_END);
return; break;
case GL_FOG_DENSITY: case GL_FOG_DENSITY:
FOG_DENSITY = param; GL_KOS_FOG_DENSITY = param;
if(FOG_MODE == GL_EXP) if(GL_KOS_FOG_MODE == GL_EXP)
return pvr_fog_table_exp(FOG_DENSITY); pvr_fog_table_exp(GL_KOS_FOG_DENSITY);
if(FOG_MODE == GL_EXP2) else if(GL_KOS_FOG_MODE == GL_EXP2)
return pvr_fog_table_exp2(FOG_DENSITY); pvr_fog_table_exp2(GL_KOS_FOG_DENSITY);
return; break;
default:
return;
} }
} }
void APIENTRY glFogfv(GLenum pname, const GLfloat *params) { void APIENTRY glFogfv(GLenum pname, const GLfloat *params) {
switch(pname) { switch(pname) {
case GL_FOG_MODE: case GL_FOG_MODE:
return glFogi(pname, (GLint) * params); glFogi(pname, (GLint) * params);
break;
case GL_FOG_DENSITY: case GL_FOG_DENSITY:
FOG_DENSITY = *params; GL_KOS_FOG_DENSITY = *params;
if(FOG_MODE == GL_EXP) if(GL_KOS_FOG_MODE == GL_EXP)
return pvr_fog_table_exp(FOG_DENSITY); pvr_fog_table_exp(GL_KOS_FOG_DENSITY);
if(FOG_MODE == GL_EXP2) else if(GL_KOS_FOG_MODE == GL_EXP2)
return pvr_fog_table_exp2(FOG_DENSITY); pvr_fog_table_exp2(GL_KOS_FOG_DENSITY);
return; break;
case GL_FOG_START: case GL_FOG_START:
case GL_FOG_END: case GL_FOG_END:
return glFogf(pname, *params); glFogf(pname, *params);
break;
case GL_FOG_COLOR: case GL_FOG_COLOR:
return pvr_fog_table_color(params[3], params[0], params[1], params[2]); pvr_fog_table_color(params[3], params[0], params[1], params[2]);
break;
case GL_FOG_INDEX:
default:
return;
} }
} }

View File

@ -76,7 +76,7 @@ void _glKosEnableLight(const GLuint light) {
GL_LIGHT_ENABLED |= (1 << (light & 0xF)); GL_LIGHT_ENABLED |= (1 << (light & 0xF));
} }
/* Disable a light - GL_LIGHT0->GL_LIGHT7 */ /* Disable a light - GL_LIGHT0->GL_LIGHT0 + GL_KOS_MAX_LIGHTS */
void _glKosDisableLight(const GLuint light) { void _glKosDisableLight(const GLuint light) {
if(light < GL_LIGHT0 || light > GL_LIGHT0 + GL_KOS_MAX_LIGHTS) { if(light < GL_LIGHT0 || light > GL_LIGHT0 + GL_KOS_MAX_LIGHTS) {
_glKosThrowError(GL_INVALID_ENUM, "glDisable(GL_LIGHT)"); _glKosThrowError(GL_INVALID_ENUM, "glDisable(GL_LIGHT)");
@ -152,7 +152,7 @@ static inline void glCopy3f(const float *src, float *dst) {
/* GL Light Parameters ******************************************************/ /* GL Light Parameters ******************************************************/
void glLightfv(GLenum light, GLenum pname, const GLfloat *params) { void glLightfv(GLenum light, GLenum pname, const GLfloat *params) {
if(light < GL_LIGHT0 || light > GL_LIGHT7) return; if(light < GL_LIGHT0 || light > GL_LIGHT0 + GL_KOS_MAX_LIGHTS) return;
switch(pname) { switch(pname) {
case GL_AMBIENT: case GL_AMBIENT:
@ -217,7 +217,7 @@ void glLightfv(GLenum light, GLenum pname, const GLfloat *params) {
} }
void glLightf(GLenum light, GLenum pname, GLfloat param) { void glLightf(GLenum light, GLenum pname, GLfloat param) {
if(light < GL_LIGHT0 || light > GL_LIGHT7) return; if(light < GL_LIGHT0 || light > GL_LIGHT0 + GL_KOS_MAX_LIGHTS) return;
switch(pname) { switch(pname) {
case GL_CONSTANT_ATTENUATION: case GL_CONSTANT_ATTENUATION:

View File

@ -119,37 +119,33 @@ uint16 __glKosAverageBiPixelARGB4444(uint16 p1, uint16 p2) {
//===================================================================================================// //===================================================================================================//
//== Colorspace Conversion ==// //== Colorspace Conversion ==//
static uint16 _glConvPixelRGBAU32(uint8 r, uint8 g, uint8 b, uint8 a) static uint16 _glConvPixelRGBAU32(uint8 r, uint8 g, uint8 b, uint8 a) {
{
return (uint16)((a & RGB4_MAX) << ARGB4444_ALPHA_SHIFT) | return (uint16)((a & RGB4_MAX) << ARGB4444_ALPHA_SHIFT) |
((r & RGB4_MAX) << ARGB4444_RED_SHIFT) | ((r & RGB4_MAX) << ARGB4444_RED_SHIFT) |
((g & RGB4_MAX) << ARGB4444_GREEN_SHIFT) | ((g & RGB4_MAX) << ARGB4444_GREEN_SHIFT) |
((b & RGB4_MAX)); ((b & RGB4_MAX));
} }
static uint16 _glConvPixelRGBU24(uint8 r, uint8 g, uint8 b) static uint16 _glConvPixelRGBU24(uint8 r, uint8 g, uint8 b) {
{
return (uint16)((r & RGB5_MAX) << RGB565_RED_SHIFT) | return (uint16)((r & RGB5_MAX) << RGB565_RED_SHIFT) |
((g & RGB6_MAX) << RGB565_GREEN_SHIFT) | ((g & RGB6_MAX) << RGB565_GREEN_SHIFT) |
((b & RGB5_MAX)); ((b & RGB5_MAX));
} }
static void _glConvPixelsRGBF(int w, int h, float * src, uint16 * dst) static void _glConvPixelsRGBF(int w, int h, float *src, uint16 *dst) {
{
int i; int i;
for(i = 0; i < w * h; i++)
{ for(i = 0; i < w * h; i++) {
dst[i] = _glConvPixelRGBU24((uint8)(src[i * 3 + 0] * RGB5_MAX), dst[i] = _glConvPixelRGBU24((uint8)(src[i * 3 + 0] * RGB5_MAX),
(uint8)(src[i * 3 + 1] * RGB6_MAX), (uint8)(src[i * 3 + 1] * RGB6_MAX),
(uint8)(src[i * 3 + 2] * RGB5_MAX)); (uint8)(src[i * 3 + 2] * RGB5_MAX));
} }
} }
static void _glConvPixelsRGBAF(int w, int h, float * src, uint16 * dst) static void _glConvPixelsRGBAF(int w, int h, float *src, uint16 *dst) {
{
int i; int i;
for(i = 0; i < w * h; i++)
{ for(i = 0; i < w * h; i++) {
dst[i] = _glConvPixelRGBAU32((uint8)(src[i * 4 + 0] * RGB4_MAX), dst[i] = _glConvPixelRGBAU32((uint8)(src[i * 4 + 0] * RGB4_MAX),
(uint8)(src[i * 4 + 1] * RGB4_MAX), (uint8)(src[i * 4 + 1] * RGB4_MAX),
(uint8)(src[i * 4 + 2] * RGB4_MAX), (uint8)(src[i * 4 + 2] * RGB4_MAX),
@ -157,13 +153,11 @@ static void _glConvPixelsRGBAF(int w, int h, float * src, uint16 * dst)
} }
} }
static void _glConvPixelsRGBU24(int w, int h, uint8 * src, uint16 * dst) static void _glConvPixelsRGBU24(int w, int h, uint8 *src, uint16 *dst) {
{
unsigned char r, g, b; unsigned char r, g, b;
int i; int i;
for(i = 0; i < w * h; i++) for(i = 0; i < w * h; i++) {
{
r = (src[i * 3 + 0] * RGB5_MAX) / RGB8_MAX; r = (src[i * 3 + 0] * RGB5_MAX) / RGB8_MAX;
g = (src[i * 3 + 1] * RGB6_MAX) / RGB8_MAX; g = (src[i * 3 + 1] * RGB6_MAX) / RGB8_MAX;
b = (src[i * 3 + 2] * RGB5_MAX) / RGB8_MAX; b = (src[i * 3 + 2] * RGB5_MAX) / RGB8_MAX;
@ -172,13 +166,11 @@ static void _glConvPixelsRGBU24(int w, int h, uint8 * src, uint16 * dst)
} }
} }
static void _glConvPixelsRGBAU32(int w, int h, uint8 * src, uint16 * dst) static void _glConvPixelsRGBAU32(int w, int h, uint8 *src, uint16 *dst) {
{
unsigned char r, g, b, a; unsigned char r, g, b, a;
int i; int i;
for(i = 0; i < w * h; i++) for(i = 0; i < w * h; i++) {
{
r = (src[i * 4 + 0] * RGB4_MAX) / RGB8_MAX; r = (src[i * 4 + 0] * RGB4_MAX) / RGB8_MAX;
g = (src[i * 4 + 1] * RGB4_MAX) / RGB8_MAX; g = (src[i * 4 + 1] * RGB4_MAX) / RGB8_MAX;
b = (src[i * 4 + 2] * RGB4_MAX) / RGB8_MAX; b = (src[i * 4 + 2] * RGB4_MAX) / RGB8_MAX;
@ -188,13 +180,11 @@ static void _glConvPixelsRGBAU32(int w, int h, uint8 * src, uint16 * dst)
} }
} }
static void _glConvPixelsRGBS24(int w, int h, int8 * src, uint16 * dst) static void _glConvPixelsRGBS24(int w, int h, int8 *src, uint16 *dst) {
{
unsigned char r, g, b; unsigned char r, g, b;
int i; int i;
for(i = 0; i < w * h; i++) for(i = 0; i < w * h; i++) {
{
r = ((src[i * 3 + 0] + S8_NEG_OFT) * RGB5_MAX) / RGB8_MAX; r = ((src[i * 3 + 0] + S8_NEG_OFT) * RGB5_MAX) / RGB8_MAX;
g = ((src[i * 3 + 1] + S8_NEG_OFT) * RGB6_MAX) / RGB8_MAX; g = ((src[i * 3 + 1] + S8_NEG_OFT) * RGB6_MAX) / RGB8_MAX;
b = ((src[i * 3 + 2] + S8_NEG_OFT) * RGB5_MAX) / RGB8_MAX; b = ((src[i * 3 + 2] + S8_NEG_OFT) * RGB5_MAX) / RGB8_MAX;
@ -203,13 +193,11 @@ static void _glConvPixelsRGBS24(int w, int h, int8 * src, uint16 * dst)
} }
} }
static void _glConvPixelsRGBAS32(int w, int h, int8 * src, uint16 * dst) static void _glConvPixelsRGBAS32(int w, int h, int8 *src, uint16 *dst) {
{
unsigned char r, g, b, a; unsigned char r, g, b, a;
int i; int i;
for(i = 0; i < w * h; i++) for(i = 0; i < w * h; i++) {
{
r = ((src[i * 4 + 0] + S8_NEG_OFT) * RGB4_MAX) / RGB8_MAX; r = ((src[i * 4 + 0] + S8_NEG_OFT) * RGB4_MAX) / RGB8_MAX;
g = ((src[i * 4 + 1] + S8_NEG_OFT) * RGB4_MAX) / RGB8_MAX; g = ((src[i * 4 + 1] + S8_NEG_OFT) * RGB4_MAX) / RGB8_MAX;
b = ((src[i * 4 + 2] + S8_NEG_OFT) * RGB4_MAX) / RGB8_MAX; b = ((src[i * 4 + 2] + S8_NEG_OFT) * RGB4_MAX) / RGB8_MAX;
@ -219,13 +207,11 @@ static void _glConvPixelsRGBAS32(int w, int h, int8 * src, uint16 * dst)
} }
} }
static void _glConvPixelsRGBS48(int w, int h, int16 * src, uint16 * dst) static void _glConvPixelsRGBS48(int w, int h, int16 *src, uint16 *dst) {
{
unsigned char r, g, b; unsigned char r, g, b;
int i; int i;
for(i = 0; i < w * h; i++) for(i = 0; i < w * h; i++) {
{
r = ((src[i * 3 + 0] + S16_NEG_OFT) * RGB5_MAX) / RGB16_MAX; r = ((src[i * 3 + 0] + S16_NEG_OFT) * RGB5_MAX) / RGB16_MAX;
g = ((src[i * 3 + 1] + S16_NEG_OFT) * RGB6_MAX) / RGB16_MAX; g = ((src[i * 3 + 1] + S16_NEG_OFT) * RGB6_MAX) / RGB16_MAX;
b = ((src[i * 3 + 2] + S16_NEG_OFT) * RGB5_MAX) / RGB16_MAX; b = ((src[i * 3 + 2] + S16_NEG_OFT) * RGB5_MAX) / RGB16_MAX;
@ -234,13 +220,11 @@ static void _glConvPixelsRGBS48(int w, int h, int16 * src, uint16 * dst)
} }
} }
static void _glConvPixelsRGBAS64(int w, int h, int16 * src, uint16 * dst) static void _glConvPixelsRGBAS64(int w, int h, int16 *src, uint16 *dst) {
{
unsigned char r, g, b, a; unsigned char r, g, b, a;
int i; int i;
for(i = 0; i < w * h; i++) for(i = 0; i < w * h; i++) {
{
r = ((src[i * 4 + 0] + S16_NEG_OFT) * RGB4_MAX) / RGB16_MAX; r = ((src[i * 4 + 0] + S16_NEG_OFT) * RGB4_MAX) / RGB16_MAX;
g = ((src[i * 4 + 1] + S16_NEG_OFT) * RGB4_MAX) / RGB16_MAX; g = ((src[i * 4 + 1] + S16_NEG_OFT) * RGB4_MAX) / RGB16_MAX;
b = ((src[i * 4 + 2] + S16_NEG_OFT) * RGB4_MAX) / RGB16_MAX; b = ((src[i * 4 + 2] + S16_NEG_OFT) * RGB4_MAX) / RGB16_MAX;
@ -250,13 +234,11 @@ static void _glConvPixelsRGBAS64(int w, int h, int16 * src, uint16 * dst)
} }
} }
static void _glConvPixelsRGBU48(int w, int h, uint16 * src, uint16 * dst) static void _glConvPixelsRGBU48(int w, int h, uint16 *src, uint16 *dst) {
{
unsigned char r, g, b; unsigned char r, g, b;
int i; int i;
for(i = 0; i < w * h; i++) for(i = 0; i < w * h; i++) {
{
r = ((src[i * 3 + 0]) * RGB5_MAX) / RGB16_MAX; r = ((src[i * 3 + 0]) * RGB5_MAX) / RGB16_MAX;
g = ((src[i * 3 + 1]) * RGB6_MAX) / RGB16_MAX; g = ((src[i * 3 + 1]) * RGB6_MAX) / RGB16_MAX;
b = ((src[i * 3 + 2]) * RGB5_MAX) / RGB16_MAX; b = ((src[i * 3 + 2]) * RGB5_MAX) / RGB16_MAX;
@ -265,13 +247,11 @@ static void _glConvPixelsRGBU48(int w, int h, uint16 * src, uint16 * dst)
} }
} }
static void _glConvPixelsRGBAU64(int w, int h, uint16 * src, uint16 * dst) static void _glConvPixelsRGBAU64(int w, int h, uint16 *src, uint16 *dst) {
{
unsigned char r, g, b, a; unsigned char r, g, b, a;
int i; int i;
for(i = 0; i < w * h; i++) for(i = 0; i < w * h; i++) {
{
r = (src[i * 4 + 0] * RGB4_MAX) / RGB16_MAX; r = (src[i * 4 + 0] * RGB4_MAX) / RGB16_MAX;
g = (src[i * 4 + 1] * RGB4_MAX) / RGB16_MAX; g = (src[i * 4 + 1] * RGB4_MAX) / RGB16_MAX;
b = (src[i * 4 + 2] * RGB4_MAX) / RGB16_MAX; b = (src[i * 4 + 2] * RGB4_MAX) / RGB16_MAX;
@ -281,10 +261,8 @@ static void _glConvPixelsRGBAU64(int w, int h, uint16 * src, uint16 * dst)
} }
} }
void _glPixelConvertRGB(int format, int w, int h, void * src, uint16 * dst) void _glPixelConvertRGB(int format, int w, int h, void *src, uint16 *dst) {
{ switch(format) {
switch(format)
{
case GL_BYTE: case GL_BYTE:
_glConvPixelsRGBS24(w, h, (int8 *)src, dst); _glConvPixelsRGBS24(w, h, (int8 *)src, dst);
break; break;
@ -307,10 +285,8 @@ void _glPixelConvertRGB(int format, int w, int h, void * src, uint16 * dst)
} }
} }
void _glPixelConvertRGBA(int format, int w, int h, void * src, uint16 * dst) void _glPixelConvertRGBA(int format, int w, int h, void *src, uint16 *dst) {
{ switch(format) {
switch(format)
{
case GL_BYTE: case GL_BYTE:
_glConvPixelsRGBAS32(w, h, (int8 *)src, dst); _glConvPixelsRGBAS32(w, h, (int8 *)src, dst);
break; break;

View File

@ -254,27 +254,24 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->data = pvr_mem_malloc(bytes); GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->data = pvr_mem_malloc(bytes);
if(data) if(data) {
{ switch(type) {
switch(type)
{
case GL_BYTE: /* Texture Formats that need conversion for PVR */ case GL_BYTE: /* Texture Formats that need conversion for PVR */
case GL_UNSIGNED_BYTE: case GL_UNSIGNED_BYTE:
case GL_SHORT: case GL_SHORT:
case GL_UNSIGNED_SHORT: case GL_UNSIGNED_SHORT:
case GL_FLOAT: case GL_FLOAT: {
{
uint16 *tex; uint16 *tex;
tex = (uint16 *)malloc(width * height * sizeof(uint16)); tex = (uint16 *)malloc(width * height * sizeof(uint16));
if(!tex) { if(!tex) {
_glKosThrowError(GL_OUT_OF_MEMORY, "glTexImage2D"); _glKosThrowError(GL_OUT_OF_MEMORY, "glTexImage2D");
_glKosPrintError(); _glKosPrintError();
return; return;
} }
switch(internalFormat) switch(internalFormat) {
{
case GL_RGB: case GL_RGB:
_glPixelConvertRGB(type, width, height, (void *)data, tex); _glPixelConvertRGB(type, width, height, (void *)data, tex);
GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->color = (PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED); GL_KOS_TEXTURE_UNIT[GL_KOS_ACTIVE_TEXTURE]->color = (PVR_TXRFMT_RGB565 | PVR_TXRFMT_NONTWIDDLED);