61 Com_Printf(
"\n------- video initialization -------\n");
67 SDL_GL_LoadLibrary(
r_driver->string);
71 Sys_Setenv(
"SDL_VIDEO_ALLOW_SCREENSAVER",
"0");
73 if (SDL_WasInit(SDL_INIT_VIDEO) == 0) {
74 if (SDL_Init(SDL_INIT_VIDEO) < 0)
79 Com_Printf(
"I: SDL version: %i.%i.%i\n", version.major, version.minor, version.patch);
84 int selectedDisplay = 0;
86 const int displays = SDL_GetNumVideoDisplays();
87 Com_Printf(
"I: found %i display(s)\n", displays);
92 for (
int display = 0; display < displays; display++) {
93 if (SDL_GetDisplayName(display))
94 Com_Printf(
"I: display %i name: %s\n", display, SDL_GetDisplayName(display));
96 SDL_Rect displayBounds;
97 if (SDL_GetDisplayBounds(display, &displayBounds) == 0) {
98 Com_Printf(
"I: display %i bounds: x: %i, y: %i, w: %i, h: %i\n", display,
99 displayBounds.x, displayBounds.y, displayBounds.w, displayBounds.h);
100 if (posLeft >= displayBounds.x && posLeft < displayBounds.x + displayBounds.w
101 && posTop >= displayBounds.y && posTop < displayBounds.y + displayBounds.h)
102 selectedDisplay = display;
104 Com_Printf(
"W: failed to determine display %i bounds: %s\n", display, SDL_GetError());
107 SDL_DisplayMode displayMode;
108 if (SDL_GetDesktopDisplayMode(display, &displayMode) != -1) {
109 const char*
name = SDL_GetPixelFormatName(displayMode.format);
110 Com_Printf(
"I: display %i current desktop mode: %dx%d@%dHz (%s)\n",
111 display, displayMode.w, displayMode.h, displayMode.refresh_rate,
name);
112 if (display == selectedDisplay) {
117 Com_Printf(
"E: failed to get the desktop mode\n");
121 const int modes = SDL_GetNumDisplayModes(selectedDisplay);
124 for (
int i = 0;
i < modes;
i++) {
125 SDL_DisplayMode displayMode;
126 SDL_GetDisplayMode(selectedDisplay,
i, &displayMode);
132 const int videoDrivers = SDL_GetNumVideoDrivers();
133 for (
int i = 0;
i < videoDrivers; ++
i) {
134 Com_Printf(
"I: available video driver: %s\n", SDL_GetVideoDriver(
i));
136 Com_Printf(
"I: current video driver: %s\n", SDL_GetCurrentVideoDriver());
138 SDL_SetModState(KMOD_NONE);
154 if (!SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &attrValue))
155 Com_Printf(
"I: got %d bits of stencil\n", attrValue);
156 if (!SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &attrValue))
157 Com_Printf(
"I: got %d bits of depth buffer\n", attrValue);
158 if (!SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &attrValue))
160 if (!SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &attrValue))
161 Com_Printf(
"I: got %d bits for red\n", attrValue);
162 if (!SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &attrValue))
163 Com_Printf(
"I: got %d bits for green\n", attrValue);
164 if (!SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &attrValue))
165 Com_Printf(
"I: got %d bits for blue\n", attrValue);
166 if (!SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &attrValue))
167 Com_Printf(
"I: got %d bits for alpha\n", attrValue);
168 if (!SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &attrValue))
169 Com_Printf(
"I: got multisample %s\n", attrValue != 0 ?
"enabled" :
"disabled");
170 if (!SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &attrValue))
171 Com_Printf(
"I: got %d multisample buffers\n", attrValue);
181 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
182 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
183 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
187 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
188 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, context->
multisample);
190 Com_Printf(
"I: disable multisample buffers\n");
191 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
192 SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
195#ifdef GL_VERSION_ES_CM_1_0
197 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
198 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
201 const int i = std::min(1, std::max(-1, context->
swapinterval));
203 SDL_GL_SetSwapInterval(
i);
204 uint32_t flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN;
207 flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
209 cls.window = SDL_CreateWindow(
218 const char* error = SDL_GetError();
219 Com_Printf(
"E: SDL_CreateWindow failed: %s\n", error);
223 cls.context = SDL_GL_CreateContext(
cls.window);
225 SDL_ShowCursor(SDL_DISABLE);
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
Contains the game screen context, everything that is needed to create the graphic context....