mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-07 00:41:26 +00:00
Attempt to fix sky dome
This commit is contained in:
parent
d45ed97e50
commit
55c6c4f5fe
1 changed files with 30 additions and 17 deletions
|
@ -1418,9 +1418,12 @@ typedef struct
|
||||||
vbo_vertex_t *data;
|
vbo_vertex_t *data;
|
||||||
} GLSkyVBO;
|
} GLSkyVBO;
|
||||||
|
|
||||||
#define sky_vbo_x (&vbo->data[0].x)
|
static const boolean gl_ext_arb_vertex_buffer_object = true;
|
||||||
#define sky_vbo_u (&vbo->data[0].u)
|
|
||||||
#define sky_vbo_r (&vbo->data[0].r)
|
#define NULL_VBO_VERTEX ((vbo_vertex_t*)NULL)
|
||||||
|
#define sky_vbo_x (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->x : &vbo->data[0].x)
|
||||||
|
#define sky_vbo_u (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->u : &vbo->data[0].u)
|
||||||
|
#define sky_vbo_r (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->r : &vbo->data[0].r)
|
||||||
|
|
||||||
// The texture offset to be applied to the texture coordinates in SkyVertex().
|
// The texture offset to be applied to the texture coordinates in SkyVertex().
|
||||||
static int rows, columns;
|
static int rows, columns;
|
||||||
|
@ -1431,7 +1434,6 @@ static float delta = 0.0f;
|
||||||
|
|
||||||
static int gl_sky_detail = 16;
|
static int gl_sky_detail = 16;
|
||||||
|
|
||||||
static boolean vbo_init = false;
|
|
||||||
static INT32 lasttex = -1;
|
static INT32 lasttex = -1;
|
||||||
|
|
||||||
#define MAP_COEFF 128.0f
|
#define MAP_COEFF 128.0f
|
||||||
|
@ -1564,30 +1566,40 @@ static void RenderDome(INT32 skytexture)
|
||||||
|
|
||||||
rows = 4;
|
rows = 4;
|
||||||
columns = 4 * gl_sky_detail;
|
columns = 4 * gl_sky_detail;
|
||||||
vbosize = 2 * rows * (columns * 2 + 2) + columns * 2;
|
|
||||||
|
|
||||||
// generate a new VBO and get the associated ID
|
vbosize = 2 * rows * (columns * 2 + 2) + columns * 2;
|
||||||
if (!vbo_init)
|
|
||||||
{
|
|
||||||
pglGenBuffers(1, &vbo->id);
|
|
||||||
vbo_init = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build the sky dome! Yes!
|
// Build the sky dome! Yes!
|
||||||
if (lasttex != skytexture)
|
if (lasttex != skytexture)
|
||||||
{
|
{
|
||||||
|
// delete VBO when already exists
|
||||||
|
if (gl_ext_arb_vertex_buffer_object)
|
||||||
|
{
|
||||||
|
if (vbo->id)
|
||||||
|
pglDeleteBuffers(1, &vbo->id);
|
||||||
|
}
|
||||||
|
|
||||||
lasttex = skytexture;
|
lasttex = skytexture;
|
||||||
gld_BuildSky(rows, columns);
|
gld_BuildSky(rows, columns);
|
||||||
|
|
||||||
// bind VBO in order to use
|
if (gl_ext_arb_vertex_buffer_object)
|
||||||
pglBindBuffer(GL_ARRAY_BUFFER, vbo->id);
|
{
|
||||||
|
// generate a new VBO and get the associated ID
|
||||||
|
pglGenBuffers(1, &vbo->id);
|
||||||
|
|
||||||
// upload data to VBO
|
// bind VBO in order to use
|
||||||
pglBufferData(GL_ARRAY_BUFFER, vbosize * sizeof(vbo->data[0]), vbo->data, GL_STATIC_DRAW);
|
pglBindBuffer(GL_ARRAY_BUFFER, vbo->id);
|
||||||
|
|
||||||
|
// upload data to VBO
|
||||||
|
pglBufferData(GL_ARRAY_BUFFER, vbosize * sizeof(vbo->data[0]), vbo->data, GL_STATIC_DRAW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bind VBO in order to use
|
||||||
|
if (gl_ext_arb_vertex_buffer_object)
|
||||||
|
pglBindBuffer(GL_ARRAY_BUFFER, vbo->id);
|
||||||
|
|
||||||
// activate and specify pointers to arrays
|
// activate and specify pointers to arrays
|
||||||
pglBindBuffer(GL_ARRAY_BUFFER, vbo->id);
|
|
||||||
pglVertexPointer(3, GL_FLOAT, sizeof(vbo->data[0]), sky_vbo_x);
|
pglVertexPointer(3, GL_FLOAT, sizeof(vbo->data[0]), sky_vbo_x);
|
||||||
pglTexCoordPointer(2, GL_FLOAT, sizeof(vbo->data[0]), sky_vbo_u);
|
pglTexCoordPointer(2, GL_FLOAT, sizeof(vbo->data[0]), sky_vbo_u);
|
||||||
pglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vbo->data[0]), sky_vbo_r);
|
pglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vbo->data[0]), sky_vbo_r);
|
||||||
|
@ -1616,7 +1628,8 @@ static void RenderDome(INT32 skytexture)
|
||||||
pglColor4ubv(white);
|
pglColor4ubv(white);
|
||||||
|
|
||||||
// bind with 0, so, switch back to normal pointer operation
|
// bind with 0, so, switch back to normal pointer operation
|
||||||
pglBindBuffer(GL_ARRAY_BUFFER, 0);
|
if (gl_ext_arb_vertex_buffer_object)
|
||||||
|
pglBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
|
|
||||||
// deactivate color array
|
// deactivate color array
|
||||||
pglDisableClientState(GL_COLOR_ARRAY);
|
pglDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
|
Loading…
Reference in a new issue