From e98ee9bb04bd8bd29c237db593a6595b8e0d0893 Mon Sep 17 00:00:00 2001
From: Ramez Ragaa <[EMAIL REDACTED]>
Date: Sat, 28 Dec 2024 23:47:54 +0200
Subject: [PATCH] Adjust testgl.c to test gl_release_behavior
---
include/SDL3/SDL_test_common.h | 1 +
src/test/SDL_test_common.c | 1 +
test/testgl.c | 8 ++++++++
3 files changed, 10 insertions(+)
diff --git a/include/SDL3/SDL_test_common.h b/include/SDL3/SDL_test_common.h
index 2d39bcf52b41e..3ab1ad01c23d0 100644
--- a/include/SDL3/SDL_test_common.h
+++ b/include/SDL3/SDL_test_common.h
@@ -139,6 +139,7 @@ typedef struct
int gl_accum_blue_size;
int gl_accum_alpha_size;
int gl_stereo;
+ int gl_release_behavior;
int gl_multisamplebuffers;
int gl_multisamplesamples;
int gl_retained_backing;
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 335d5595dd28d..8e0590ae9fa7d 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1226,6 +1226,7 @@ bool SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_GL_SetAttribute(SDL_GL_ACCUM_BLUE_SIZE, state->gl_accum_blue_size);
SDL_GL_SetAttribute(SDL_GL_ACCUM_ALPHA_SIZE, state->gl_accum_alpha_size);
SDL_GL_SetAttribute(SDL_GL_STEREO, state->gl_stereo);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_RELEASE_BEHAVIOR, state->gl_release_behavior);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, state->gl_multisamplebuffers);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, state->gl_multisamplesamples);
if (state->gl_accelerated >= 0) {
diff --git a/test/testgl.c b/test/testgl.c
index 8854f21dca4c8..f109def341f3c 100644
--- a/test/testgl.c
+++ b/test/testgl.c
@@ -263,6 +263,9 @@ int main(int argc, char *argv[])
state->gl_green_size = 5;
state->gl_blue_size = 5;
state->gl_depth_size = 16;
+ /* For release_behavior to work, at least on Windows, you'll most likely need to set state->gl_major_version = 3 */
+ /* state->gl_major_version = 3; */
+ state->gl_release_behavior = 0;
state->gl_double_buffer = 1;
if (fsaa) {
state->gl_multisamplebuffers = 1;
@@ -331,6 +334,11 @@ int main(int argc, char *argv[])
} else {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError());
}
+ if (SDL_GL_GetAttribute(SDL_GL_CONTEXT_RELEASE_BEHAVIOR, &value)) {
+ SDL_Log("SDL_GL_CONTEXT_RELEASE_BEHAVIOR: requested %d, got %d\n", 0, value);
+ } else {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to get SDL_GL_CONTEXT_RELEASE_BEHAVIOR: %s\n", SDL_GetError());
+ }
if (fsaa) {
if (SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value)) {
SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value);