X-Git-Url: http://git.mutantstargoat.com?p=faros-demo;a=blobdiff_plain;f=src%2Fgeom.cc;fp=src%2Fgeom.cc;h=770b4385182a337d0c5f7ef041860150ffdca327;hp=62e36d398702580c4e6c83b4f89a56178251dff3;hb=1aaca3876c029a6558d193bf315e2ce188ce1d79;hpb=3ab4c732d6d2b7dccfe34f1ae7be9025ef79611b diff --git a/src/geom.cc b/src/geom.cc index 62e36d3..770b438 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,7 +144,7 @@ void ground() glPopMatrix(); } -void xlogo() +void xlogo(float sz, 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, @@ -124,23 +156,57 @@ void xlogo() /* billboarding */ float mv[16]; glGetFloatv(GL_MODELVIEW_MATRIX, mv); - mv[0] = mv[5] = mv[10] = 1.0f; + 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(0, 0, 0, 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