some fancy things
This commit is contained in:
parent
f86e26cddd
commit
7cf83fbb2a
7 changed files with 117 additions and 3 deletions
|
|
@ -23,6 +23,10 @@ GSDECL void GSGLTextureDelete(GSGL gl, GLuint texture);
|
||||||
/* gl_common.c */
|
/* gl_common.c */
|
||||||
GSDECL GSBool GSGLTextureLoadFile(GSGL gl, GLuint* texture, int* width, int* height, const char* filename);
|
GSDECL GSBool GSGLTextureLoadFile(GSGL gl, GLuint* texture, int* width, int* height, const char* filename);
|
||||||
GSDECL GSBool GSGLTextureTry(GSGL gl, GLuint* texture, int* width, int* height, const char* prefix);
|
GSDECL GSBool GSGLTextureTry(GSGL gl, GLuint* texture, int* width, int* height, const char* prefix);
|
||||||
|
GSDECL void GSGLTextEx(GSGL gl, double x, double y, double sx, double sy, const char* text);
|
||||||
|
GSDECL void GSGLText(GSGL gl, double x, double y, const char* text);
|
||||||
|
GSDECL double GSGLTextWidth(GSGL gl, const char* text);
|
||||||
|
GSDECL double GSGLTextHeight(GSGL gl, const char* text);
|
||||||
|
|
||||||
/* gl_shadow.c */
|
/* gl_shadow.c */
|
||||||
GSDECL void GSGLShadowInit(GSGL gl);
|
GSDECL void GSGLShadowInit(GSGL gl);
|
||||||
|
|
@ -51,6 +55,7 @@ GSDECL void GSGLPopMatrix(GSGL gl);
|
||||||
GSDECL GLuint GSGLBeginList(GSGL gl);
|
GSDECL GLuint GSGLBeginList(GSGL gl);
|
||||||
GSDECL void GSGLEndList(GSGL gl);
|
GSDECL void GSGLEndList(GSGL gl);
|
||||||
GSDECL void GSGLCallList(GSGL gl, GLuint list);
|
GSDECL void GSGLCallList(GSGL gl, GLuint list);
|
||||||
|
GSDECL void GSGLSetColor(GSGL gl, GSVector4 color);
|
||||||
|
|
||||||
/* gl_camera.c */
|
/* gl_camera.c */
|
||||||
GSDECL void GSGLCameraPerspective(GSGL gl, GSNumber width, GSNumber height);
|
GSDECL void GSGLCameraPerspective(GSGL gl, GSNumber width, GSNumber height);
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,9 @@ struct _GSClient {
|
||||||
GSEngine engine;
|
GSEngine engine;
|
||||||
|
|
||||||
GSGL gl;
|
GSGL gl;
|
||||||
|
GLuint font;
|
||||||
|
int font_width;
|
||||||
|
int font_height;
|
||||||
GSVector3 look_at;
|
GSVector3 look_at;
|
||||||
GSVector3 camera;
|
GSVector3 camera;
|
||||||
GSVector4 light0;
|
GSVector4 light0;
|
||||||
|
|
@ -180,6 +183,7 @@ struct _GSResource {
|
||||||
|
|
||||||
struct _GSVersion {
|
struct _GSVersion {
|
||||||
char string[64];
|
char string[64];
|
||||||
|
char copyright[256];
|
||||||
int majorlevel;
|
int majorlevel;
|
||||||
int minorlevel;
|
int minorlevel;
|
||||||
int patchlevel;
|
int patchlevel;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
#include <GearSrc/SkyBox.h>
|
#include <GearSrc/SkyBox.h>
|
||||||
#include <GearSrc/Math.h>
|
#include <GearSrc/Math.h>
|
||||||
#include <GearSrc/Model.h>
|
#include <GearSrc/Model.h>
|
||||||
|
#include <GearSrc/Version.h>
|
||||||
|
|
||||||
GSClient GSClientCreate(GSEngine engine) {
|
GSClient GSClientCreate(GSEngine engine) {
|
||||||
GSClient client = malloc(sizeof(*client));
|
GSClient client = malloc(sizeof(*client));
|
||||||
|
|
@ -32,12 +33,20 @@ GSClient GSClientCreate(GSEngine engine) {
|
||||||
|
|
||||||
client->skybox = GSSkyBoxTry(client, "default");
|
client->skybox = GSSkyBoxTry(client, "default");
|
||||||
|
|
||||||
|
if(GSGLTextureTry(client->gl, &client->font, &client->font_width, &client->font_height, "game:/font")){
|
||||||
|
}else if(GSGLTextureTry(client->gl, &client->font, &client->font_width, &client->font_height, "base:/font")){
|
||||||
|
}else{
|
||||||
|
client->font = 0;
|
||||||
|
}
|
||||||
|
|
||||||
GSLog(GSLogInfo, "Created client");
|
GSLog(GSLogInfo, "Created client");
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSClientDestroy(GSClient client) {
|
void GSClientDestroy(GSClient client) {
|
||||||
|
if(client->font != 0) GSGLTextureDelete(client->gl, client->font);
|
||||||
|
|
||||||
GSGLDestroy(client->gl);
|
GSGLDestroy(client->gl);
|
||||||
|
|
||||||
free(client);
|
free(client);
|
||||||
|
|
@ -50,7 +59,15 @@ static void scene(GSClient client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GSClientStep(GSClient client) {
|
void GSClientStep(GSClient client) {
|
||||||
static double r = 0;
|
int tw, th;
|
||||||
|
int tw2, th2;
|
||||||
|
int sw, sh;
|
||||||
|
char buf[512];
|
||||||
|
char buf2[512];
|
||||||
|
GSVersion ver;
|
||||||
|
GSVector4 white = {1, 1, 1, 1};
|
||||||
|
GSVector4 half = {0, 0, 0, 0.5};
|
||||||
|
GSVector2 sq[4];
|
||||||
|
|
||||||
GSGLClear(client->gl);
|
GSGLClear(client->gl);
|
||||||
GSGLCameraSetup(client->gl);
|
GSGLCameraSetup(client->gl);
|
||||||
|
|
@ -67,6 +84,36 @@ void GSClientStep(GSClient client) {
|
||||||
scene(client);
|
scene(client);
|
||||||
GSGLShadowEnd(client->gl);
|
GSGLShadowEnd(client->gl);
|
||||||
|
|
||||||
|
|
||||||
|
GSVersionGet(&ver);
|
||||||
|
|
||||||
|
sprintf(buf, "GearSrc Engine %s", ver.string);
|
||||||
|
|
||||||
|
tw = GSGLTextWidth(client->gl, buf);
|
||||||
|
th = GSGLTextHeight(client->gl, buf);
|
||||||
|
|
||||||
|
sprintf(buf2, "%s", ver.copyright);
|
||||||
|
|
||||||
|
tw2 = GSGLTextWidth(client->gl, buf2);
|
||||||
|
th2 = GSGLTextHeight(client->gl, buf2);
|
||||||
|
|
||||||
|
sw = tw > tw2 ? tw : tw2;
|
||||||
|
sh = th + th2;
|
||||||
|
|
||||||
|
sq[0][0] = client->engine->width - sw, sq[0][1] = client->engine->height - sh;
|
||||||
|
sq[1][0] = client->engine->width - sw, sq[1][1] = client->engine->height;
|
||||||
|
sq[2][0] = client->engine->width, sq[2][1] = client->engine->height;
|
||||||
|
sq[3][0] = client->engine->width, sq[3][1] = client->engine->height - sh;
|
||||||
|
|
||||||
|
GSGLSetColor(client->gl, half);
|
||||||
|
GSGLBegin2D(client->gl);
|
||||||
|
GSGLPolygon2D(client->gl, 4, sq, NULL);
|
||||||
|
GSGLEnd2D(client->gl);
|
||||||
|
|
||||||
|
GSGLSetColor(client->gl, white);
|
||||||
|
GSGLText(client->gl, client->engine->width - tw, client->engine->height - th * 2, buf);
|
||||||
|
GSGLText(client->gl, client->engine->width - tw2, client->engine->height - th2, buf2);
|
||||||
|
|
||||||
client->engine->param->gl_swapbuffer();
|
client->engine->param->gl_swapbuffer();
|
||||||
|
|
||||||
if(client->engine->param->after_render != NULL) client->engine->param->after_render(client->engine);
|
if(client->engine->param->after_render != NULL) client->engine->param->after_render(client->engine);
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ GSEngine GSEngineCreate(GSEngineParam* param) {
|
||||||
engine->param = malloc(sizeof(*engine->param));
|
engine->param = malloc(sizeof(*engine->param));
|
||||||
memcpy(engine->param, param, sizeof(*param));
|
memcpy(engine->param, param, sizeof(*param));
|
||||||
|
|
||||||
engine->width = 1024;
|
engine->width = 800;
|
||||||
engine->height = 768;
|
engine->height = 600;
|
||||||
|
|
||||||
if(param->ready != NULL && param->client) {
|
if(param->ready != NULL && param->client) {
|
||||||
param->ready(engine->width, engine->height);
|
param->ready(engine->width, engine->height);
|
||||||
|
|
|
||||||
|
|
@ -145,3 +145,7 @@ void GSGLEndList(GSGL gl) {
|
||||||
void GSGLCallList(GSGL gl, GLuint list) {
|
void GSGLCallList(GSGL gl, GLuint list) {
|
||||||
glCallList(list);
|
glCallList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSGLSetColor(GSGL gl, GSVector4 color){
|
||||||
|
glColor4f(color[0], color[1], color[2], color[3]);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,3 +60,56 @@ GSBool GSGLTextureTry(GSGL gl, GLuint* texture, int* width, int* height, const c
|
||||||
|
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSGLTextEx(GSGL gl, double x, double y, double sx, double sy, const char* text){
|
||||||
|
double px = x;
|
||||||
|
double py = y;
|
||||||
|
int i;
|
||||||
|
double gw = gl->engine->client->font_width / 16 * sx;
|
||||||
|
double gh = gl->engine->client->font_height / 16 * sy;
|
||||||
|
|
||||||
|
GSGLBegin2D(gl);
|
||||||
|
GSGLTextureSet(gl, gl->engine->client->font);
|
||||||
|
|
||||||
|
for(i = 0; text[i] != 0; i++){
|
||||||
|
GSVector2 v[4];
|
||||||
|
GSVector2 t[4];
|
||||||
|
double gx = text[i] % 16;
|
||||||
|
double gy = text[i] / 16;
|
||||||
|
|
||||||
|
gx = gx / 16;
|
||||||
|
gy = gy / 16;
|
||||||
|
|
||||||
|
v[0][0] = px, v[0][1] = py;
|
||||||
|
|
||||||
|
v[1][0] = px, v[1][1] = py + gh;
|
||||||
|
|
||||||
|
v[2][0] = px + gw, v[2][1] = py + gh;
|
||||||
|
|
||||||
|
v[3][0] = px + gw, v[3][1] = py;
|
||||||
|
|
||||||
|
t[0][0] = gx, t[0][1] = gy;
|
||||||
|
t[1][0] = gx, t[1][1] = gy + 1.0 / 16;
|
||||||
|
t[2][0] = gx + 1.0 / 16, t[2][1] = gy + 1.0 / 16;
|
||||||
|
t[3][0] = gx + 1.0 / 16, t[3][1] = gy;
|
||||||
|
|
||||||
|
GSGLPolygon2D(gl, 4, v, t);
|
||||||
|
|
||||||
|
px += gw;
|
||||||
|
}
|
||||||
|
|
||||||
|
GSGLTextureSet(gl, 0);
|
||||||
|
GSGLEnd2D(gl);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GSGLText(GSGL gl, double x, double y, const char* text){
|
||||||
|
GSGLTextEx(gl, x, y, 1, 1, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
double GSGLTextWidth(GSGL gl, const char* text){
|
||||||
|
return gl->engine->client->font_width / 16 * strlen(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
double GSGLTextHeight(GSGL gl, const char* text){
|
||||||
|
return gl->engine->client->font_height / 16;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,5 @@ void GSVersionGet(GSVersion* version) {
|
||||||
version->patchlevel = 0;
|
version->patchlevel = 0;
|
||||||
|
|
||||||
sprintf(version->string, "%d.%d.%d", version->majorlevel, version->minorlevel, version->patchlevel);
|
sprintf(version->string, "%d.%d.%d", version->majorlevel, version->minorlevel, version->patchlevel);
|
||||||
|
strcpy(version->copyright, "Copyright (C) 2026 Pyrite development team");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue