Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed compilation for older C #915

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,13 +706,14 @@ bool al_remove_config_key(ALLEGRO_CONFIG *config, char const *section,
ALLEGRO_USTR const *ukey = al_ref_cstr(&key_info, key);
void *value;
ALLEGRO_CONFIG_ENTRY * e;
ALLEGRO_CONFIG_SECTION *s;

if (section == NULL)
section = "";

usection = al_ref_cstr(&section_info, section);

ALLEGRO_CONFIG_SECTION *s = find_section(config, usection);
s = find_section(config, usection);
if (!s)
return false;

Expand Down
3 changes: 1 addition & 2 deletions src/opengl/extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static uint32_t parse_opengl_version(const char *s)
/* Reads version info out of glGetString(GL_VERSION) */
static uint32_t _al_ogl_version(void)
{
const char *str;
char const *value = al_get_config_value(al_get_system_config(), "opengl",
"force_opengl_version");
if (value) {
Expand All @@ -145,8 +146,6 @@ static uint32_t _al_ogl_version(void)
return v;
}

const char *str;

str = (const char *)glGetString(GL_VERSION);
if (str) {
#ifdef ALLEGRO_CFG_OPENGLES
Expand Down
3 changes: 2 additions & 1 deletion src/opengl/ogl_bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ GLuint al_get_opengl_texture(ALLEGRO_BITMAP *bitmap)
*/
void al_remove_opengl_fbo(ALLEGRO_BITMAP *bitmap)
{
ALLEGRO_FBO_INFO *info;
ALLEGRO_BITMAP_EXTRA_OPENGL *ogl_bitmap;
if (bitmap->parent)
bitmap = bitmap->parent;
Expand All @@ -1157,7 +1158,7 @@ void al_remove_opengl_fbo(ALLEGRO_BITMAP *bitmap)
ASSERT(ogl_bitmap->fbo_info->fbo_state > FBO_INFO_UNUSED);
ASSERT(ogl_bitmap->fbo_info->fbo != 0);

ALLEGRO_FBO_INFO *info = ogl_bitmap->fbo_info;
info = ogl_bitmap->fbo_info;
_al_ogl_del_fbo(info);

if (info->fbo_state == FBO_INFO_PERSISTENT) {
Expand Down
26 changes: 18 additions & 8 deletions src/opengl/ogl_fbo.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,18 @@ static void attach_depth_buffer(ALLEGRO_FBO_INFO *info)
ALLEGRO_DISPLAY *display = _al_get_bitmap_display(info->owner);
int w = al_get_bitmap_width(info->owner);
int h = al_get_bitmap_height(info->owner);
int samples = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's some whitespace inconsistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the next commit. Thanks.

bool extension_supported;
GLint e;

if (bits == 24) gldepth = GL_DEPTH_COMPONENT24;

glGenRenderbuffersEXT(1, &rb);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);

int samples = al_get_bitmap_samples(info->owner);
samples = al_get_bitmap_samples(info->owner);

bool extension_supported;

#ifdef ALLEGRO_CFG_OPENGLES
(void)display;
extension_supported = al_have_opengl_extension("EXT_multisampled_render_to_texture");
Expand All @@ -206,7 +209,7 @@ static void attach_depth_buffer(ALLEGRO_FBO_INFO *info)
info->buffers.dw = w;
info->buffers.dw = h;
info->buffers.depth = bits;
GLint e = glGetError();
e = glGetError();
if (e) {
ALLEGRO_ERROR("glRenderbufferStorage failed! bits=%d w=%d h=%d (%s)\n",
bits, w, h, _al_gl_error_string(e));
Expand All @@ -232,6 +235,7 @@ static void attach_multisample_buffer(ALLEGRO_FBO_INFO *info)
{
#if !defined ALLEGRO_RASPBERRYPI && (!defined ALLEGRO_ANDROID || defined ALLEGRO_CFG_OPENGLES3)
ALLEGRO_BITMAP *b = info->owner;
ALLEGRO_DISPLAY *display = NULL;
int samples = al_get_bitmap_samples(b);

if (info->buffers.multisample_buffer != 0) {
Expand All @@ -245,7 +249,7 @@ static void attach_multisample_buffer(ALLEGRO_FBO_INFO *info)

if (!samples)
return;
ALLEGRO_DISPLAY *display = _al_get_bitmap_display(info->owner);
display = _al_get_bitmap_display(info->owner);
if (!display->ogl_extras->extension_list->ALLEGRO_GL_EXT_framebuffer_multisample)
return;

Expand Down Expand Up @@ -505,20 +509,26 @@ void _al_ogl_setup_fbo(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *bitmap)
void _al_ogl_finalize_fbo(ALLEGRO_DISPLAY *display,
ALLEGRO_BITMAP *bitmap)
{
ALLEGRO_FBO_INFO *info = NULL;
ALLEGRO_BITMAP_EXTRA_OPENGL *extra = bitmap->extra;

#ifndef ALLEGRO_CFG_OPENGLES
int w, h;
GLuint blit_fbo;
#endif

if (!extra)
return;
ALLEGRO_FBO_INFO *info = extra->fbo_info;
info = extra->fbo_info;
(void)display;
if (!info)
return;
if (!info->buffers.multisample_buffer)
return;
#ifndef ALLEGRO_CFG_OPENGLES
int w = al_get_bitmap_width(bitmap);
int h = al_get_bitmap_height(bitmap);
w = al_get_bitmap_width(bitmap);
h = al_get_bitmap_height(bitmap);

GLuint blit_fbo;
glGenFramebuffersEXT(1, &blit_fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, blit_fbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
Expand Down
5 changes: 4 additions & 1 deletion src/win/wgl_disp.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,7 @@ static bool create_display_internals(ALLEGRO_DISPLAY_WGL *wgl_disp)
WGL_DISPLAY_PARAMETERS ndp;
int window_x, window_y;
int major, minor;
bool fc = false;

/* The window is created in a separate thread so we need to pass this
* TLS on
Expand Down Expand Up @@ -967,7 +968,9 @@ static bool create_display_internals(ALLEGRO_DISPLAY_WGL *wgl_disp)
if ((disp->flags & ALLEGRO_OPENGL_3_0) || major != 0) {
if (major == 0)
major = 3;
bool fc = (disp->flags & ALLEGRO_OPENGL_FORWARD_COMPATIBLE) != 0;
if ((disp->flags & ALLEGRO_OPENGL_FORWARD_COMPATIBLE) != 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that != 0 there is a bit unnecessary if we are introducing a new if() statement here...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, fixed in the next commit. Thanks.

fc = true;

wgl_disp->glrc = init_ogl_context_ex(wgl_disp->dc, fc, major,
minor);
}
Expand Down