GSGLTetrakis
This commit is contained in:
parent
f325b6c303
commit
cf213a68fe
8 changed files with 92 additions and 6 deletions
|
|
@ -44,6 +44,16 @@ static GSModel model = NULL;
|
||||||
|
|
||||||
static void render(GSEngine self){
|
static void render(GSEngine self){
|
||||||
GSGL gl = GSClientGetGL(GSEngineGetClient(self));
|
GSGL gl = GSClientGetGL(GSEngineGetClient(self));
|
||||||
|
GSVector3 v[] = {
|
||||||
|
{-5, -2, 5},
|
||||||
|
{-5, -2, -5},
|
||||||
|
{5, -2, -5},
|
||||||
|
{5, -2, 5}
|
||||||
|
};
|
||||||
|
GSVector3 n = {0, 1, 0};
|
||||||
|
GSVector4 col = {1, 1, 1, 1};
|
||||||
|
GSVector4 col2 = {1, 0, 0, 1};
|
||||||
|
int i, j;
|
||||||
|
|
||||||
pos[1] = 0;
|
pos[1] = 0;
|
||||||
|
|
||||||
|
|
@ -60,6 +70,25 @@ static void render(GSEngine self){
|
||||||
GSGLSetRotation(gl, rot);
|
GSGLSetRotation(gl, rot);
|
||||||
if(model != NULL) GSModelDraw(model);
|
if(model != NULL) GSModelDraw(model);
|
||||||
GSGLPopMatrix(gl);
|
GSGLPopMatrix(gl);
|
||||||
|
|
||||||
|
for(i = -1; i <= 1; i++){
|
||||||
|
for(j = -1; j <= 1; j++){
|
||||||
|
GSVector3 pos2;
|
||||||
|
|
||||||
|
pos2[0] = i;
|
||||||
|
pos2[1] = 0;
|
||||||
|
pos2[2] = j;
|
||||||
|
|
||||||
|
GSGLPushMatrix(gl);
|
||||||
|
GSGLSetPosition(gl, pos2);
|
||||||
|
GSGLSetRotation(gl, rot);
|
||||||
|
GSGLTetrakis(gl, 0.5, col, col2);
|
||||||
|
GSGLPopMatrix(gl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GSGLSetColor(gl, col);
|
||||||
|
GSGLPolygon(gl, 4, v, NULL, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void after_render(GSEngine self){
|
static void after_render(GSEngine self){
|
||||||
|
|
@ -101,7 +130,7 @@ int main(int argc, char** argv){
|
||||||
|
|
||||||
GSClientSetSkybox(GSEngineGetClient(engine), GSTrue);
|
GSClientSetSkybox(GSEngineGetClient(engine), GSTrue);
|
||||||
|
|
||||||
if((sound = GSSoundOpen(GSClientGetSoundEngine(GSEngineGetClient(engine)), "game:/df97.xm")) != NULL){
|
if((sound = GSSoundOpen(GSClientGetSoundEngine(GSEngineGetClient(engine)), "game:/2nd_pm.xm")) != NULL){
|
||||||
GSSoundSetLoop(sound, 1);
|
GSSoundSetLoop(sound, 1);
|
||||||
GSSoundStart(sound);
|
GSSoundStart(sound);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ varying vec4 vColor;
|
||||||
uniform sampler2D depth_texture;
|
uniform sampler2D depth_texture;
|
||||||
uniform sampler2D current_texture;
|
uniform sampler2D current_texture;
|
||||||
uniform float enable_lighting;
|
uniform float enable_lighting;
|
||||||
|
uniform float enable_texture;
|
||||||
|
|
||||||
vec4 PhongShading(void)
|
vec4 PhongShading(void)
|
||||||
{
|
{
|
||||||
|
|
@ -67,8 +68,9 @@ void main(void){
|
||||||
vec4 ambient = gl_LightSource[0].ambient;
|
vec4 ambient = gl_LightSource[0].ambient;
|
||||||
float shadow_coef = ShadowCoef();
|
float shadow_coef = ShadowCoef();
|
||||||
|
|
||||||
c = c * texture2D(current_texture, gl_TexCoord[0].st);
|
if(enable_texture >= 0.5){
|
||||||
|
c = c * texture2D(current_texture, gl_TexCoord[0].st);
|
||||||
|
}
|
||||||
|
|
||||||
gl_FragColor = ambient * shadow_coef * c + (1.0 - ambient) * c;
|
gl_FragColor = ambient * shadow_coef * c + (1.0 - ambient) * c;
|
||||||
gl_FragColor.a = 1.0;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ GSDECL void GSGLTextEx(GSGL gl, GSNumber x, GSNumber y, const char* text, GSNu
|
||||||
GSDECL void GSGLText(GSGL gl, GSNumber x, GSNumber y, const char* text);
|
GSDECL void GSGLText(GSGL gl, GSNumber x, GSNumber y, const char* text);
|
||||||
GSDECL double GSGLTextWidth(GSGL gl, const char* text);
|
GSDECL double GSGLTextWidth(GSGL gl, const char* text);
|
||||||
GSDECL double GSGLTextHeight(GSGL gl, const char* text);
|
GSDECL double GSGLTextHeight(GSGL gl, const char* text);
|
||||||
|
GSDECL void GSGLTetrakis(GSGL gl, GSNumber scale, GSVector4 col1, GSVector4 col2);
|
||||||
|
|
||||||
/* gl_shadow.c */
|
/* gl_shadow.c */
|
||||||
GSDECL void GSGLShadowInit(GSGL gl);
|
GSDECL void GSGLShadowInit(GSGL gl);
|
||||||
|
|
|
||||||
|
|
@ -96,8 +96,14 @@ void GSClientDestroy(GSClient client) {
|
||||||
free(client);
|
free(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GSVector4 white = {1, 1, 1, 1};
|
||||||
|
|
||||||
static void scene(GSClient client) {
|
static void scene(GSClient client) {
|
||||||
|
GSGLSetColor(client->gl, white);
|
||||||
|
|
||||||
if(client->engine->param->render != NULL) client->engine->param->render(client->engine);
|
if(client->engine->param->render != NULL) client->engine->param->render(client->engine);
|
||||||
|
|
||||||
|
GSGLSetColor(client->gl, white);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSClientStep(GSClient client) {
|
void GSClientStep(GSClient client) {
|
||||||
|
|
@ -107,7 +113,6 @@ void GSClientStep(GSClient client) {
|
||||||
char buf[512];
|
char buf[512];
|
||||||
char buf2[512];
|
char buf2[512];
|
||||||
GSVersion ver;
|
GSVersion ver;
|
||||||
GSVector4 white = {1, 1, 1, 1};
|
|
||||||
GSVector4 yellow = {1, 1, 0, 1};
|
GSVector4 yellow = {1, 1, 0, 1};
|
||||||
GSVector4 half = {0, 0, 0, 0.5};
|
GSVector4 half = {0, 0, 0, 0.5};
|
||||||
GSVector2 sq[4];
|
GSVector2 sq[4];
|
||||||
|
|
@ -116,7 +121,6 @@ void GSClientStep(GSClient client) {
|
||||||
GSGLClear(client->gl);
|
GSGLClear(client->gl);
|
||||||
GSGLCameraSetup(client->gl);
|
GSGLCameraSetup(client->gl);
|
||||||
GSGLSetLight(client->gl);
|
GSGLSetLight(client->gl);
|
||||||
GSGLSetColor(client->gl, white);
|
|
||||||
|
|
||||||
GSGLTextBold(client->gl, 0);
|
GSGLTextBold(client->gl, 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ void GSGLEnd2D(GSGL gl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSGLSetPosition(GSGL gl, GSVector3 pos) {
|
void GSGLSetPosition(GSGL gl, GSVector3 pos) {
|
||||||
glTranslatef(pos[0], pos[1], pos[2]);
|
glTranslatef(pos[0], pos[1], -pos[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSGLSetRotation(GSGL gl, GSVector3 rot) {
|
void GSGLSetRotation(GSGL gl, GSVector3 rot) {
|
||||||
|
|
|
||||||
|
|
@ -172,3 +172,44 @@ void GSGLTexturePrepareEx(GSGL gl, GLuint* texture, unsigned char* rgba, int wid
|
||||||
void GSGLTexturePrepare(GSGL gl, GLuint* texture, unsigned char* rgba, int width, int height) {
|
void GSGLTexturePrepare(GSGL gl, GLuint* texture, unsigned char* rgba, int width, int height) {
|
||||||
GSGLTexturePrepareEx(gl, texture, rgba, width, height, 1);
|
GSGLTexturePrepareEx(gl, texture, rgba, width, height, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* who even uses this other than second reality? :) */
|
||||||
|
void GSGLTetrakis(GSGL gl, GSNumber scale, GSVector4 col1, GSVector4 col2) {
|
||||||
|
GSVector3 v[] = {
|
||||||
|
{0, 1, 0},
|
||||||
|
{-0.75, 0.75, -0.75},
|
||||||
|
{0.75, 0.75, -0.75}};
|
||||||
|
GSVector3 n;
|
||||||
|
GSVector3 rot2 = {0, 90, 0};
|
||||||
|
GSVector3 rot3 = {0, 0, 90};
|
||||||
|
GSVector3 rot4 = {90, 0, 0};
|
||||||
|
int i, j, k = 0;
|
||||||
|
|
||||||
|
for(i = 0; i < 3; i++) {
|
||||||
|
for(j = 0; j < 3; j++) v[i][j] *= scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
GSMathNormal3x3(n, v[0], v[1], v[2]);
|
||||||
|
|
||||||
|
GSGLPushMatrix(gl);
|
||||||
|
for(i = 0; i < 6; i++) {
|
||||||
|
for(j = 0; j < 4; j++) {
|
||||||
|
GSGLSetColor(gl, ((k + j) % 2) ? col2 : col1);
|
||||||
|
GSGLPolygon(gl, 3, v, NULL, n);
|
||||||
|
|
||||||
|
GSGLSetRotation(gl, rot2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(i == 3) {
|
||||||
|
GSGLSetRotation(gl, rot4);
|
||||||
|
k++;
|
||||||
|
} else if(i == 4) {
|
||||||
|
GSGLSetRotation(gl, rot4);
|
||||||
|
GSGLSetRotation(gl, rot4);
|
||||||
|
} else {
|
||||||
|
GSGLSetRotation(gl, rot3);
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GSGLPopMatrix(gl);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ void GSGLShadowInit(GSGL gl) {
|
||||||
glUniform1i(glGetUniformLocation(gl->shadow_shader, "depth_texture"), 7);
|
glUniform1i(glGetUniformLocation(gl->shadow_shader, "depth_texture"), 7);
|
||||||
glUniform1i(glGetUniformLocation(gl->shadow_shader, "current_texture"), 0);
|
glUniform1i(glGetUniformLocation(gl->shadow_shader, "current_texture"), 0);
|
||||||
glUniform1f(glGetUniformLocation(gl->shadow_shader, "enable_lighting"), 1);
|
glUniform1f(glGetUniformLocation(gl->shadow_shader, "enable_lighting"), 1);
|
||||||
|
glUniform1f(glGetUniformLocation(gl->shadow_shader, "enable_texture"), 0);
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
|
|
||||||
gl->shadow_use_shader = 1;
|
gl->shadow_use_shader = 1;
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,16 @@ void GSGLTextureSet(GSGL gl, GLuint texture) {
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
if(texture == 0) {
|
if(texture == 0) {
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
if(gl->shadow_use_shader) {
|
||||||
|
glUniform1f(glGetUniformLocation(gl->shadow_shader, "enable_texture"), 0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
if(gl->shadow_use_shader) {
|
||||||
|
glUniform1f(glGetUniformLocation(gl->shadow_shader, "enable_texture"), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue