summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/sdl/drawogl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/sdl/drawogl.c')
-rw-r--r--src/osd/sdl/drawogl.c147
1 files changed, 97 insertions, 50 deletions
diff --git a/src/osd/sdl/drawogl.c b/src/osd/sdl/drawogl.c
index 594d729389f..61b4e04385f 100644
--- a/src/osd/sdl/drawogl.c
+++ b/src/osd/sdl/drawogl.c
@@ -161,6 +161,25 @@ struct texture_info;
/* texture_info holds information about a texture */
struct texture_info
{
+ texture_info()
+ : hash(0), flags(0), rawwidth(0), rawheight(0),
+ rawwidth_create(0), rawheight_create(0),
+ type(0), format(0), borderpix(0), xprescale(0), yprescale(0), nocopy(0),
+ texture(0), texTarget(0), texpow2(0), mpass_dest_idx(0), pbo(0), data(NULL),
+ data_own(0), texCoordBufferName(0)
+ {
+ for (int i=0; i<2; i++)
+ {
+ mpass_textureunit[i] = 0;
+ mpass_texture_mamebm[i] = 0;
+ mpass_fbo_mamebm[i] = 0;
+ mpass_texture_scrn[i] = 0;
+ mpass_fbo_scrn[i] = 0;
+ }
+ for (int i=0; i<8; i++)
+ texCoord[i] = 0.0f;
+ }
+
HashT hash; // hash value for the texture (must be >= pointer size)
UINT32 flags; // rendering flags
render_texinfo texinfo; // copy of the texture info
@@ -198,6 +217,36 @@ struct texture_info
/* sdl_info is the information about SDL for the current screen */
struct sdl_info
{
+ sdl_info()
+ : blittimer(0), extra_flags(0),
+#if (SDLMAME_SDL2)
+ gl_context_id(0),
+#else
+ sdlsurf(NULL),
+#endif
+ initialized(0),
+ last_blendmode(0),
+ texture_max_width(0),
+ texture_max_height(0),
+ texpoweroftwo(0),
+ usevbo(0), usepbo(0), usefbo(0), useglsl(0), glsl(NULL),
+ glsl_program_num(0),
+ glsl_program_mb2sc(0),
+ usetexturerect(0),
+ init_context(0),
+ last_hofs(0.0f),
+ last_vofs(0.0f),
+ surf_w(0),
+ surf_h(0)
+ {
+ for (int i=0; i < HASH_SIZE + OVERFLOW_SIZE; i++)
+ texhash[i] = NULL;
+ for (int i=0; i < 2*GLSL_SHADER_MAX; i++)
+ glsl_program[i] = 0;
+ for (int i=0; i < 8; i++)
+ texVerticex[i] = 0.0f;
+ }
+
INT32 blittimer;
UINT32 extra_flags;
@@ -487,8 +536,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height)
int has_and_allow_texturerect = 0;
// allocate memory for our structures
- sdl = (sdl_info *) osd_malloc(sizeof(*sdl));
- memset(sdl, 0, sizeof(*sdl));
+ sdl = global_alloc(sdl_info);
window->dxdata = sdl;
@@ -1612,7 +1660,7 @@ static void drawogl_window_destroy(sdl_window_info *window)
}
#endif
- osd_free(sdl);
+ global_free(sdl);
window->dxdata = NULL;
}
@@ -1654,7 +1702,7 @@ static void texture_compute_type_subroutine(sdl_info *sdl, const render_texinfo
if ( texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_EQUALS_DEST] &&
!texture_copy_properties[texture->format][SDL_TEXFORMAT_SRC_HAS_PALETTE] &&
texture->xprescale == 1 && texture->yprescale == 1 &&
- !texture->borderpix && !texsource->palette &&
+ !texture->borderpix && !texsource->palette() &&
texsource->rowpixels <= sdl->texture_max_width )
{
texture->nocopy = TRUE;
@@ -2068,8 +2116,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture_info *texture;
// allocate a new texture
- texture = (texture_info *) malloc(sizeof(*texture));
- memset(texture, 0, sizeof(*texture));
+ texture = global_alloc(texture_info);
// fill in the core data
texture->hash = texture_compute_hash(texsource, flags);
@@ -2107,7 +2154,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture->format = SDL_TEXFORMAT_ARGB32;
break;
case TEXFORMAT_RGB32:
- if (texsource->palette != NULL)
+ if (texsource->palette() != NULL)
texture->format = SDL_TEXFORMAT_RGB32_PALETTED;
else
texture->format = SDL_TEXFORMAT_RGB32;
@@ -2119,7 +2166,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
texture->format = SDL_TEXFORMAT_PALETTE16A;
break;
case TEXFORMAT_YUY16:
- if (texsource->palette != NULL)
+ if (texsource->palette() != NULL)
texture->format = SDL_TEXFORMAT_YUY16_PALETTED;
else
texture->format = SDL_TEXFORMAT_YUY16;
@@ -2143,7 +2190,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
{
if ( texture_shader_create(window, texsource, texture, flags) )
{
- free(texture);
+ global_free(texture);
return NULL;
}
}
@@ -2229,7 +2276,7 @@ static texture_info *texture_create(sdl_window_info *window, const render_texinf
sdl->texhash[i] = texture;
break;
}
- assert(i < HASH_SIZE + OVERFLOW_SIZE);
+ assert_always(i < HASH_SIZE + OVERFLOW_SIZE, "texture hash exhausted ...");
}
if(sdl->usevbo)
@@ -2561,23 +2608,23 @@ static void texture_set_data(texture_info *texture, const render_texinfo *texsou
switch (PRIMFLAG_GET_TEXFORMAT(flags))
{
case TEXFORMAT_PALETTE16:
- copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
+ copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break;
case TEXFORMAT_PALETTEA16:
- copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
+ copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break;
case TEXFORMAT_RGB32:
- copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
+ copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break;
case TEXFORMAT_ARGB32:
- copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
+ copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break;
case TEXFORMAT_YUY16:
- copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette, texture->borderpix, texture->xprescale);
+ copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + y * texsource->rowpixels, texsource->width, texsource->palette(), texture->borderpix, texture->xprescale);
break;
default:
@@ -2650,7 +2697,7 @@ static int compare_texture_primitive(const texture_info *texture, const render_p
texture->texinfo.width == prim->texture.width &&
texture->texinfo.height == prim->texture.height &&
texture->texinfo.rowpixels == prim->texture.rowpixels &&
- texture->texinfo.palette == prim->texture.palette &&
+ /* texture->texinfo.palette() == prim->texture.palette() && */
((texture->flags ^ prim->flags) & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK)) == 0)
return 1;
else
@@ -3041,40 +3088,40 @@ static void drawogl_destroy_all_textures(sdl_window_info *window)
sdl->texhash[i] = NULL;
if (texture != NULL)
{
- if(sdl->usevbo)
- {
- pfn_glDeleteBuffers( 1, &(texture->texCoordBufferName) );
- texture->texCoordBufferName=0;
- }
-
- if(sdl->usepbo && texture->pbo)
- {
- pfn_glDeleteBuffers( 1, (GLuint *)&(texture->pbo) );
- texture->pbo=0;
- }
-
- if( sdl->glsl_program_num > 1 )
- {
- assert(sdl->usefbo);
- pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_mamebm[0]);
- glDeleteTextures(2, (GLuint *)&texture->mpass_texture_mamebm[0]);
- }
-
- if ( sdl->glsl_program_mb2sc < sdl->glsl_program_num - 1 )
- {
- assert(sdl->usefbo);
- pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_scrn[0]);
- glDeleteTextures(2, (GLuint *)&texture->mpass_texture_scrn[0]);
- }
-
- glDeleteTextures(1, (GLuint *)&texture->texture);
- if ( texture->data_own )
- {
- free(texture->data);
- texture->data=NULL;
- texture->data_own=FALSE;
- }
- free(texture);
+ if(sdl->usevbo)
+ {
+ pfn_glDeleteBuffers( 1, &(texture->texCoordBufferName) );
+ texture->texCoordBufferName=0;
+ }
+
+ if(sdl->usepbo && texture->pbo)
+ {
+ pfn_glDeleteBuffers( 1, (GLuint *)&(texture->pbo) );
+ texture->pbo=0;
+ }
+
+ if( sdl->glsl_program_num > 1 )
+ {
+ assert(sdl->usefbo);
+ pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_mamebm[0]);
+ glDeleteTextures(2, (GLuint *)&texture->mpass_texture_mamebm[0]);
+ }
+
+ if ( sdl->glsl_program_mb2sc < sdl->glsl_program_num - 1 )
+ {
+ assert(sdl->usefbo);
+ pfn_glDeleteFramebuffers(2, (GLuint *)&texture->mpass_fbo_scrn[0]);
+ glDeleteTextures(2, (GLuint *)&texture->mpass_texture_scrn[0]);
+ }
+
+ glDeleteTextures(1, (GLuint *)&texture->texture);
+ if ( texture->data_own )
+ {
+ free(texture->data);
+ texture->data=NULL;
+ texture->data_own=FALSE;
+ }
+ global_free(texture);
}
i++;
}