Fixed memory leak produced by drawing circles and disks

This commit is contained in:
zicodxx 2011-02-09 17:18:26 +01:00
parent eb0d876b9c
commit 80e9e5893e
2 changed files with 18 additions and 3 deletions

View file

@ -3,6 +3,7 @@ D1X-Rebirth Changelog
20110209
--------
main/ai.c, main/game.c, main/gamecntl.c, main/menu.c, main/multi.c, main/multi.h, main/state.c, main/state.h, main/titles.c: Reintroduced Savegames for Coop games using the original Descent2 implementation but correctly handling player slots in their pre-loading state preventing accidential player shifting which never really worked in the original game and we do not want with UDP anyways - was all tested but still might need a fix or two; Added some missing initializations for saving players and AI stuff; Completely ripped out remnants of saving between levels code
arch/ogl/ogl.c: Fixed memory leak produced by drawing circles and disks
20110206
--------

View file

@ -83,7 +83,7 @@ int ogl_rgb_internalformat = GL_RGB;
int ogl_rgba_internalformat = GL_RGBA8;
int ogl_rgb_internalformat = GL_RGB8;
#endif
GLfloat *sphere_va = NULL;
GLfloat *sphere_va = NULL, *circle_va = NULL, *disk_va = NULL;
GLfloat *secondary_lva[3]={NULL, NULL, NULL};
int r_polyc,r_tpolyc,r_bitmapc,r_ubitbltc,r_upixelc;
extern int linedotscale;
@ -218,6 +218,16 @@ void ogl_smash_texture_list_internal(void){
d_free(sphere_va);
sphere_va = NULL;
}
if (circle_va != NULL)
{
d_free(circle_va);
circle_va = NULL;
}
if (disk_va != NULL)
{
d_free(disk_va);
disk_va = NULL;
}
for(i = 0; i < 3; i++) {
if (secondary_lva[i] != NULL)
{
@ -771,7 +781,9 @@ int gr_ucircle(fix xc1, fix yc1, fix r1)
1.0 - (f2fl(yc1) + grd_curcanv->cv_bitmap.bm_y + 0.5) / (float)last_height,0);
glScalef(f2fl(r1) / last_width, f2fl(r1) / last_height, 1.0);
nsides = 10 + 2 * (int)(M_PI * f2fl(r1) / 19);
ogl_drawcircle(nsides, GL_LINE_LOOP, circle_array_init(nsides));
if(!circle_va)
circle_va = circle_array_init(nsides);
ogl_drawcircle(nsides, GL_LINE_LOOP, circle_va);
glPopMatrix();
return 0;
}
@ -792,7 +804,9 @@ int gr_disk(fix x,fix y,fix r)
1.0 - (f2fl(y) + grd_curcanv->cv_bitmap.bm_y + 0.5) / (float)last_height,0);
glScalef(f2fl(r) / last_width, f2fl(r) / last_height, 1.0);
nsides = 10 + 2 * (int)(M_PI * f2fl(r) / 19);
ogl_drawcircle(nsides, GL_TRIANGLE_FAN, circle_array_init(nsides));
if(!disk_va)
disk_va = circle_array_init(nsides);
ogl_drawcircle(nsides, GL_LINE_LOOP, disk_va);
glPopMatrix();
return 0;
}