comparison src/video/SDL_video.c @ 1720:a1ebb17f9c52 SDL-1.3

Cleaned up a bunch of warnings, started adding Win32 event support
author Sam Lantinga <slouken@libsdl.org>
date Fri, 30 Jun 2006 05:42:49 +0000
parents 5b9f50c957ed
children 6c63fc2bd986
comparison
equal deleted inserted replaced
1719:5b9f50c957ed 1720:a1ebb17f9c52
175 SDL_VideoInit(const char *driver_name, Uint32 flags) 175 SDL_VideoInit(const char *driver_name, Uint32 flags)
176 { 176 {
177 SDL_VideoDevice *video; 177 SDL_VideoDevice *video;
178 int index; 178 int index;
179 int i; 179 int i;
180 int bpp;
181 Uint32 Rmask, Gmask, Bmask, Amask;
182 180
183 /* Toggle the event thread flags, based on OS requirements */ 181 /* Toggle the event thread flags, based on OS requirements */
184 #if defined(MUST_THREAD_EVENTS) 182 #if defined(MUST_THREAD_EVENTS)
185 flags |= SDL_INIT_EVENTTHREAD; 183 flags |= SDL_INIT_EVENTTHREAD;
186 #elif defined(CANT_THREAD_EVENTS) 184 #elif defined(CANT_THREAD_EVENTS)
522 int 520 int
523 SDL_SetDisplayMode(const SDL_DisplayMode * mode) 521 SDL_SetDisplayMode(const SDL_DisplayMode * mode)
524 { 522 {
525 SDL_VideoDisplay *display; 523 SDL_VideoDisplay *display;
526 SDL_DisplayMode display_mode; 524 SDL_DisplayMode display_mode;
527 int i, ncolors; 525 int ncolors;
528 526
529 if (!_this) { 527 if (!_this) {
530 SDL_SetError("Video subsystem has not been initialized"); 528 SDL_SetError("Video subsystem has not been initialized");
531 return -1; 529 return -1;
532 } 530 }
598 596
599 if (!_this) { 597 if (!_this) {
600 SDL_SetError("Video subsystem has not been initialized"); 598 SDL_SetError("Video subsystem has not been initialized");
601 return -1; 599 return -1;
602 } 600 }
603 if (!SDL_CurrentDisplay.palette) { 601 palette = SDL_CurrentDisplay.palette;
602 if (!palette) {
604 SDL_SetError("Display mode does not have a palette"); 603 SDL_SetError("Display mode does not have a palette");
605 return -1; 604 return -1;
606 } 605 }
607 606
608 status = 607 status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors);
609 SDL_SetPaletteColors(SDL_CurrentDisplay.palette, colors, firstcolor,
610 ncolors);
611 608
612 if (_this->SetDisplayPalette) { 609 if (_this->SetDisplayPalette) {
613 if (_this->SetDisplayPalette(_this, palette) < 0) { 610 if (_this->SetDisplayPalette(_this, palette) < 0) {
614 status = -1; 611 status = -1;
615 } 612 }
1220 SDL_CreateTextureFromSurface(Uint32 format, int access, SDL_Surface * surface) 1217 SDL_CreateTextureFromSurface(Uint32 format, int access, SDL_Surface * surface)
1221 { 1218 {
1222 SDL_TextureID textureID; 1219 SDL_TextureID textureID;
1223 Uint32 surface_flags = surface->flags; 1220 Uint32 surface_flags = surface->flags;
1224 SDL_PixelFormat *fmt = surface->format; 1221 SDL_PixelFormat *fmt = surface->format;
1225 Uint32 colorkey;
1226 Uint8 alpha; 1222 Uint8 alpha;
1227 SDL_Rect bounds; 1223 SDL_Rect bounds;
1228 SDL_Surface dst; 1224 SDL_Surface dst;
1229 int bpp; 1225 int bpp;
1230 Uint32 Rmask, Gmask, Bmask, Amask; 1226 Uint32 Rmask, Gmask, Bmask, Amask;
1326 bounds.w = surface->w; 1322 bounds.w = surface->w;
1327 bounds.h = surface->h; 1323 bounds.h = surface->h;
1328 SDL_LowerBlit(surface, &bounds, &dst, &bounds); 1324 SDL_LowerBlit(surface, &bounds, &dst, &bounds);
1329 1325
1330 /* Clean up the original surface */ 1326 /* Clean up the original surface */
1331 if ((surface_flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
1332 Uint32 cflags = surface_flags & (SDL_SRCCOLORKEY | SDL_RLEACCELOK);
1333 SDL_SetColorKey(surface, cflags, colorkey);
1334 }
1335 if ((surface_flags & SDL_SRCALPHA) == SDL_SRCALPHA) { 1327 if ((surface_flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
1336 Uint32 aflags = surface_flags & (SDL_SRCALPHA | SDL_RLEACCELOK); 1328 Uint32 aflags = surface_flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
1337 if (fmt->Amask) { 1329 if (fmt->Amask) {
1338 surface->flags |= SDL_SRCALPHA; 1330 surface->flags |= SDL_SRCALPHA;
1339 } else { 1331 } else {
1522 1514
1523 renderer = texture->renderer; 1515 renderer = texture->renderer;
1524 if (!renderer->UnlockTexture) { 1516 if (!renderer->UnlockTexture) {
1525 return; 1517 return;
1526 } 1518 }
1527 return renderer->UnlockTexture(renderer, texture); 1519 renderer->UnlockTexture(renderer, texture);
1528 } 1520 }
1529 1521
1530 void 1522 void
1531 SDL_DirtyTexture(SDL_TextureID textureID, int numrects, 1523 SDL_DirtyTexture(SDL_TextureID textureID, int numrects,
1532 const SDL_Rect * rects) 1524 const SDL_Rect * rects)
1583 full_rect.w = window->w; 1575 full_rect.w = window->w;
1584 full_rect.h = window->h; 1576 full_rect.h = window->h;
1585 rect = &full_rect; 1577 rect = &full_rect;
1586 } 1578 }
1587 1579
1588 renderer->RenderFill(renderer, rect, color); 1580 return renderer->RenderFill(renderer, rect, color);
1589 } 1581 }
1590 1582
1591 int 1583 int
1592 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, 1584 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect,
1593 const SDL_Rect * dstrect, int blendMode, int scaleMode) 1585 const SDL_Rect * dstrect, int blendMode, int scaleMode)
1596 SDL_Renderer *renderer; 1588 SDL_Renderer *renderer;
1597 SDL_Rect full_srcrect; 1589 SDL_Rect full_srcrect;
1598 SDL_Rect full_dstrect; 1590 SDL_Rect full_dstrect;
1599 1591
1600 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) { 1592 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) {
1601 return; 1593 return -1;
1602 } 1594 }
1603 1595
1604 renderer = SDL_CurrentDisplay.current_renderer; 1596 renderer = SDL_CurrentDisplay.current_renderer;
1605 if (!renderer || !renderer->RenderCopy) { 1597 if (!renderer || !renderer->RenderCopy) {
1606 return -1; 1598 return -1;
2040 } 2032 }
2041 } 2033 }
2042 #endif 2034 #endif
2043 2035
2044 SDL_bool 2036 SDL_bool
2045 SDL_GetWindowWMInfo(SDL_WindowID windowID, SDL_SysWMinfo * info) 2037 SDL_GetWindowWMInfo(SDL_WindowID windowID, struct SDL_SysWMinfo *info)
2046 { 2038 {
2047 SDL_Window *window = SDL_GetWindowFromID(windowID); 2039 SDL_Window *window = SDL_GetWindowFromID(windowID);
2048 2040
2049 if (!window || !_this->GetWindowWMInfo) { 2041 if (!window || !_this->GetWindowWMInfo) {
2050 return SDL_FALSE; 2042 return SDL_FALSE;