Mercurial > sdl-ios-xcode
annotate src/video/win32/SDL_gdirender.c @ 4929:aa8888658021
Use the enumerated type for blend and scale mode instead of int
Renamed SDL_TextureScaleMode to SDL_ScaleMode
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 12 Dec 2010 15:19:05 -0800 |
parents | e1664f94f026 |
children |
rev | line source |
---|---|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #if SDL_VIDEO_RENDER_GDI |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #include "SDL_win32video.h" |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
27 #include "../SDL_rect_c.h" |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #include "../SDL_yuv_sw_c.h" |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
29 #include "../SDL_alphamult.h" |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
31 #ifdef _WIN32_WCE |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
32 #define NO_GETDIBBITS 1 |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
33 #endif |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
34 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 /* GDI renderer implementation */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
37 static SDL_Renderer *GDI_CreateRenderer(SDL_Window * window, Uint32 flags); |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
38 static int GDI_DisplayModeChanged(SDL_Renderer * renderer); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
39 static int GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
40 static int GDI_QueryTexturePixels(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
41 SDL_Texture * texture, void **pixels, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
42 int *pitch); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
43 static int GDI_SetTexturePalette(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
44 SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
45 const SDL_Color * colors, int firstcolor, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
46 int ncolors); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
47 static int GDI_GetTexturePalette(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
48 SDL_Texture * texture, SDL_Color * colors, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
49 int firstcolor, int ncolors); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
50 static int GDI_SetTextureAlphaMod(SDL_Renderer * renderer, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
51 SDL_Texture * texture); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
52 static int GDI_SetTextureBlendMode(SDL_Renderer * renderer, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
53 SDL_Texture * texture); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
54 static int GDI_SetTextureScaleMode(SDL_Renderer * renderer, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
55 SDL_Texture * texture); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
56 static int GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
57 const SDL_Rect * rect, const void *pixels, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
58 int pitch); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
59 static int GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
60 const SDL_Rect * rect, int markDirty, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
61 void **pixels, int *pitch); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
62 static void GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
2927
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
63 static int GDI_SetDrawBlendMode(SDL_Renderer * renderer); |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
64 static int GDI_RenderDrawPoints(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
65 const SDL_Point * points, int count); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
66 static int GDI_RenderDrawLines(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
67 const SDL_Point * points, int count); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
68 static int GDI_RenderDrawRects(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
69 const SDL_Rect ** rects, int count); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
70 static int GDI_RenderFillRects(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
71 const SDL_Rect ** rects, int count); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
72 static int GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
73 const SDL_Rect * srcrect, const SDL_Rect * dstrect); |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
74 static int GDI_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
75 Uint32 format, void * pixels, int pitch); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
76 static int GDI_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
77 Uint32 format, const void * pixels, int pitch); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
78 static void GDI_RenderPresent(SDL_Renderer * renderer); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
79 static void GDI_DestroyTexture(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
80 SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
81 static void GDI_DestroyRenderer(SDL_Renderer * renderer); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
84 SDL_RenderDriver GDI_RenderDriver = { |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
85 GDI_CreateRenderer, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 "gdi", |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
88 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
89 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
90 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED), |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
91 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA), |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
92 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK), |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
4569
diff
changeset
|
93 (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST), |
2811
7af2419ad5b0
Fixed the list of supported YUV formats
Sam Lantinga <slouken@libsdl.org>
parents:
2810
diff
changeset
|
94 14, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
96 SDL_PIXELFORMAT_INDEX8, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
97 SDL_PIXELFORMAT_RGB555, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
98 SDL_PIXELFORMAT_RGB565, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
99 SDL_PIXELFORMAT_RGB888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
100 SDL_PIXELFORMAT_BGR888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
101 SDL_PIXELFORMAT_ARGB8888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
102 SDL_PIXELFORMAT_RGBA8888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
103 SDL_PIXELFORMAT_ABGR8888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
104 SDL_PIXELFORMAT_BGRA8888, |
2811
7af2419ad5b0
Fixed the list of supported YUV formats
Sam Lantinga <slouken@libsdl.org>
parents:
2810
diff
changeset
|
105 SDL_PIXELFORMAT_YV12, |
7af2419ad5b0
Fixed the list of supported YUV formats
Sam Lantinga <slouken@libsdl.org>
parents:
2810
diff
changeset
|
106 SDL_PIXELFORMAT_IYUV, |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
107 SDL_PIXELFORMAT_YUY2, |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2786
diff
changeset
|
108 SDL_PIXELFORMAT_UYVY, |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2786
diff
changeset
|
109 SDL_PIXELFORMAT_YVYU}, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 0, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 0} |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 }; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 typedef struct |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 HWND hwnd; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 HDC window_hdc; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 HDC render_hdc; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 HDC memory_hdc; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 HDC current_hdc; |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
121 #ifndef NO_GETDIBBITS |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 LPBITMAPINFO bmi; |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
123 #endif |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
124 HBITMAP hbm[3]; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
125 int current_hbm; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
126 SDL_DirtyRectList dirty; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
127 SDL_bool makedirty; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
128 } GDI_RenderData; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 typedef struct |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 SDL_SW_YUVTexture *yuv; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 Uint32 format; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 HPALETTE hpal; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 HBITMAP hbm; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 void *pixels; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 int pitch; |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
138 SDL_bool premultiplied; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
139 } GDI_TextureData; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 UpdateYUVTextureData(SDL_Texture * texture) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
144 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 SDL_Rect rect; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 rect.x = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 rect.y = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 rect.w = texture->w; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 rect.h = texture->h; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 texture->h, data->pixels, data->pitch); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 GDI_AddRenderDriver(_THIS) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 { |
3520
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
158 int i; |
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
159 for (i = 0; i < _this->num_displays; ++i) { |
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
160 SDL_AddRenderDriver(&_this->displays[i], &GDI_RenderDriver); |
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
161 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 SDL_Renderer * |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
165 GDI_CreateRenderer(SDL_Window * window, Uint32 flags) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 SDL_Renderer *renderer; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
169 GDI_RenderData *data; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 int bmi_size; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 HBITMAP hbm; |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
172 int i, n; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
1920
8a162bfdc838
Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents:
1918
diff
changeset
|
174 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 if (!renderer) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 |
1920
8a162bfdc838
Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents:
1918
diff
changeset
|
180 data = (GDI_RenderData *) SDL_calloc(1, sizeof(*data)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 if (!data) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
182 GDI_DestroyRenderer(renderer); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 |
4569 | 187 windowdata->videodata->render = RENDER_GDI; |
188 | |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
189 renderer->DisplayModeChanged = GDI_DisplayModeChanged; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
190 renderer->CreateTexture = GDI_CreateTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
191 renderer->QueryTexturePixels = GDI_QueryTexturePixels; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
192 renderer->SetTexturePalette = GDI_SetTexturePalette; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
193 renderer->GetTexturePalette = GDI_GetTexturePalette; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
194 renderer->SetTextureAlphaMod = GDI_SetTextureAlphaMod; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
195 renderer->SetTextureBlendMode = GDI_SetTextureBlendMode; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
196 renderer->SetTextureScaleMode = GDI_SetTextureScaleMode; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
197 renderer->UpdateTexture = GDI_UpdateTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
198 renderer->LockTexture = GDI_LockTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
199 renderer->UnlockTexture = GDI_UnlockTexture; |
2927
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
200 renderer->SetDrawBlendMode = GDI_SetDrawBlendMode; |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
201 renderer->RenderDrawPoints = GDI_RenderDrawPoints; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
202 renderer->RenderDrawLines = GDI_RenderDrawLines; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
203 renderer->RenderDrawRects = GDI_RenderDrawRects; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
204 renderer->RenderFillRects = GDI_RenderFillRects; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
205 renderer->RenderCopy = GDI_RenderCopy; |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
206 renderer->RenderReadPixels = GDI_RenderReadPixels; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
207 renderer->RenderWritePixels = GDI_RenderWritePixels; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
208 renderer->RenderPresent = GDI_RenderPresent; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
209 renderer->DestroyTexture = GDI_DestroyTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
210 renderer->DestroyRenderer = GDI_DestroyRenderer; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
211 renderer->info = GDI_RenderDriver.info; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3599
diff
changeset
|
212 renderer->window = window; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 renderer->driverdata = data; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
215 renderer->info.flags = SDL_RENDERER_ACCELERATED; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
217 data->hwnd = windowdata->hwnd; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
218 data->window_hdc = windowdata->hdc; |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
219 data->render_hdc = CreateCompatibleDC(data->window_hdc); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
220 data->memory_hdc = CreateCompatibleDC(data->window_hdc); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
221 |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
222 #ifndef NO_GETDIBBITS |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
223 /* Fill in the compatible bitmap info */ |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
224 bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); |
1920
8a162bfdc838
Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents:
1918
diff
changeset
|
225 data->bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size); |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
226 if (!data->bmi) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
227 GDI_DestroyRenderer(renderer); |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
228 SDL_OutOfMemory(); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
229 return NULL; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
230 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
231 data->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
232 |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
233 hbm = CreateCompatibleBitmap(data->window_hdc, 1, 1); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
234 GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
235 GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
236 DeleteObject(hbm); |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
237 #endif |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
238 |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
239 if (flags & SDL_RENDERER_SINGLEBUFFER) { |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
240 renderer->info.flags |= |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
241 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY); |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
242 n = 0; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
243 } else if (flags & SDL_RENDERER_PRESENTFLIP2) { |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
244 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
245 n = 2; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
246 } else if (flags & SDL_RENDERER_PRESENTFLIP3) { |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
247 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
248 n = 3; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
249 } else { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
250 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
251 n = 1; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
252 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
253 for (i = 0; i < n; ++i) { |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
254 data->hbm[i] = |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
255 CreateCompatibleBitmap(data->window_hdc, window->w, window->h); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
256 if (!data->hbm[i]) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
257 GDI_DestroyRenderer(renderer); |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
258 WIN_SetError("CreateCompatibleBitmap()"); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
259 return NULL; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
260 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
261 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
262 if (n > 0) { |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
263 SelectObject(data->render_hdc, data->hbm[0]); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
264 data->current_hdc = data->render_hdc; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
265 data->makedirty = SDL_TRUE; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
266 } else { |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
267 data->current_hdc = data->window_hdc; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
268 data->makedirty = SDL_FALSE; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
269 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
270 data->current_hbm = 0; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
271 |
4569 | 272 #ifdef _WIN32_WCE |
273 // check size for GDI fullscreen and rotate | |
274 if((window->flags & SDL_WINDOW_FULLSCREEN) && | |
275 GetSystemMetrics(SM_CXSCREEN) != GetSystemMetrics(SM_CYSCREEN) && | |
276 ((GetSystemMetrics(SM_CXSCREEN) < GetSystemMetrics(SM_CYSCREEN) && window->w > window->h) || | |
277 (GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN) && window->w < window->h))) | |
278 { | |
279 int orientation = WINCE_GetDMOrientation(); | |
280 switch(orientation) | |
281 { | |
282 case DMDO_0: orientation = DMDO_90; break; | |
283 case DMDO_270: orientation = DMDO_180; break; | |
284 case DMDO_90: orientation = DMDO_0; break; | |
285 case DMDO_180: orientation = DMDO_270; break; | |
286 | |
287 default: | |
288 GDI_DestroyRenderer(renderer); | |
289 return NULL; | |
290 } | |
291 | |
292 if(0 > WINCE_SetDMOrientation(orientation)) | |
293 { | |
294 GDI_DestroyRenderer(renderer); | |
295 return NULL; | |
296 } | |
297 } | |
298 #endif | |
299 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 return renderer; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 static int |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
304 GDI_DisplayModeChanged(SDL_Renderer * renderer) |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
305 { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
306 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3599
diff
changeset
|
307 SDL_Window *window = renderer->window; |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
308 int i, n; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
309 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
310 if (renderer->info.flags & SDL_RENDERER_SINGLEBUFFER) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
311 n = 0; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
312 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
313 n = 2; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
314 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
315 n = 3; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
316 } else { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
317 n = 1; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
318 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
319 for (i = 0; i < n; ++i) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
320 if (data->hbm[i]) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
321 DeleteObject(data->hbm[i]); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
322 data->hbm[i] = NULL; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
323 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
324 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
325 for (i = 0; i < n; ++i) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
326 data->hbm[i] = |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
327 CreateCompatibleBitmap(data->window_hdc, window->w, window->h); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
328 if (!data->hbm[i]) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
329 WIN_SetError("CreateCompatibleBitmap()"); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
330 return -1; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
331 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
332 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
333 if (n > 0) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
334 SelectObject(data->render_hdc, data->hbm[0]); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
335 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2786
diff
changeset
|
336 data->current_hbm = 0; |
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2786
diff
changeset
|
337 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
338 return 0; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
339 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
340 |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
341 static HBITMAP |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
342 GDI_CreateDIBSection(HDC hdc, int w, int h, int pitch, Uint32 format, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
343 HPALETTE * hpal, void ** pixels) |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
344 { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
345 int bmi_size; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
346 LPBITMAPINFO bmi; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
347 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
348 bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
349 bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
350 if (!bmi) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
351 SDL_OutOfMemory(); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
352 return NULL; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
353 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
354 bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
355 bmi->bmiHeader.biWidth = w; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
356 bmi->bmiHeader.biHeight = -h; /* topdown bitmap */ |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
357 bmi->bmiHeader.biPlanes = 1; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
358 bmi->bmiHeader.biSizeImage = h * pitch; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
359 bmi->bmiHeader.biXPelsPerMeter = 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
360 bmi->bmiHeader.biYPelsPerMeter = 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
361 bmi->bmiHeader.biClrUsed = 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
362 bmi->bmiHeader.biClrImportant = 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
363 bmi->bmiHeader.biBitCount = SDL_BYTESPERPIXEL(format) * 8; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
364 if (SDL_ISPIXELFORMAT_INDEXED(format)) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
365 bmi->bmiHeader.biCompression = BI_RGB; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
366 if (hpal) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
367 int i, ncolors; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
368 LOGPALETTE *palette; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
369 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
370 ncolors = (1 << SDL_BITSPERPIXEL(format)); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
371 palette = |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
372 (LOGPALETTE *) SDL_malloc(sizeof(*palette) + |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
373 ncolors * sizeof(PALETTEENTRY)); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
374 if (!palette) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
375 SDL_free(bmi); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
376 SDL_OutOfMemory(); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
377 return NULL; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
378 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
379 palette->palVersion = 0x300; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
380 palette->palNumEntries = ncolors; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
381 for (i = 0; i < ncolors; ++i) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
382 palette->palPalEntry[i].peRed = 0xFF; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
383 palette->palPalEntry[i].peGreen = 0xFF; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
384 palette->palPalEntry[i].peBlue = 0xFF; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
385 palette->palPalEntry[i].peFlags = 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
386 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
387 *hpal = CreatePalette(palette); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
388 SDL_free(palette); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
389 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
390 } else { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
391 int bpp; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
392 Uint32 Rmask, Gmask, Bmask, Amask; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
393 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
394 bmi->bmiHeader.biCompression = BI_BITFIELDS; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
395 SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
396 &Amask); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
397 ((Uint32 *) bmi->bmiColors)[0] = Rmask; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
398 ((Uint32 *) bmi->bmiColors)[1] = Gmask; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
399 ((Uint32 *) bmi->bmiColors)[2] = Bmask; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
400 if (hpal) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
401 *hpal = NULL; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
402 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
403 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
404 return CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, pixels, NULL, 0); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
405 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
406 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
407 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
408 GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
410 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3599
diff
changeset
|
411 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3599
diff
changeset
|
412 SDL_VideoDisplay *display = window->display; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
413 GDI_TextureData *data; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 |
1920
8a162bfdc838
Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents:
1918
diff
changeset
|
415 data = (GDI_TextureData *) SDL_calloc(1, sizeof(*data)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 if (!data) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 texture->driverdata = data; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
2786 | 424 data->yuv = |
425 SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 if (!data->yuv) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 data->format = display->current_mode.format; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 data->format = texture->format; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 data->pitch = (texture->w * SDL_BYTESPERPIXEL(data->format)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 |
2222
926294b2bb4e
Emphasized the separation between SDL_Surface and SDL_Texture
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
435 if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
436 || texture->format != display->current_mode.format) { |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
437 data->hbm = GDI_CreateDIBSection(renderdata->memory_hdc, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
438 texture->w, texture->h, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
439 data->pitch, data->format, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
440 &data->hpal, &data->pixels); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 } else { |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
442 data->hbm = CreateCompatibleBitmap(renderdata->window_hdc, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
443 texture->w, texture->h); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 if (!data->hbm) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 WIN_SetError("Couldn't create bitmap"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 } |
4569 | 449 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
454 GDI_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
455 void **pixels, int *pitch) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
457 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 if (data->yuv) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 *pixels = data->pixels; |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
463 *pitch = data->pitch; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
469 GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
470 const SDL_Color * colors, int firstcolor, int ncolors) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
472 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
473 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 if (data->yuv) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 SDL_SetError("YUV textures don't have a palette"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 PALETTEENTRY entries[256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 int i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 for (i = 0; i < ncolors; ++i) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 entries[i].peRed = colors[i].r; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 entries[i].peGreen = colors[i].g; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 entries[i].peBlue = colors[i].b; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 entries[i].peFlags = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 if (!SetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 WIN_SetError("SetPaletteEntries()"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
497 GDI_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
498 SDL_Color * colors, int firstcolor, int ncolors) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
499 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
500 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
501 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 if (data->yuv) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 SDL_SetError("YUV textures don't have a palette"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
504 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 PALETTEENTRY entries[256]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 int i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 if (!GetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 WIN_SetError("GetPaletteEntries()"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 for (i = 0; i < ncolors; ++i) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 colors[i].r = entries[i].peRed; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 colors[i].g = entries[i].peGreen; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 colors[i].b = entries[i].peBlue; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 static int |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
523 GDI_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
524 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
525 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
526 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
527 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
528 static int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
529 GDI_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
530 { |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
531 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
532 |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
533 switch (texture->blendMode) { |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
534 case SDL_BLENDMODE_NONE: |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
535 if (data->premultiplied) { |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
536 /* Crap, we've lost the original pixel data... *sigh* */ |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
537 } |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
538 return 0; |
3139 | 539 #ifndef _WIN32_WCE /* WinCE has no alphablend */ |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
540 case SDL_BLENDMODE_MASK: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
541 case SDL_BLENDMODE_BLEND: |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
542 if (!data->premultiplied && data->pixels) { |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
543 switch (texture->format) { |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
544 case SDL_PIXELFORMAT_ARGB8888: |
3055 | 545 SDL_PreMultiplyAlphaARGB8888(texture->w, texture->h, |
546 (Uint32 *) data->pixels, | |
547 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
548 data->premultiplied = SDL_TRUE; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
549 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
550 case SDL_PIXELFORMAT_RGBA8888: |
3055 | 551 SDL_PreMultiplyAlphaRGBA8888(texture->w, texture->h, |
552 (Uint32 *) data->pixels, | |
553 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
554 data->premultiplied = SDL_TRUE; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
555 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
556 case SDL_PIXELFORMAT_ABGR8888: |
3055 | 557 SDL_PreMultiplyAlphaABGR8888(texture->w, texture->h, |
558 (Uint32 *) data->pixels, | |
559 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
560 data->premultiplied = SDL_TRUE; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
561 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
562 case SDL_PIXELFORMAT_BGRA8888: |
3055 | 563 SDL_PreMultiplyAlphaBGRA8888(texture->w, texture->h, |
564 (Uint32 *) data->pixels, | |
565 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
566 data->premultiplied = SDL_TRUE; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
567 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
568 } |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
569 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
570 return 0; |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
571 #endif |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
572 default: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
573 SDL_Unsupported(); |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
574 texture->blendMode = SDL_BLENDMODE_NONE; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
575 return -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
576 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
577 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
578 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
579 static int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
580 GDI_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
581 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
582 switch (texture->scaleMode) { |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
4569
diff
changeset
|
583 case SDL_SCALEMODE_NONE: |
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
4569
diff
changeset
|
584 case SDL_SCALEMODE_FAST: |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
585 return 0; |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
4569
diff
changeset
|
586 case SDL_SCALEMODE_SLOW: |
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
4569
diff
changeset
|
587 case SDL_SCALEMODE_BEST: |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
588 SDL_Unsupported(); |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
4569
diff
changeset
|
589 texture->scaleMode = SDL_SCALEMODE_FAST; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
590 return -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
591 default: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
592 SDL_Unsupported(); |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
4569
diff
changeset
|
593 texture->scaleMode = SDL_SCALEMODE_NONE; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
594 return -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
595 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
596 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
597 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
598 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
599 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
600 GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
601 const SDL_Rect * rect, const void *pixels, int pitch) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
603 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 if (data->yuv) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
606 if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
607 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
608 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
609 UpdateYUVTextureData(texture); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
610 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
611 } else { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
612 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
613 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
614 if (data->pixels) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
615 Uint8 *src, *dst; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
616 int row; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
617 size_t length; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 src = (Uint8 *) pixels; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
620 dst = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 (Uint8 *) data->pixels + rect->y * data->pitch + |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
622 rect->x * SDL_BYTESPERPIXEL(texture->format); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 length = rect->w * SDL_BYTESPERPIXEL(texture->format); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
624 for (row = 0; row < rect->h; ++row) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
625 SDL_memcpy(dst, src, length); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
626 src += pitch; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
627 dst += data->pitch; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
628 } |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
629 if (data->premultiplied) { |
3055 | 630 Uint32 *pixels = |
631 (Uint32 *) data->pixels + rect->y * (data->pitch / 4) + | |
632 rect->x; | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
633 switch (texture->format) { |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
634 case SDL_PIXELFORMAT_ARGB8888: |
3055 | 635 SDL_PreMultiplyAlphaARGB8888(rect->w, rect->h, pixels, |
636 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
637 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
638 case SDL_PIXELFORMAT_RGBA8888: |
3055 | 639 SDL_PreMultiplyAlphaRGBA8888(rect->w, rect->h, pixels, |
640 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
641 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
642 case SDL_PIXELFORMAT_ABGR8888: |
3055 | 643 SDL_PreMultiplyAlphaABGR8888(rect->w, rect->h, pixels, |
644 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
645 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
646 case SDL_PIXELFORMAT_BGRA8888: |
3055 | 647 SDL_PreMultiplyAlphaBGRA8888(rect->w, rect->h, pixels, |
648 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
649 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
650 } |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
651 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
652 } else if (rect->w == texture->w && pitch == data->pitch) { |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
653 #ifndef NO_GETDIBBITS |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 if (!SetDIBits |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 (renderdata->window_hdc, data->hbm, rect->y, rect->h, pixels, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
656 renderdata->bmi, DIB_RGB_COLORS)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
657 WIN_SetError("SetDIBits()"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
658 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
659 } |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
660 #else |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
661 SDL_SetError("FIXME: Update Texture"); |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
662 return -1; |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
663 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
664 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
665 SDL_SetError |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
666 ("FIXME: Need to allocate temporary memory and do GetDIBits() followed by SetDIBits(), since we can only set blocks of scanlines at a time"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
667 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
668 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
669 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
670 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
671 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
672 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
673 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
674 GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
675 const SDL_Rect * rect, int markDirty, void **pixels, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
676 int *pitch) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
677 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
678 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
679 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
680 if (data->yuv) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
681 return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
682 pitch); |
1898
f89e49e51e89
Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents:
1897
diff
changeset
|
683 } else if (data->pixels) { |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
684 #ifndef _WIN32_WCE |
3139 | 685 /* WinCE has no GdiFlush */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
686 GdiFlush(); |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
687 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
688 *pixels = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
689 (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
690 rect->x * SDL_BYTESPERPIXEL(texture->format)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
691 *pitch = data->pitch; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
692 return 0; |
1898
f89e49e51e89
Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents:
1897
diff
changeset
|
693 } else { |
f89e49e51e89
Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents:
1897
diff
changeset
|
694 SDL_SetError("No pixels available"); |
f89e49e51e89
Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents:
1897
diff
changeset
|
695 return -1; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
696 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
697 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
698 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
699 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
700 GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
701 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
702 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
703 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
704 if (data->yuv) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
705 SDL_SW_UnlockYUVTexture(data->yuv); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
706 UpdateYUVTextureData(texture); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
707 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
709 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
710 static int |
2927
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
711 GDI_SetDrawBlendMode(SDL_Renderer * renderer) |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
712 { |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
713 switch (renderer->blendMode) { |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
714 case SDL_BLENDMODE_NONE: |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
715 return 0; |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
716 default: |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
717 SDL_Unsupported(); |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
718 renderer->blendMode = SDL_BLENDMODE_NONE; |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
719 return -1; |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
720 } |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
721 } |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
722 |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
723 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
724 GDI_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
725 int count) |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
726 { |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
727 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
728 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
729 COLORREF color; |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
730 |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
731 if (data->makedirty) { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
732 /* Get the smallest rectangle that contains everything */ |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3599
diff
changeset
|
733 SDL_Window *window = renderer->window; |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
734 SDL_Rect rect; |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
735 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
736 rect.x = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
737 rect.y = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
738 rect.w = window->w; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
739 rect.h = window->h; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
740 if (!SDL_EnclosePoints(points, count, &rect, &rect)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
741 /* Nothing to draw */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
742 return 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
743 } |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
744 |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
745 SDL_AddDirtyRect(&data->dirty, &rect); |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
746 } |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
747 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
748 color = RGB(renderer->r, renderer->g, renderer->b); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
749 for (i = 0; i < count; ++i) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
750 SetPixel(data->current_hdc, points[i].x, points[i].y, color); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
751 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
752 |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
753 return 0; |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
754 } |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
755 |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
756 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
757 GDI_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
758 int count) |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
759 { |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
760 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; |
3056
a434fe6360df
Oh, Polyline() uses a pen, not a brush. Doh! :)
Sam Lantinga <slouken@libsdl.org>
parents:
3055
diff
changeset
|
761 HPEN pen; |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
762 BOOL status; |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
763 |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
764 if (data->makedirty) { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
765 /* Get the smallest rectangle that contains everything */ |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3599
diff
changeset
|
766 SDL_Window *window = renderer->window; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
767 SDL_Rect clip, rect; |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
768 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
769 clip.x = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
770 clip.y = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
771 clip.w = window->w; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
772 clip.h = window->h; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
773 SDL_EnclosePoints(points, count, NULL, &rect); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
774 if (!SDL_IntersectRect(&rect, &clip, &rect)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
775 /* Nothing to draw */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
776 return 0; |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
777 } |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
778 |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
779 SDL_AddDirtyRect(&data->dirty, &rect); |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
780 } |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
781 |
3056
a434fe6360df
Oh, Polyline() uses a pen, not a brush. Doh! :)
Sam Lantinga <slouken@libsdl.org>
parents:
3055
diff
changeset
|
782 /* Should we cache the pen? .. it looks like GDI does for us. :) */ |
a434fe6360df
Oh, Polyline() uses a pen, not a brush. Doh! :)
Sam Lantinga <slouken@libsdl.org>
parents:
3055
diff
changeset
|
783 pen = CreatePen(PS_SOLID, 1, RGB(renderer->r, renderer->g, renderer->b)); |
a434fe6360df
Oh, Polyline() uses a pen, not a brush. Doh! :)
Sam Lantinga <slouken@libsdl.org>
parents:
3055
diff
changeset
|
784 SelectObject(data->current_hdc, pen); |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
785 { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
786 LPPOINT p = SDL_stack_alloc(POINT, count); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
787 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
788 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
789 for (i = 0; i < count; ++i) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
790 p[i].x = points[i].x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
791 p[i].y = points[i].y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
792 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
793 status = Polyline(data->current_hdc, p, count); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
794 SDL_stack_free(p); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
795 } |
3056
a434fe6360df
Oh, Polyline() uses a pen, not a brush. Doh! :)
Sam Lantinga <slouken@libsdl.org>
parents:
3055
diff
changeset
|
796 DeleteObject(pen); |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
797 |
3535
b403f790df65
Hey, those automated tests are coming in handy! Fixed GDI rendering semantics
Sam Lantinga <slouken@libsdl.org>
parents:
3534
diff
changeset
|
798 /* Need to close the endpoint of the line */ |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
799 if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
800 SetPixel(data->current_hdc, points[count-1].x, points[count-1].y, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
801 RGB(renderer->r, renderer->g, renderer->b)); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
802 } |
3535
b403f790df65
Hey, those automated tests are coming in handy! Fixed GDI rendering semantics
Sam Lantinga <slouken@libsdl.org>
parents:
3534
diff
changeset
|
803 |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
804 if (!status) { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
805 WIN_SetError("Polyline()"); |
2926
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
806 return -1; |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
807 } |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
808 return 0; |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
809 } |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
810 |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
811 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
812 GDI_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
813 int count) |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
814 { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
815 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
816 HPEN pen; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
817 POINT vertices[5]; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
818 int i, status = 1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
819 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
820 if (data->makedirty) { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3599
diff
changeset
|
821 SDL_Window *window = renderer->window; |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
822 SDL_Rect clip, rect; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
823 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
824 clip.x = 0; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
825 clip.y = 0; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
826 clip.w = window->w; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
827 clip.h = window->h; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
828 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
829 for (i = 0; i < count; ++i) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
830 if (SDL_IntersectRect(rects[i], &clip, &rect)) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
831 SDL_AddDirtyRect(&data->dirty, &rect); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
832 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
833 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
834 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
835 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
836 /* Should we cache the pen? .. it looks like GDI does for us. :) */ |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
837 pen = CreatePen(PS_SOLID, 1, RGB(renderer->r, renderer->g, renderer->b)); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
838 SelectObject(data->current_hdc, pen); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
839 for (i = 0; i < count; ++i) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
840 const SDL_Rect *rect = rects[i]; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
841 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
842 vertices[0].x = rect->x; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
843 vertices[0].y = rect->y; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
844 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
845 vertices[1].x = rect->x+rect->w-1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
846 vertices[1].y = rect->y; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
847 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
848 vertices[2].x = rect->x+rect->w-1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
849 vertices[2].y = rect->y+rect->h-1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
850 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
851 vertices[3].x = rect->x; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
852 vertices[3].y = rect->y+rect->h-1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
853 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
854 vertices[4].x = rect->x; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
855 vertices[4].y = rect->y; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
856 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
857 status &= Polyline(data->current_hdc, vertices, 5); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
858 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
859 DeleteObject(pen); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
860 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
861 if (!status) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
862 WIN_SetError("Polyline()"); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
863 return -1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
864 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
865 return 0; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
866 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
867 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
868 static int |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
869 GDI_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
870 int count) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
871 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
872 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
873 RECT rc; |
1899 | 874 HBRUSH brush; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
875 int i, status = 1; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
876 |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
877 if (data->makedirty) { |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3599
diff
changeset
|
878 SDL_Window *window = renderer->window; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
879 SDL_Rect clip, rect; |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
880 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
881 clip.x = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
882 clip.y = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
883 clip.w = window->w; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
884 clip.h = window->h; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
885 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
886 for (i = 0; i < count; ++i) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
887 if (SDL_IntersectRect(rects[i], &clip, &rect)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
888 SDL_AddDirtyRect(&data->dirty, &rect); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
889 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
890 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
891 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
892 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
893 /* Should we cache the brushes? .. it looks like GDI does for us. :) */ |
2919
2f91a3847ae8
Fixed compiling Windows renderers. Lines and points will be implemented later.
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
894 brush = CreateSolidBrush(RGB(renderer->r, renderer->g, renderer->b)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
895 SelectObject(data->current_hdc, brush); |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
896 for (i = 0; i < count; ++i) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
897 const SDL_Rect *rect = rects[i]; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
898 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
899 rc.left = rect->x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
900 rc.top = rect->y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
901 rc.right = rect->x + rect->w; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
902 rc.bottom = rect->y + rect->h; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
903 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
904 status &= FillRect(data->current_hdc, &rc, brush); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
905 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
906 DeleteObject(brush); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
907 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
908 if (!status) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
909 WIN_SetError("FillRect()"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
910 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
911 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
912 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
913 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
914 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
915 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
916 GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
917 const SDL_Rect * srcrect, const SDL_Rect * dstrect) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
918 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
919 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
920 GDI_TextureData *texturedata = (GDI_TextureData *) texture->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
921 |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
922 if (data->makedirty) { |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
923 SDL_AddDirtyRect(&data->dirty, dstrect); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
924 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
925 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
926 SelectObject(data->memory_hdc, texturedata->hbm); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
927 if (texturedata->hpal) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
928 SelectPalette(data->memory_hdc, texturedata->hpal, TRUE); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
929 RealizePalette(data->memory_hdc); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
930 } |
3055 | 931 if (texture->blendMode & (SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND)) { |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
932 #ifdef _WIN32_WCE |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
933 SDL_SetError("Texture has blendmode not supported under WinCE"); |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
934 return -1; |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
935 #else |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
936 BLENDFUNCTION blendFunc = { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
937 AC_SRC_OVER, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
938 0, |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
939 texture->a, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
940 AC_SRC_ALPHA |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
941 }; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
942 if (!AlphaBlend |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
943 (data->current_hdc, dstrect->x, dstrect->y, dstrect->w, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
944 dstrect->h, data->memory_hdc, srcrect->x, srcrect->y, srcrect->w, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
945 srcrect->h, blendFunc)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
946 WIN_SetError("AlphaBlend()"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
947 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
948 } |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
949 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
950 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
951 if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
952 if (!BitBlt |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
953 (data->current_hdc, dstrect->x, dstrect->y, dstrect->w, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
954 srcrect->h, data->memory_hdc, srcrect->x, srcrect->y, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
955 SRCCOPY)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
956 WIN_SetError("BitBlt()"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
957 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
958 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
959 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
960 if (!StretchBlt |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
961 (data->current_hdc, dstrect->x, dstrect->y, dstrect->w, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
962 dstrect->h, data->memory_hdc, srcrect->x, srcrect->y, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
963 srcrect->w, srcrect->h, SRCCOPY)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
964 WIN_SetError("StretchBlt()"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
965 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
966 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
967 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
968 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
969 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
970 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
971 |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
972 static int |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
973 GDI_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
974 Uint32 format, void * pixels, int pitch) |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
975 { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
976 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3599
diff
changeset
|
977 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3599
diff
changeset
|
978 SDL_VideoDisplay *display = window->display; |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
979 struct { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
980 HBITMAP hbm; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
981 void *pixels; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
982 int pitch; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
983 Uint32 format; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
984 } data; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
985 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
986 data.format = display->current_mode.format; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
987 data.pitch = (rect->w * SDL_BYTESPERPIXEL(data.format)); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
988 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
989 data.hbm = GDI_CreateDIBSection(renderdata->memory_hdc, rect->w, rect->h, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
990 data.pitch, data.format, NULL, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
991 &data.pixels); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
992 if (!data.hbm) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
993 WIN_SetError("Couldn't create bitmap"); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
994 return -1; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
995 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
996 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
997 SelectObject(renderdata->memory_hdc, data.hbm); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
998 if (!BitBlt(renderdata->memory_hdc, 0, 0, rect->w, rect->h, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
999 renderdata->current_hdc, rect->x, rect->y, SRCCOPY)) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1000 WIN_SetError("BitBlt()"); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1001 DeleteObject(data.hbm); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1002 return -1; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1003 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1004 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1005 SDL_ConvertPixels(rect->w, rect->h, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1006 data.format, data.pixels, data.pitch, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1007 format, pixels, pitch); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1008 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1009 DeleteObject(data.hbm); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1010 return 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1011 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1012 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1013 static int |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1014 GDI_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1015 Uint32 format, const void * pixels, int pitch) |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1016 { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1017 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3599
diff
changeset
|
1018 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3599
diff
changeset
|
1019 SDL_VideoDisplay *display = window->display; |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1020 struct { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1021 HBITMAP hbm; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1022 void *pixels; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1023 int pitch; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1024 Uint32 format; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1025 } data; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1026 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1027 data.format = display->current_mode.format; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1028 data.pitch = (rect->w * SDL_BYTESPERPIXEL(data.format)); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1029 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1030 data.hbm = GDI_CreateDIBSection(renderdata->memory_hdc, rect->w, rect->h, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1031 data.pitch, data.format, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1032 NULL, &data.pixels); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1033 if (!data.hbm) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1034 WIN_SetError("Couldn't create bitmap"); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1035 return -1; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1036 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1037 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1038 SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1039 data.format, data.pixels, data.pitch); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1040 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1041 SelectObject(renderdata->memory_hdc, data.hbm); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1042 if (!BitBlt(renderdata->current_hdc, rect->x, rect->y, rect->w, rect->h, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1043 renderdata->memory_hdc, 0, 0, SRCCOPY)) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1044 WIN_SetError("BitBlt()"); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1045 DeleteObject(data.hbm); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1046 return -1; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1047 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1048 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1049 DeleteObject(data.hbm); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1050 return 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1051 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1052 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1053 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1054 GDI_RenderPresent(SDL_Renderer * renderer) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1055 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1056 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1057 SDL_DirtyRect *dirty; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1058 |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1059 /* Send the data to the display */ |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
1060 if (!(renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)) { |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1061 for (dirty = data->dirty.list; dirty; dirty = dirty->next) { |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1062 const SDL_Rect *rect = &dirty->rect; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1063 BitBlt(data->window_hdc, rect->x, rect->y, rect->w, rect->h, |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1064 data->render_hdc, rect->x, rect->y, SRCCOPY); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1065 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1066 SDL_ClearDirtyRects(&data->dirty); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1067 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1068 |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1069 /* Update the flipping chain, if any */ |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
1070 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1071 data->current_hbm = (data->current_hbm + 1) % 2; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1072 SelectObject(data->render_hdc, data->hbm[data->current_hbm]); |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
1073 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) { |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1074 data->current_hbm = (data->current_hbm + 1) % 3; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1075 SelectObject(data->render_hdc, data->hbm[data->current_hbm]); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1076 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1077 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1078 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1079 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1080 GDI_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1081 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1082 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1083 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1084 if (!data) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1085 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1086 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1087 if (data->yuv) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1088 SDL_SW_DestroyYUVTexture(data->yuv); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1089 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1090 if (data->hpal) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1091 DeleteObject(data->hpal); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1092 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1093 if (data->hbm) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1094 DeleteObject(data->hbm); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1095 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1096 SDL_free(data); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1097 texture->driverdata = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1098 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1099 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1100 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1101 GDI_DestroyRenderer(SDL_Renderer * renderer) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1102 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1103 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1104 int i; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1105 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1106 if (data) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1107 DeleteDC(data->render_hdc); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1108 DeleteDC(data->memory_hdc); |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
1109 #ifndef NO_GETDIBBITS |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1110 if (data->bmi) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1111 SDL_free(data->bmi); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1112 } |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
1113 #endif |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1114 for (i = 0; i < SDL_arraysize(data->hbm); ++i) { |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1115 if (data->hbm[i]) { |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1116 DeleteObject(data->hbm[i]); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1117 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1118 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1119 SDL_FreeDirtyRects(&data->dirty); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1120 SDL_free(data); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1121 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1122 SDL_free(renderer); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1123 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1124 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1125 #endif /* SDL_VIDEO_RENDER_GDI */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1126 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1127 /* vi: set ts=4 sw=4 expandtab: */ |