Commit 240b5fca authored by Sam Lantinga's avatar Sam Lantinga

Default to allow either accelerated or not

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404320
parent fe2b42f8
...@@ -239,7 +239,7 @@ SDL_VideoInit(const char *driver_name, Uint32 flags) ...@@ -239,7 +239,7 @@ SDL_VideoInit(const char *driver_name, Uint32 flags)
_this->gl_config.multisamplebuffers = 0; _this->gl_config.multisamplebuffers = 0;
_this->gl_config.multisamplesamples = 0; _this->gl_config.multisamplesamples = 0;
_this->gl_config.retained_backing = 1; _this->gl_config.retained_backing = 1;
_this->gl_config.accelerated = 1; _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */
_this->gl_config.major_version = 2; _this->gl_config.major_version = 2;
_this->gl_config.minor_version = 1; _this->gl_config.minor_version = 1;
...@@ -3274,7 +3274,7 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) ...@@ -3274,7 +3274,7 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
case SDL_GL_ACCELERATED_VISUAL: case SDL_GL_ACCELERATED_VISUAL:
{ {
/* FIXME: How do we get this information? */ /* FIXME: How do we get this information? */
*value = _this->gl_config.accelerated; *value = (_this->gl_config.accelerated != 0);
return 0; return 0;
} }
default: default:
......
...@@ -133,11 +133,13 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window) ...@@ -133,11 +133,13 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
attr[i++] = NSOpenGLPFANoRecovery; attr[i++] = NSOpenGLPFANoRecovery;
} }
if (_this->gl_config.accelerated) { if (_this->gl_config.accelerated >= 0) {
attr[i++] = NSOpenGLPFAAccelerated; if (_this->gl_config.accelerated) {
} else { attr[i++] = NSOpenGLPFAAccelerated;
attr[i++] = NSOpenGLPFARendererID; } else {
attr[i++] = kCGLRendererGenericFloatID; attr[i++] = NSOpenGLPFARendererID;
attr[i++] = kCGLRendererGenericFloatID;
}
} }
attr[i++] = NSOpenGLPFAScreenMask; attr[i++] = NSOpenGLPFAScreenMask;
......
...@@ -469,9 +469,12 @@ WIN_GL_SetupWindow(_THIS, SDL_Window * window) ...@@ -469,9 +469,12 @@ WIN_GL_SetupWindow(_THIS, SDL_Window * window)
*iAttr++ = _this->gl_config.multisamplesamples; *iAttr++ = _this->gl_config.multisamplesamples;
} }
*iAttr++ = WGL_ACCELERATION_ARB; if (_this->gl_config.accelerated >= 0) {
*iAttr++ = (_this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB : *iAttr++ = WGL_ACCELERATION_ARB;
WGL_NO_ACCELERATION_ARB); *iAttr++ =
(_this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB :
WGL_NO_ACCELERATION_ARB);
}
*iAttr = 0; *iAttr = 0;
......
...@@ -359,7 +359,8 @@ X11_GL_GetVisual(_THIS, Display * display, int screen) ...@@ -359,7 +359,8 @@ X11_GL_GetVisual(_THIS, Display * display, int screen)
attribs[i++] = _this->gl_config.multisamplesamples; attribs[i++] = _this->gl_config.multisamplesamples;
} }
if (_this->gl_data->HAS_GLX_EXT_visual_rating) { if (_this->gl_config.accelerated >= 0 &&
_this->gl_data->HAS_GLX_EXT_visual_rating) {
attribs[i++] = GLX_VISUAL_CAVEAT_EXT; attribs[i++] = GLX_VISUAL_CAVEAT_EXT;
attribs[i++] = _this->gl_config.accelerated ? GLX_NONE_EXT : attribs[i++] = _this->gl_config.accelerated ? GLX_NONE_EXT :
GLX_SLOW_VISUAL_EXT; GLX_SLOW_VISUAL_EXT;
......
...@@ -104,7 +104,7 @@ CommonCreateState(char **argv, Uint32 flags) ...@@ -104,7 +104,7 @@ CommonCreateState(char **argv, Uint32 flags)
state->gl_multisamplebuffers = 0; state->gl_multisamplebuffers = 0;
state->gl_multisamplesamples = 0; state->gl_multisamplesamples = 0;
state->gl_retained_backing = 1; state->gl_retained_backing = 1;
state->gl_accelerated = 1; state->gl_accelerated = -1;
state->gl_major_version = 2; state->gl_major_version = 2;
state->gl_minor_version = 1; state->gl_minor_version = 1;
...@@ -659,7 +659,10 @@ CommonInit(CommonState * state) ...@@ -659,7 +659,10 @@ CommonInit(CommonState * state)
SDL_GL_SetAttribute(SDL_GL_STEREO, state->gl_stereo); SDL_GL_SetAttribute(SDL_GL_STEREO, state->gl_stereo);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, state->gl_multisamplebuffers); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, state->gl_multisamplebuffers);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, state->gl_multisamplesamples); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, state->gl_multisamplesamples);
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, state->gl_accelerated); if (state->gl_accelerated >= 0) {
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL,
state->gl_accelerated);
}
SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, state->gl_retained_backing); SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, state->gl_retained_backing);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, state->gl_major_version); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, state->gl_major_version);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, state->gl_minor_version); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, state->gl_minor_version);
......
...@@ -370,7 +370,7 @@ DrawLogoTexture(void) ...@@ -370,7 +370,7 @@ DrawLogoTexture(void)
int int
RunGLTest(int argc, char *argv[], RunGLTest(int argc, char *argv[],
int logo, int logocursor, int slowly, int bpp, float gamma, int logo, int logocursor, int slowly, int bpp, float gamma,
int noframe, int fsaa, int sync, int noaccel) int noframe, int fsaa, int sync, int accel)
{ {
int i; int i;
int rgb_size[3]; int rgb_size[3];
...@@ -454,7 +454,9 @@ RunGLTest(int argc, char *argv[], ...@@ -454,7 +454,9 @@ RunGLTest(int argc, char *argv[],
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa);
} }
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, !noaccel); if (accel >= 0) {
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, accel);
}
if (SDL_SetVideoMode(w, h, bpp, video_flags) == NULL) { if (SDL_SetVideoMode(w, h, bpp, video_flags) == NULL) {
fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
SDL_Quit(); SDL_Quit();
...@@ -491,8 +493,11 @@ RunGLTest(int argc, char *argv[], ...@@ -491,8 +493,11 @@ RunGLTest(int argc, char *argv[],
printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa,
value); value);
} }
SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); if (accel >= 0) {
printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", !noaccel, value); SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
value);
}
if (sync) { if (sync) {
printf("Buffer swap interval: requested 1, got %d\n", printf("Buffer swap interval: requested 1, got %d\n",
SDL_GL_GetSwapInterval()); SDL_GL_GetSwapInterval());
...@@ -703,7 +708,7 @@ main(int argc, char *argv[]) ...@@ -703,7 +708,7 @@ main(int argc, char *argv[])
float gamma = 0.0; float gamma = 0.0;
int noframe = 0; int noframe = 0;
int fsaa = 0; int fsaa = 0;
int noaccel = 0; int accel = -1;
int sync = 0; int sync = 0;
logo = 0; logo = 0;
...@@ -734,22 +739,22 @@ main(int argc, char *argv[]) ...@@ -734,22 +739,22 @@ main(int argc, char *argv[])
if (strcmp(argv[i], "-fsaa") == 0) { if (strcmp(argv[i], "-fsaa") == 0) {
++fsaa; ++fsaa;
} }
if (strcmp(argv[i], "-noaccel") == 0) { if (strcmp(argv[i], "-accel") == 0) {
++noaccel; accel = atoi(argv[++i]);
} }
if (strcmp(argv[i], "-sync") == 0) { if (strcmp(argv[i], "-sync") == 0) {
++sync; ++sync;
} }
if (strncmp(argv[i], "-h", 2) == 0) { if (strncmp(argv[i], "-h", 2) == 0) {
printf printf
("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-noaccel] [-sync] [-fullscreen]\n", ("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-accel n] [-sync] [-fullscreen]\n",
argv[0]); argv[0]);
exit(0); exit(0);
} }
} }
for (i = 0; i < numtests; ++i) { for (i = 0; i < numtests; ++i) {
RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma, RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma,
noframe, fsaa, sync, noaccel); noframe, fsaa, sync, accel);
} }
return 0; return 0;
} }
......
...@@ -162,7 +162,7 @@ Render() ...@@ -162,7 +162,7 @@ Render()
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int fsaa, noaccel; int fsaa, accel;
int value; int value;
int i, done; int i, done;
SDL_DisplayMode mode; SDL_DisplayMode mode;
...@@ -172,7 +172,7 @@ main(int argc, char *argv[]) ...@@ -172,7 +172,7 @@ main(int argc, char *argv[])
/* Initialize parameters */ /* Initialize parameters */
fsaa = 0; fsaa = 0;
noaccel = 0; accel = -1;
/* Initialize test framework */ /* Initialize test framework */
state = CommonCreateState(argv, SDL_INIT_VIDEO); state = CommonCreateState(argv, SDL_INIT_VIDEO);
...@@ -187,15 +187,15 @@ main(int argc, char *argv[]) ...@@ -187,15 +187,15 @@ main(int argc, char *argv[])
if (SDL_strcasecmp(argv[i], "--fsaa") == 0) { if (SDL_strcasecmp(argv[i], "--fsaa") == 0) {
++fsaa; ++fsaa;
consumed = 1; consumed = 1;
} else if (SDL_strcasecmp(argv[i], "--noaccel") == 0) { } else if (SDL_strcasecmp(argv[i], "--accel") == 0 && i+1 < argc) {
++noaccel; accel = atoi(argv[i+1]);
consumed = 1; consumed = 2;
} else { } else {
consumed = -1; consumed = -1;
} }
} }
if (consumed < 0) { if (consumed < 0) {
fprintf(stderr, "Usage: %s %s [--fsaa] [--noaccel]\n", argv[0], fprintf(stderr, "Usage: %s %s [--fsaa] [--accel n]\n", argv[0],
CommonUsage(state)); CommonUsage(state));
quit(1); quit(1);
} }
...@@ -213,7 +213,9 @@ main(int argc, char *argv[]) ...@@ -213,7 +213,9 @@ main(int argc, char *argv[])
state->gl_multisamplebuffers = 1; state->gl_multisamplebuffers = 1;
state->gl_multisamplesamples = fsaa; state->gl_multisamplesamples = fsaa;
} }
state->gl_accelerated = !noaccel; if (accel >= 0) {
state->gl_accelerated = accel;
}
if (!CommonInit(state)) { if (!CommonInit(state)) {
quit(2); quit(2);
...@@ -282,13 +284,15 @@ main(int argc, char *argv[]) ...@@ -282,13 +284,15 @@ main(int argc, char *argv[])
SDL_GetError()); SDL_GetError());
} }
} }
status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); if (accel >= 0) {
if (!status) { status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value);
printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", !noaccel, if (!status) {
value); printf("SDL_GL_ACCELERATED_VISUAL: requested %d, got %d\n", accel,
} else { value);
printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", } else {
SDL_GetError()); printf("Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n",
SDL_GetError());
}
} }
/* Set rendering settings */ /* Set rendering settings */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment