Skip to content

Commit

Permalink
Prevent video context destruction if no GL context is active
Browse files Browse the repository at this point in the history
  • Loading branch information
vircon32 committed Apr 14, 2024
1 parent 011b1aa commit 293d0b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
15 changes: 9 additions & 6 deletions VideoOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ VideoOutput::VideoOutput()
VBOVertexInfo = 0;
VBOIndices = 0;
ShaderProgramID = 0;
IsInitialized = false;

// initialize vertex indices; they are organized
// assuming each quad will be given as 4 vertices,
Expand Down Expand Up @@ -391,6 +392,7 @@ void VideoOutput::InitRendering()
);

LOG( "Finished initializing rendering" );
IsInitialized = true;
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -451,6 +453,10 @@ void VideoOutput::ReleaseTexture( GLuint& OpenGLTextureID )

void VideoOutput::Destroy()
{
// prevent calling GL functions with no context active
if( !IsInitialized )
return;

LOG( "Destroying video context" );

// release all textures
Expand All @@ -476,13 +482,10 @@ void VideoOutput::Destroy()

// delete our shader program
LOG( "Deleting shader program" );
glDeleteProgram( ShaderProgramID );
ShaderProgramID = 0;

// these checks should not be needed but Lakka seems to crash here
if( glIsProgram( ShaderProgramID ) && glDeleteProgram )
{
glDeleteProgram( ShaderProgramID );
ShaderProgramID = 0;
}
IsInitialized = false;
}


Expand Down
1 change: 1 addition & 0 deletions VideoOutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class VideoOutput
GLuint VBOVertexInfo;
GLuint VBOIndices;
GLuint ShaderProgramID;
bool IsInitialized;

// rendering control for quad groups
int QueuedQuads;
Expand Down
2 changes: 1 addition & 1 deletion libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void retro_get_system_info( struct retro_system_info *info )
{
memset( info, 0, sizeof( *info ) );
info->library_name = "Vircon32";
info->library_version = "2023.08.24";
info->library_version = "2024.04.14";
info->need_fullpath = true; // games can be too large to hold in memory
info->valid_extensions = "v32|V32"; // target system may be case sensitive
}
Expand Down

0 comments on commit 293d0b2

Please sign in to comment.