ref: 7bbc0321cd8680ff911b0bd9346516585b505f2f
parent: b2244f17fc6257caa99f835538bd550a3272c71a
author: Clownacy <Clownacy@users.noreply.github.com>
date: Wed Jul 24 16:00:23 EDT 2019
Backport OpenGL2 fixes from the enhanced branch
--- a/src/Backends/Rendering/OpenGL2.cpp
+++ b/src/Backends/Rendering/OpenGL2.cpp
@@ -113,6 +113,7 @@
// Set up framebuffer (used for surface-to-surface blitting)
glGenFramebuffersEXT(1, &framebuffer_id);
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer_id);
// Set up framebuffer screen texture (used for screen-to-surface blitting)
glGenTextures(1, &framebuffer_surface.texture_id);
@@ -214,6 +215,9 @@
static void BlitCommon(Backend_Surface *source_surface, const RECT *rect, long x, long y, BOOL colour_key)
{
+ if (rect->right - rect->left < 0 || rect->bottom - rect->top < 0)
+ return;
+
// Switch to colour-key shader if we have to
glUseProgram(colour_key ? colour_key_program_id : 0);
@@ -250,6 +254,9 @@
static void ColourFillCommon(const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
{
+ if (rect->right - rect->left < 0 || rect->bottom - rect->top < 0)
+ return;
+
// Disable colour-keying
glUseProgram(0);
@@ -302,6 +309,12 @@
return NULL;
unsigned char *buffer = (unsigned char*)malloc(width * height * 4);
+
+ if (buffer == NULL)
+ {
+ free(glyph);
+ return NULL;
+ }
switch (pixel_mode)
{