2014-08-29 19:56:23 +00:00
|
|
|
/* KallistiGL for KallistiOS ##version##
|
|
|
|
|
|
|
|
libgl/gl-fog.c
|
2014-09-29 02:40:41 +00:00
|
|
|
Copyright (C) 2013-2014 Josh Pearson
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
Functionality adapted from the original KOS libgl fog code:
|
|
|
|
Copyright (C) 2002 Benoit Miller
|
|
|
|
|
|
|
|
OpenGL Fog - Wrapper for the PowerVR fog functions in KOS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gl.h"
|
|
|
|
|
2015-09-09 18:25:51 +00:00
|
|
|
static GLuint GL_KOS_FOG_MODE = GL_EXP; /* GL_LINEAR, GL_EXP, or GL_EXP2 FOG */
|
|
|
|
static GLfloat GL_KOS_FOG_DENSITY = 1.0f, /* Density - GL_EXP, or GL_EXP2 FOG */
|
|
|
|
GL_KOS_FOG_START = 0.0f, /* Linear FOG */
|
|
|
|
GL_KOS_FOG_END = 1.0f; /* Linear FOG */
|
2014-08-29 19:56:23 +00:00
|
|
|
|
2014-09-29 02:40:41 +00:00
|
|
|
void APIENTRY glFogi(GLenum pname, GLint param) {
|
2014-08-29 19:56:23 +00:00
|
|
|
switch(pname) {
|
|
|
|
case GL_FOG_MODE:
|
|
|
|
switch(param) {
|
|
|
|
case GL_LINEAR:
|
2015-09-09 18:25:51 +00:00
|
|
|
pvr_fog_table_linear(GL_KOS_FOG_START, GL_KOS_FOG_END);
|
|
|
|
break;
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
case GL_EXP:
|
2015-09-09 18:25:51 +00:00
|
|
|
pvr_fog_table_exp(GL_KOS_FOG_DENSITY);
|
|
|
|
break;
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
case GL_EXP2:
|
2015-09-09 18:25:51 +00:00
|
|
|
pvr_fog_table_exp2(GL_KOS_FOG_DENSITY);
|
|
|
|
break;
|
2014-08-29 19:56:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-29 02:40:41 +00:00
|
|
|
void APIENTRY glFogf(GLenum pname, GLfloat param) {
|
2014-08-29 19:56:23 +00:00
|
|
|
switch(pname) {
|
|
|
|
case GL_FOG_START:
|
2015-09-09 18:25:51 +00:00
|
|
|
GL_KOS_FOG_START = param;
|
2014-08-29 19:56:23 +00:00
|
|
|
|
2015-09-09 18:25:51 +00:00
|
|
|
if(GL_KOS_FOG_MODE == GL_LINEAR)
|
|
|
|
pvr_fog_table_linear(GL_KOS_FOG_START, GL_KOS_FOG_END);
|
2014-08-29 19:56:23 +00:00
|
|
|
|
2015-09-09 18:25:51 +00:00
|
|
|
break;
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
case GL_FOG_END:
|
2015-09-09 18:25:51 +00:00
|
|
|
GL_KOS_FOG_END = param;
|
2014-08-29 19:56:23 +00:00
|
|
|
|
2015-09-09 18:25:51 +00:00
|
|
|
if(GL_KOS_FOG_MODE == GL_LINEAR)
|
|
|
|
pvr_fog_table_linear(GL_KOS_FOG_START, GL_KOS_FOG_END);
|
2014-08-29 19:56:23 +00:00
|
|
|
|
2015-09-09 18:25:51 +00:00
|
|
|
break;
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
case GL_FOG_DENSITY:
|
2015-09-09 18:25:51 +00:00
|
|
|
GL_KOS_FOG_DENSITY = param;
|
2014-08-29 19:56:23 +00:00
|
|
|
|
2015-09-09 18:25:51 +00:00
|
|
|
if(GL_KOS_FOG_MODE == GL_EXP)
|
|
|
|
pvr_fog_table_exp(GL_KOS_FOG_DENSITY);
|
2014-08-29 19:56:23 +00:00
|
|
|
|
2015-09-09 18:25:51 +00:00
|
|
|
else if(GL_KOS_FOG_MODE == GL_EXP2)
|
|
|
|
pvr_fog_table_exp2(GL_KOS_FOG_DENSITY);
|
2014-08-29 19:56:23 +00:00
|
|
|
|
2015-09-09 18:25:51 +00:00
|
|
|
break;
|
2014-08-29 19:56:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-29 02:40:41 +00:00
|
|
|
void APIENTRY glFogfv(GLenum pname, const GLfloat *params) {
|
2014-08-29 19:56:23 +00:00
|
|
|
switch(pname) {
|
|
|
|
case GL_FOG_MODE:
|
2015-09-09 18:25:51 +00:00
|
|
|
glFogi(pname, (GLint) * params);
|
|
|
|
break;
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
case GL_FOG_DENSITY:
|
2015-09-09 18:25:51 +00:00
|
|
|
GL_KOS_FOG_DENSITY = *params;
|
2014-08-29 19:56:23 +00:00
|
|
|
|
2015-09-09 18:25:51 +00:00
|
|
|
if(GL_KOS_FOG_MODE == GL_EXP)
|
|
|
|
pvr_fog_table_exp(GL_KOS_FOG_DENSITY);
|
2014-08-29 19:56:23 +00:00
|
|
|
|
2015-09-09 18:25:51 +00:00
|
|
|
else if(GL_KOS_FOG_MODE == GL_EXP2)
|
|
|
|
pvr_fog_table_exp2(GL_KOS_FOG_DENSITY);
|
2014-08-29 19:56:23 +00:00
|
|
|
|
2015-09-09 18:25:51 +00:00
|
|
|
break;
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
case GL_FOG_START:
|
|
|
|
case GL_FOG_END:
|
2015-09-09 18:25:51 +00:00
|
|
|
glFogf(pname, *params);
|
|
|
|
break;
|
2014-08-29 19:56:23 +00:00
|
|
|
|
|
|
|
case GL_FOG_COLOR:
|
2015-09-09 18:25:51 +00:00
|
|
|
pvr_fog_table_color(params[3], params[0], params[1], params[2]);
|
|
|
|
break;
|
2014-08-29 19:56:23 +00:00
|
|
|
}
|
|
|
|
}
|