Mercurial > sdl-ios-xcode
comparison src/video/SDL_video.c @ 2884:9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions
> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>
I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.
Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.
The diff also includes
a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 20 Dec 2008 12:00:00 +0000 |
parents | 3fcb0d447bcd |
children | ca6499468250 |
comparison
equal
deleted
inserted
replaced
2883:11626a53e7bc | 2884:9dde605c7540 |
---|---|
1973 } | 1973 } |
1974 renderer->DirtyTexture(renderer, texture, numrects, rects); | 1974 renderer->DirtyTexture(renderer, texture, numrects, rects); |
1975 } | 1975 } |
1976 | 1976 |
1977 int | 1977 int |
1978 SDL_RenderFill(Uint8 r, Uint8 g, Uint8 b, Uint8 a, const SDL_Rect * rect) | 1978 SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
1979 { | |
1980 SDL_Renderer *renderer; | |
1981 | |
1982 if (!_this) { | |
1983 SDL_UninitializedVideo(); | |
1984 return -1; | |
1985 } | |
1986 renderer = SDL_CurrentDisplay.current_renderer; | |
1987 if (!renderer) { | |
1988 return -1; | |
1989 } | |
1990 if (!renderer->SetDrawColor) { | |
1991 SDL_Unsupported(); | |
1992 return -1; | |
1993 } | |
1994 renderer->r = r; | |
1995 renderer->g = g; | |
1996 renderer->b = b; | |
1997 renderer->a = a; | |
1998 renderer->SetDrawColor(renderer); | |
1999 return 0; | |
2000 } | |
2001 | |
2002 int | |
2003 SDL_GetRenderDrawColor(Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) | |
2004 { | |
2005 SDL_Renderer *renderer; | |
2006 | |
2007 if (!_this) { | |
2008 SDL_UninitializedVideo(); | |
2009 return -1; | |
2010 } | |
2011 renderer = SDL_CurrentDisplay.current_renderer; | |
2012 if (!renderer) { | |
2013 return -1; | |
2014 } | |
2015 if (!renderer->SetDrawColor) { | |
2016 SDL_Unsupported(); | |
2017 return -1; | |
2018 } | |
2019 if (r) { | |
2020 *r = renderer->r; | |
2021 } | |
2022 if (g) { | |
2023 *g = renderer->g; | |
2024 } | |
2025 if (b) { | |
2026 *b = renderer->b; | |
2027 } | |
2028 if (a) { | |
2029 *a = renderer->a; | |
2030 } | |
2031 return 0; | |
2032 } | |
2033 | |
2034 int | |
2035 SDL_SetRenderDrawBlendMode(int blendMode) | |
2036 { | |
2037 SDL_Renderer *renderer; | |
2038 | |
2039 if (!_this) { | |
2040 SDL_UninitializedVideo(); | |
2041 return -1; | |
2042 } | |
2043 renderer = SDL_CurrentDisplay.current_renderer; | |
2044 if (!renderer) { | |
2045 return -1; | |
2046 } | |
2047 if (!renderer->SetDrawBlendMode) { | |
2048 SDL_Unsupported(); | |
2049 return -1; | |
2050 } | |
2051 renderer->blendMode = blendMode; | |
2052 renderer->SetDrawBlendMode(renderer); | |
2053 return 0; | |
2054 } | |
2055 | |
2056 int | |
2057 SDL_GetRenderDrawBlendMode(int *blendMode) | |
2058 { | |
2059 SDL_Renderer *renderer; | |
2060 | |
2061 if (!_this) { | |
2062 SDL_UninitializedVideo(); | |
2063 return -1; | |
2064 } | |
2065 renderer = SDL_CurrentDisplay.current_renderer; | |
2066 if (!renderer) { | |
2067 return -1; | |
2068 } | |
2069 *blendMode = renderer->blendMode; | |
2070 return 0; | |
2071 } | |
2072 | |
2073 | |
2074 int | |
2075 SDL_RenderFill(const SDL_Rect * rect) | |
1979 { | 2076 { |
1980 SDL_Renderer *renderer; | 2077 SDL_Renderer *renderer; |
1981 SDL_Window *window; | 2078 SDL_Window *window; |
1982 SDL_Rect real_rect; | 2079 SDL_Rect real_rect; |
1983 | 2080 |
2001 if (rect) { | 2098 if (rect) { |
2002 if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { | 2099 if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { |
2003 return 0; | 2100 return 0; |
2004 } | 2101 } |
2005 } | 2102 } |
2006 return renderer->RenderFill(renderer, r, g, b, a, &real_rect); | 2103 return renderer->RenderFill(renderer, &real_rect); |
2104 } | |
2105 | |
2106 int | |
2107 SDL_RenderLine(int x1, int y1, int x2, int y2) | |
2108 { | |
2109 SDL_Renderer *renderer; | |
2110 SDL_Window *window; | |
2111 SDL_Rect real_rect; | |
2112 | |
2113 if (!_this) { | |
2114 SDL_UninitializedVideo(); | |
2115 return -1; | |
2116 } | |
2117 renderer = SDL_CurrentDisplay.current_renderer; | |
2118 if (!renderer) { | |
2119 return -1; | |
2120 } | |
2121 if (!renderer->RenderLine) { | |
2122 SDL_Unsupported(); | |
2123 return -1; | |
2124 } | |
2125 #if 0 | |
2126 //FIXME: Need line intersect routine | |
2127 window = SDL_GetWindowFromID(renderer->window); | |
2128 real_rect.x = 0; | |
2129 real_rect.y = 0; | |
2130 real_rect.w = window->w; | |
2131 real_rect.h = window->h; | |
2132 if (rect) { | |
2133 if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { | |
2134 return 0; | |
2135 } | |
2136 } | |
2137 #endif | |
2138 return renderer->RenderLine(renderer, x1, y1, x2, y2); | |
2007 } | 2139 } |
2008 | 2140 |
2009 int | 2141 int |
2010 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, | 2142 SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect, |
2011 const SDL_Rect * dstrect) | 2143 const SDL_Rect * dstrect) |