| 1 | <HTML |
| 2 | ><HEAD |
| 3 | ><TITLE |
| 4 | >SDL_SetVideoMode</TITLE |
| 5 | ><META |
| 6 | NAME="GENERATOR" |
| 7 | CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+ |
| 8 | "><LINK |
| 9 | REL="HOME" |
| 10 | TITLE="SDL Library Documentation" |
| 11 | HREF="index.html"><LINK |
| 12 | REL="UP" |
| 13 | TITLE="Video" |
| 14 | HREF="video.html"><LINK |
| 15 | REL="PREVIOUS" |
| 16 | TITLE="SDL_VideoModeOK" |
| 17 | HREF="sdlvideomodeok.html"><LINK |
| 18 | REL="NEXT" |
| 19 | TITLE="SDL_UpdateRect" |
| 20 | HREF="sdlupdaterect.html"></HEAD |
| 21 | ><BODY |
| 22 | CLASS="REFENTRY" |
| 23 | BGCOLOR="#FFF8DC" |
| 24 | TEXT="#000000" |
| 25 | LINK="#0000ee" |
| 26 | VLINK="#551a8b" |
| 27 | ALINK="#ff0000" |
| 28 | ><DIV |
| 29 | CLASS="NAVHEADER" |
| 30 | ><TABLE |
| 31 | SUMMARY="Header navigation table" |
| 32 | WIDTH="100%" |
| 33 | BORDER="0" |
| 34 | CELLPADDING="0" |
| 35 | CELLSPACING="0" |
| 36 | ><TR |
| 37 | ><TH |
| 38 | COLSPAN="3" |
| 39 | ALIGN="center" |
| 40 | >SDL Library Documentation</TH |
| 41 | ></TR |
| 42 | ><TR |
| 43 | ><TD |
| 44 | WIDTH="10%" |
| 45 | ALIGN="left" |
| 46 | VALIGN="bottom" |
| 47 | ><A |
| 48 | HREF="sdlvideomodeok.html" |
| 49 | ACCESSKEY="P" |
| 50 | >Prev</A |
| 51 | ></TD |
| 52 | ><TD |
| 53 | WIDTH="80%" |
| 54 | ALIGN="center" |
| 55 | VALIGN="bottom" |
| 56 | ></TD |
| 57 | ><TD |
| 58 | WIDTH="10%" |
| 59 | ALIGN="right" |
| 60 | VALIGN="bottom" |
| 61 | ><A |
| 62 | HREF="sdlupdaterect.html" |
| 63 | ACCESSKEY="N" |
| 64 | >Next</A |
| 65 | ></TD |
| 66 | ></TR |
| 67 | ></TABLE |
| 68 | ><HR |
| 69 | ALIGN="LEFT" |
| 70 | WIDTH="100%"></DIV |
| 71 | ><H1 |
| 72 | ><A |
| 73 | NAME="SDLSETVIDEOMODE" |
| 74 | ></A |
| 75 | >SDL_SetVideoMode</H1 |
| 76 | ><DIV |
| 77 | CLASS="REFNAMEDIV" |
| 78 | ><A |
| 79 | NAME="AEN1239" |
| 80 | ></A |
| 81 | ><H2 |
| 82 | >Name</H2 |
| 83 | >SDL_SetVideoMode -- Set up a video mode with the specified width, height and bits-per-pixel.</DIV |
| 84 | ><DIV |
| 85 | CLASS="REFSYNOPSISDIV" |
| 86 | ><A |
| 87 | NAME="AEN1242" |
| 88 | ></A |
| 89 | ><H2 |
| 90 | >Synopsis</H2 |
| 91 | ><DIV |
| 92 | CLASS="FUNCSYNOPSIS" |
| 93 | ><A |
| 94 | NAME="AEN1243" |
| 95 | ></A |
| 96 | ><P |
| 97 | ></P |
| 98 | ><PRE |
| 99 | CLASS="FUNCSYNOPSISINFO" |
| 100 | >#include "SDL.h"</PRE |
| 101 | ><P |
| 102 | ><CODE |
| 103 | ><CODE |
| 104 | CLASS="FUNCDEF" |
| 105 | >SDL_Surface *<B |
| 106 | CLASS="FSFUNC" |
| 107 | >SDL_SetVideoMode</B |
| 108 | ></CODE |
| 109 | >(int width, int height, int bpp, Uint32 flags);</CODE |
| 110 | ></P |
| 111 | ><P |
| 112 | ></P |
| 113 | ></DIV |
| 114 | ></DIV |
| 115 | ><DIV |
| 116 | CLASS="REFSECT1" |
| 117 | ><A |
| 118 | NAME="AEN1249" |
| 119 | ></A |
| 120 | ><H2 |
| 121 | >Description</H2 |
| 122 | ><P |
| 123 | >Set up a video mode with the specified width, height and bits-per-pixel.</P |
| 124 | ><P |
| 125 | >If <TT |
| 126 | CLASS="PARAMETER" |
| 127 | ><I |
| 128 | >bpp</I |
| 129 | ></TT |
| 130 | > is 0, it is treated as the |
| 131 | current display bits per pixel.</P |
| 132 | ><P |
| 133 | >The <TT |
| 134 | CLASS="PARAMETER" |
| 135 | ><I |
| 136 | >flags</I |
| 137 | ></TT |
| 138 | > parameter is the same as the <TT |
| 139 | CLASS="STRUCTFIELD" |
| 140 | ><I |
| 141 | >flags</I |
| 142 | ></TT |
| 143 | > field of the <A |
| 144 | HREF="sdlsurface.html" |
| 145 | ><SPAN |
| 146 | CLASS="STRUCTNAME" |
| 147 | >SDL_Surface</SPAN |
| 148 | ></A |
| 149 | > structure. OR'd combinations of the following values are valid.</P |
| 150 | ><DIV |
| 151 | CLASS="INFORMALTABLE" |
| 152 | ><A |
| 153 | NAME="AEN1259" |
| 154 | ></A |
| 155 | ><P |
| 156 | ></P |
| 157 | ><TABLE |
| 158 | BORDER="1" |
| 159 | CLASS="CALSTABLE" |
| 160 | ><TBODY |
| 161 | ><TR |
| 162 | ><TD |
| 163 | ALIGN="LEFT" |
| 164 | VALIGN="TOP" |
| 165 | ><TT |
| 166 | CLASS="LITERAL" |
| 167 | >SDL_SWSURFACE</TT |
| 168 | ></TD |
| 169 | ><TD |
| 170 | ALIGN="LEFT" |
| 171 | VALIGN="TOP" |
| 172 | >Create the video surface in system memory</TD |
| 173 | ></TR |
| 174 | ><TR |
| 175 | ><TD |
| 176 | ALIGN="LEFT" |
| 177 | VALIGN="TOP" |
| 178 | ><TT |
| 179 | CLASS="LITERAL" |
| 180 | >SDL_HWSURFACE</TT |
| 181 | ></TD |
| 182 | ><TD |
| 183 | ALIGN="LEFT" |
| 184 | VALIGN="TOP" |
| 185 | >Create the video surface in video memory</TD |
| 186 | ></TR |
| 187 | ><TR |
| 188 | ><TD |
| 189 | ALIGN="LEFT" |
| 190 | VALIGN="TOP" |
| 191 | ><TT |
| 192 | CLASS="LITERAL" |
| 193 | >SDL_ASYNCBLIT</TT |
| 194 | ></TD |
| 195 | ><TD |
| 196 | ALIGN="LEFT" |
| 197 | VALIGN="TOP" |
| 198 | >Enables the use of asynchronous updates of the display surface. This will |
| 199 | usually slow down blitting on single CPU machines, but may provide a speed |
| 200 | increase on SMP systems.</TD |
| 201 | ></TR |
| 202 | ><TR |
| 203 | ><TD |
| 204 | ALIGN="LEFT" |
| 205 | VALIGN="TOP" |
| 206 | ><TT |
| 207 | CLASS="LITERAL" |
| 208 | >SDL_ANYFORMAT</TT |
| 209 | ></TD |
| 210 | ><TD |
| 211 | ALIGN="LEFT" |
| 212 | VALIGN="TOP" |
| 213 | >Normally, if a video surface of the requested bits-per-pixel (<TT |
| 214 | CLASS="PARAMETER" |
| 215 | ><I |
| 216 | >bpp</I |
| 217 | ></TT |
| 218 | >) is not available, SDL will emulate one with a shadow surface. Passing <TT |
| 219 | CLASS="LITERAL" |
| 220 | >SDL_ANYFORMAT</TT |
| 221 | > prevents this and causes SDL to use the video surface, regardless of its pixel depth.</TD |
| 222 | ></TR |
| 223 | ><TR |
| 224 | ><TD |
| 225 | ALIGN="LEFT" |
| 226 | VALIGN="TOP" |
| 227 | ><TT |
| 228 | CLASS="LITERAL" |
| 229 | >SDL_HWPALETTE</TT |
| 230 | ></TD |
| 231 | ><TD |
| 232 | ALIGN="LEFT" |
| 233 | VALIGN="TOP" |
| 234 | >Give SDL exclusive palette access. Without this flag you may not always get the the colors you request with <A |
| 235 | HREF="sdlsetcolors.html" |
| 236 | ><TT |
| 237 | CLASS="FUNCTION" |
| 238 | >SDL_SetColors</TT |
| 239 | ></A |
| 240 | > or <A |
| 241 | HREF="sdlsetpalette.html" |
| 242 | ><TT |
| 243 | CLASS="FUNCTION" |
| 244 | >SDL_SetPalette</TT |
| 245 | ></A |
| 246 | >.</TD |
| 247 | ></TR |
| 248 | ><TR |
| 249 | ><TD |
| 250 | ALIGN="LEFT" |
| 251 | VALIGN="TOP" |
| 252 | ><TT |
| 253 | CLASS="LITERAL" |
| 254 | >SDL_DOUBLEBUF</TT |
| 255 | ></TD |
| 256 | ><TD |
| 257 | ALIGN="LEFT" |
| 258 | VALIGN="TOP" |
| 259 | >Enable hardware double buffering; only valid with SDL_HWSURFACE. Calling |
| 260 | <A |
| 261 | HREF="sdlflip.html" |
| 262 | ><TT |
| 263 | CLASS="FUNCTION" |
| 264 | >SDL_Flip</TT |
| 265 | ></A |
| 266 | > will flip the |
| 267 | buffers and update the screen. All drawing will take place on the surface |
| 268 | that is not displayed at the moment. If double buffering could not be enabled |
| 269 | then <TT |
| 270 | CLASS="FUNCTION" |
| 271 | >SDL_Flip</TT |
| 272 | > will just perform a |
| 273 | <A |
| 274 | HREF="sdlupdaterect.html" |
| 275 | ><TT |
| 276 | CLASS="FUNCTION" |
| 277 | >SDL_UpdateRect</TT |
| 278 | ></A |
| 279 | > |
| 280 | on the entire screen.</TD |
| 281 | ></TR |
| 282 | ><TR |
| 283 | ><TD |
| 284 | ALIGN="LEFT" |
| 285 | VALIGN="TOP" |
| 286 | ><TT |
| 287 | CLASS="LITERAL" |
| 288 | >SDL_FULLSCREEN</TT |
| 289 | ></TD |
| 290 | ><TD |
| 291 | ALIGN="LEFT" |
| 292 | VALIGN="TOP" |
| 293 | >SDL will attempt to use a fullscreen mode. If a hardware resolution change is |
| 294 | not possible (for whatever reason), the next higher resolution will be used and |
| 295 | the display window centered on a black background.</TD |
| 296 | ></TR |
| 297 | ><TR |
| 298 | ><TD |
| 299 | ALIGN="LEFT" |
| 300 | VALIGN="TOP" |
| 301 | ><TT |
| 302 | CLASS="LITERAL" |
| 303 | >SDL_OPENGL</TT |
| 304 | ></TD |
| 305 | ><TD |
| 306 | ALIGN="LEFT" |
| 307 | VALIGN="TOP" |
| 308 | >Create an OpenGL rendering context. You should have previously set OpenGL video attributes with <A |
| 309 | HREF="sdlglsetattribute.html" |
| 310 | ><TT |
| 311 | CLASS="FUNCTION" |
| 312 | >SDL_GL_SetAttribute</TT |
| 313 | ></A |
| 314 | >.</TD |
| 315 | ></TR |
| 316 | ><TR |
| 317 | ><TD |
| 318 | ALIGN="LEFT" |
| 319 | VALIGN="TOP" |
| 320 | ><TT |
| 321 | CLASS="LITERAL" |
| 322 | >SDL_OPENGLBLIT</TT |
| 323 | ></TD |
| 324 | ><TD |
| 325 | ALIGN="LEFT" |
| 326 | VALIGN="TOP" |
| 327 | >Create an OpenGL rendering context, like above, but allow normal blitting |
| 328 | operations. The screen (2D) surface may have an alpha channel, and |
| 329 | <A |
| 330 | HREF="sdlupdaterects.html" |
| 331 | ><TT |
| 332 | CLASS="FUNCTION" |
| 333 | >SDL_UpdateRects</TT |
| 334 | ></A |
| 335 | > |
| 336 | must be used for updating changes to the screen surface. NOTE: This option |
| 337 | is kept for compatibility only, and is <SPAN |
| 338 | CLASS="emphasis" |
| 339 | ><I |
| 340 | CLASS="EMPHASIS" |
| 341 | >not</I |
| 342 | ></SPAN |
| 343 | > recommended for |
| 344 | new code.</TD |
| 345 | ></TR |
| 346 | ><TR |
| 347 | ><TD |
| 348 | ALIGN="LEFT" |
| 349 | VALIGN="TOP" |
| 350 | ><TT |
| 351 | CLASS="LITERAL" |
| 352 | >SDL_RESIZABLE</TT |
| 353 | ></TD |
| 354 | ><TD |
| 355 | ALIGN="LEFT" |
| 356 | VALIGN="TOP" |
| 357 | >Create a resizable window. When the window is resized by the user a <A |
| 358 | HREF="sdlresizeevent.html" |
| 359 | ><TT |
| 360 | CLASS="LITERAL" |
| 361 | >SDL_VIDEORESIZE</TT |
| 362 | ></A |
| 363 | > event is generated and <TT |
| 364 | CLASS="FUNCTION" |
| 365 | >SDL_SetVideoMode</TT |
| 366 | > can be called again with the new size.</TD |
| 367 | ></TR |
| 368 | ><TR |
| 369 | ><TD |
| 370 | ALIGN="LEFT" |
| 371 | VALIGN="TOP" |
| 372 | ><TT |
| 373 | CLASS="LITERAL" |
| 374 | >SDL_NOFRAME</TT |
| 375 | ></TD |
| 376 | ><TD |
| 377 | ALIGN="LEFT" |
| 378 | VALIGN="TOP" |
| 379 | >If possible, <TT |
| 380 | CLASS="LITERAL" |
| 381 | >SDL_NOFRAME</TT |
| 382 | > causes SDL to create a window with no title bar or frame decoration. Fullscreen modes automatically have this flag set.</TD |
| 383 | ></TR |
| 384 | ></TBODY |
| 385 | ></TABLE |
| 386 | ><P |
| 387 | ></P |
| 388 | ></DIV |
| 389 | ><DIV |
| 390 | CLASS="NOTE" |
| 391 | ><BLOCKQUOTE |
| 392 | CLASS="NOTE" |
| 393 | ><P |
| 394 | ><B |
| 395 | >Note: </B |
| 396 | >Whatever <TT |
| 397 | CLASS="PARAMETER" |
| 398 | ><I |
| 399 | >flags</I |
| 400 | ></TT |
| 401 | > <TT |
| 402 | CLASS="FUNCTION" |
| 403 | >SDL_SetVideoMode</TT |
| 404 | > could satisfy are set in the <TT |
| 405 | CLASS="STRUCTFIELD" |
| 406 | ><I |
| 407 | >flags</I |
| 408 | ></TT |
| 409 | > member of the returned surface.</P |
| 410 | ></BLOCKQUOTE |
| 411 | ></DIV |
| 412 | ><DIV |
| 413 | CLASS="NOTE" |
| 414 | ><BLOCKQUOTE |
| 415 | CLASS="NOTE" |
| 416 | ><P |
| 417 | ><B |
| 418 | >Note: </B |
| 419 | >The <TT |
| 420 | CLASS="PARAMETER" |
| 421 | ><I |
| 422 | >bpp</I |
| 423 | ></TT |
| 424 | > parameter is the number of bits per pixel, |
| 425 | so a <TT |
| 426 | CLASS="PARAMETER" |
| 427 | ><I |
| 428 | >bpp</I |
| 429 | ></TT |
| 430 | > of 24 uses the packed representation of |
| 431 | 3 bytes/pixel. For the more common 4 bytes/pixel mode, use a |
| 432 | <TT |
| 433 | CLASS="PARAMETER" |
| 434 | ><I |
| 435 | >bpp</I |
| 436 | ></TT |
| 437 | > of 32. Somewhat oddly, both 15 and 16 will |
| 438 | request a 2 bytes/pixel mode, but different pixel formats.</P |
| 439 | ></BLOCKQUOTE |
| 440 | ></DIV |
| 441 | ></DIV |
| 442 | ><DIV |
| 443 | CLASS="REFSECT1" |
| 444 | ><A |
| 445 | NAME="AEN1336" |
| 446 | ></A |
| 447 | ><H2 |
| 448 | >Return Value</H2 |
| 449 | ><P |
| 450 | >The framebuffer surface, or <SPAN |
| 451 | CLASS="RETURNVALUE" |
| 452 | >NULL</SPAN |
| 453 | > if it fails. |
| 454 | The surface returned is freed by SDL_Quit() and should nt be freed by |
| 455 | the caller.</P |
| 456 | ></DIV |
| 457 | ><DIV |
| 458 | CLASS="REFSECT1" |
| 459 | ><A |
| 460 | NAME="AEN1340" |
| 461 | ></A |
| 462 | ><H2 |
| 463 | >See Also</H2 |
| 464 | ><P |
| 465 | ><A |
| 466 | HREF="sdllocksurface.html" |
| 467 | ><TT |
| 468 | CLASS="FUNCTION" |
| 469 | >SDL_LockSurface</TT |
| 470 | ></A |
| 471 | >, |
| 472 | <A |
| 473 | HREF="sdlsetcolors.html" |
| 474 | ><TT |
| 475 | CLASS="FUNCTION" |
| 476 | >SDL_SetColors</TT |
| 477 | ></A |
| 478 | >, |
| 479 | <A |
| 480 | HREF="sdlflip.html" |
| 481 | ><TT |
| 482 | CLASS="FUNCTION" |
| 483 | >SDL_Flip</TT |
| 484 | ></A |
| 485 | >, |
| 486 | <A |
| 487 | HREF="sdlsurface.html" |
| 488 | ><SPAN |
| 489 | CLASS="STRUCTNAME" |
| 490 | >SDL_Surface</SPAN |
| 491 | ></A |
| 492 | ></P |
| 493 | ></DIV |
| 494 | ><DIV |
| 495 | CLASS="NAVFOOTER" |
| 496 | ><HR |
| 497 | ALIGN="LEFT" |
| 498 | WIDTH="100%"><TABLE |
| 499 | SUMMARY="Footer navigation table" |
| 500 | WIDTH="100%" |
| 501 | BORDER="0" |
| 502 | CELLPADDING="0" |
| 503 | CELLSPACING="0" |
| 504 | ><TR |
| 505 | ><TD |
| 506 | WIDTH="33%" |
| 507 | ALIGN="left" |
| 508 | VALIGN="top" |
| 509 | ><A |
| 510 | HREF="sdlvideomodeok.html" |
| 511 | ACCESSKEY="P" |
| 512 | >Prev</A |
| 513 | ></TD |
| 514 | ><TD |
| 515 | WIDTH="34%" |
| 516 | ALIGN="center" |
| 517 | VALIGN="top" |
| 518 | ><A |
| 519 | HREF="index.html" |
| 520 | ACCESSKEY="H" |
| 521 | >Home</A |
| 522 | ></TD |
| 523 | ><TD |
| 524 | WIDTH="33%" |
| 525 | ALIGN="right" |
| 526 | VALIGN="top" |
| 527 | ><A |
| 528 | HREF="sdlupdaterect.html" |
| 529 | ACCESSKEY="N" |
| 530 | >Next</A |
| 531 | ></TD |
| 532 | ></TR |
| 533 | ><TR |
| 534 | ><TD |
| 535 | WIDTH="33%" |
| 536 | ALIGN="left" |
| 537 | VALIGN="top" |
| 538 | >SDL_VideoModeOK</TD |
| 539 | ><TD |
| 540 | WIDTH="34%" |
| 541 | ALIGN="center" |
| 542 | VALIGN="top" |
| 543 | ><A |
| 544 | HREF="video.html" |
| 545 | ACCESSKEY="U" |
| 546 | >Up</A |
| 547 | ></TD |
| 548 | ><TD |
| 549 | WIDTH="33%" |
| 550 | ALIGN="right" |
| 551 | VALIGN="top" |
| 552 | >SDL_UpdateRect</TD |
| 553 | ></TR |
| 554 | ></TABLE |
| 555 | ></DIV |
| 556 | ></BODY |
| 557 | ></HTML |
| 558 | > |