X-Git-Url: https://eleni.mutantstargoat.com/git/?p=lighthouse;a=blobdiff_plain;f=src%2Fgeom.cc;h=dae21f5369843b01397b0554f60863a829fd194c;hp=804c18f82b20064dc454c2fbcb8dd10a37ecbec9;hb=0c1863b54e2d9ff94a65fbe2dae07d213ca6de6d;hpb=d60954c471d6f446523bad8c4c4860aa2138da1e diff --git a/src/geom.cc b/src/geom.cc index 804c18f..dae21f5 100644 --- a/src/geom.cc +++ b/src/geom.cc @@ -1,20 +1,52 @@ +#include #include #include #include "geom.h" #include "sdr.h" static unsigned int sdr_curve_top; +static unsigned int tex_xcircle; + +static const unsigned char tex_xcircle_pixels[] = { + 0, 64, 255, 255, 255, 255, 64, 0, + 0, 64, 255, 255, 255, 255, 64, 0, + 0, 64, 255, 255, 255, 255, 64, 0, + 0, 64, 255, 255, 255, 255, 64, 0, + 0, 64, 255, 255, 255, 255, 64, 0, + 0, 64, 255, 255, 255, 255, 64, 0, + 0, 64, 255, 255, 255, 255, 64, 0, + 0, 64, 255, 255, 255, 255, 64, 0, + + 0, 64, 255, 255, 255, 255, 64, 0, + 0, 0, 255, 255, 255, 255, 0, 0, + 0, 0, 128, 255, 255, 128, 0, 0, + 0, 0, 0, 64, 64, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 +}; + bool init_geom() { if(!(sdr_curve_top = create_program_load("sdr/curve_top.v.glsl", "sdr/curve_top.f.glsl"))) { return false; } + + glGenTextures(1, &tex_xcircle); + glBindTexture(GL_TEXTURE_2D, tex_xcircle); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 8, 16, 0, + GL_LUMINANCE, GL_UNSIGNED_BYTE, tex_xcircle_pixels); return true; } void destroy_geom() { + glDeleteTextures(1, &tex_xcircle); free_program(sdr_curve_top); } @@ -112,6 +144,70 @@ void ground() glPopMatrix(); } -void xlogo() +void xlogo(float sz, const float *col_ink, const float *col_paper, float alpha, float xcircle) { + static const float xlogo_varr[] = { + -0.500, 0.407, -0.113, -0.109, 0.059, -0.006, -0.251, 0.407, + -0.113, -0.109, -0.499, -0.593, -0.410, -0.593, 0.059, -0.006, + -0.058, -0.182, 0.251, -0.593, 0.500, -0.593, 0.114, -0.079, + -0.058, -0.182, 0.114, -0.079, 0.500, 0.407, 0.411, 0.407 + }; + + /* billboarding */ + float mv[16]; + glGetFloatv(GL_MODELVIEW_MATRIX, mv); + mv[0] = mv[5] = mv[10] = sz; + mv[1] = mv[2] = mv[4] = mv[6] = mv[8] = mv[9] = 0.0f; + + glPushMatrix(); + glLoadMatrixf(mv); + glTranslatef(0, 0.15, 0); + + glPushAttrib(GL_ENABLE_BIT); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glBegin(GL_QUADS); + glColor4f(col_ink[0], col_ink[1], col_ink[2], alpha); + const float *vptr = xlogo_varr; + for(int i=0; i<(int)(sizeof xlogo_varr / sizeof *xlogo_varr) / 2; i++) { + glVertex2fv(vptr); + vptr += 2; + } + glEnd(); + glTranslatef(0, -0.15, 0); + glDisable(GL_BLEND); + + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, tex_xcircle); + + glDisable(GL_CULL_FACE); + glEnable(GL_ALPHA_TEST); + float aref = 1.0f - xcircle; + glAlphaFunc(GL_GREATER, aref > 0.0f ? aref : 0.0f); + + glScalef(1.4, 1, 1); + +#define XLOGO_CIRCLE_SEG 64 + // circle thingy + glBegin(GL_QUAD_STRIP); + for(int i=0; i