comparison src/video/SDL_video.c @ 1724:6c63fc2bd986 SDL-1.3

Proof of concept done - Win32 GDI implementation mostly complete.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 06 Jul 2006 07:17:11 +0000
parents a1ebb17f9c52
children 98a3207ddde8
comparison
equal deleted inserted replaced
1723:4bdbb9b2bd0a 1724:6c63fc2bd986
185 if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) { 185 if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) {
186 SDL_SetError("OS doesn't support threaded events"); 186 SDL_SetError("OS doesn't support threaded events");
187 return -1; 187 return -1;
188 } 188 }
189 #endif 189 #endif
190
191 /* Start the event loop */
192 if (SDL_StartEventLoop(flags) < 0) {
193 return -1;
194 }
190 195
191 /* Check to make sure we don't overwrite '_this' */ 196 /* Check to make sure we don't overwrite '_this' */
192 if (_this != NULL) { 197 if (_this != NULL) {
193 SDL_VideoQuit(); 198 SDL_VideoQuit();
194 } 199 }
275 if (_this->displays[i].num_render_drivers > 0) { 280 if (_this->displays[i].num_render_drivers > 0) {
276 SDL_AddRenderDriver(i, &SDL_SW_RenderDriver); 281 SDL_AddRenderDriver(i, &SDL_SW_RenderDriver);
277 } 282 }
278 } 283 }
279 284
280 /* Start the event loop */
281 if (SDL_StartEventLoop(flags) < 0) {
282 SDL_VideoQuit();
283 return -1;
284 }
285
286 /* We're ready to go! */ 285 /* We're ready to go! */
287 return 0; 286 return 0;
288 } 287 }
289 288
290 const char * 289 const char *
1284 return 0; 1283 return 0;
1285 } 1284 }
1286 } 1285 }
1287 1286
1288 /* Copy the palette if any */ 1287 /* Copy the palette if any */
1289 if (fmt->palette) { 1288 if (SDL_ISPIXELFORMAT_INDEXED(format)) {
1290 SDL_SetTexturePalette(textureID, fmt->palette->colors, 0, 1289 if (fmt->palette) {
1291 fmt->palette->ncolors); 1290 SDL_SetTexturePalette(textureID, fmt->palette->colors, 0,
1292 SDL_SetSurfacePalette(&dst, fmt->palette); 1291 fmt->palette->ncolors);
1292 SDL_SetSurfacePalette(&dst, fmt->palette);
1293 } else {
1294 dst.format->palette =
1295 SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
1296 if (!dst.format->palette) {
1297 SDL_DestroyTexture(textureID);
1298 SDL_FreeFormat(dst.format);
1299 return 0;
1300 }
1301 SDL_DitherColors(dst.format->palette->colors,
1302 SDL_BITSPERPIXEL(format));
1303 }
1293 } 1304 }
1294 1305
1295 /* Make the texture transparent if the surface has colorkey */ 1306 /* Make the texture transparent if the surface has colorkey */
1296 if (surface_flags & SDL_SRCCOLORKEY) { 1307 if (surface_flags & SDL_SRCCOLORKEY) {
1297 int row; 1308 int row;
1555 1566
1556 int 1567 int
1557 SDL_RenderFill(const SDL_Rect * rect, Uint32 color) 1568 SDL_RenderFill(const SDL_Rect * rect, Uint32 color)
1558 { 1569 {
1559 SDL_Renderer *renderer; 1570 SDL_Renderer *renderer;
1560 SDL_Rect full_rect; 1571 SDL_Window *window;
1572 SDL_Rect real_rect;
1561 1573
1562 if (!_this) { 1574 if (!_this) {
1563 return -1; 1575 return -1;
1564 } 1576 }
1565 1577
1566 renderer = SDL_CurrentDisplay.current_renderer; 1578 renderer = SDL_CurrentDisplay.current_renderer;
1567 if (!renderer || !renderer->RenderFill) { 1579 if (!renderer || !renderer->RenderFill) {
1568 return -1; 1580 return -1;
1569 } 1581 }
1570 1582
1571 if (!rect) { 1583 window = SDL_GetWindowFromID(renderer->window);
1572 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 1584 real_rect.x = 0;
1573 full_rect.x = 0; 1585 real_rect.y = 0;
1574 full_rect.y = 0; 1586 real_rect.w = window->w;
1575 full_rect.w = window->w; 1587 real_rect.h = window->h;
1576 full_rect.h = window->h; 1588 if (rect) {
1577 rect = &full_rect; 1589 if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
1578 } 1590 return 0;
1591 }
1592 }
1593 rect = &real_rect;
1579 1594
1580 return renderer->RenderFill(renderer, rect, color); 1595 return renderer->RenderFill(renderer, rect, color);
1581 } 1596 }
1582 1597
1583 int 1598 int
1584 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, 1599 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect,
1585 const SDL_Rect * dstrect, int blendMode, int scaleMode) 1600 const SDL_Rect * dstrect, int blendMode, int scaleMode)
1586 { 1601 {
1587 SDL_Texture *texture = SDL_GetTextureFromID(textureID); 1602 SDL_Texture *texture = SDL_GetTextureFromID(textureID);
1588 SDL_Renderer *renderer; 1603 SDL_Renderer *renderer;
1589 SDL_Rect full_srcrect; 1604 SDL_Window *window;
1590 SDL_Rect full_dstrect; 1605 SDL_Rect real_srcrect;
1606 SDL_Rect real_dstrect;
1591 1607
1592 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) { 1608 if (!texture || texture->renderer != SDL_CurrentDisplay.current_renderer) {
1593 return -1; 1609 return -1;
1594 } 1610 }
1595 1611
1596 renderer = SDL_CurrentDisplay.current_renderer; 1612 renderer = SDL_CurrentDisplay.current_renderer;
1597 if (!renderer || !renderer->RenderCopy) { 1613 if (!renderer || !renderer->RenderCopy) {
1598 return -1; 1614 return -1;
1599 } 1615 }
1600 1616
1617 /* FIXME: implement clipping */
1618 window = SDL_GetWindowFromID(renderer->window);
1619 real_srcrect.x = 0;
1620 real_srcrect.y = 0;
1621 real_srcrect.w = texture->w;
1622 real_srcrect.h = texture->h;
1623 real_dstrect.x = 0;
1624 real_dstrect.y = 0;
1625 real_dstrect.w = window->w;
1626 real_dstrect.h = window->h;
1601 if (!srcrect) { 1627 if (!srcrect) {
1602 full_srcrect.x = 0; 1628 srcrect = &real_srcrect;
1603 full_srcrect.y = 0;
1604 full_srcrect.w = texture->w;
1605 full_srcrect.h = texture->h;
1606 srcrect = &full_srcrect;
1607 } 1629 }
1608 if (!dstrect) { 1630 if (!dstrect) {
1609 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 1631 dstrect = &real_dstrect;
1610 full_dstrect.x = 0;
1611 full_dstrect.y = 0;
1612 full_dstrect.w = window->w;
1613 full_dstrect.h = window->h;
1614 dstrect = &full_dstrect;
1615 } 1632 }
1616 1633
1617 return renderer->RenderCopy(renderer, texture, srcrect, dstrect, 1634 return renderer->RenderCopy(renderer, texture, srcrect, dstrect,
1618 blendMode, scaleMode); 1635 blendMode, scaleMode);
1619 } 1636 }