Mercurial > sdl-ios-xcode
annotate src/video/win32/SDL_gdirender.c @ 4423:7953336267c2
Disable error checks for reset actuators and set autocenter.
Reset actuators and set autocenter might not actually be supported on all
implementations. We'll just disable error checking since they aren't
critical to neither opening the joystick nor the haptic subsystem.
author | Edgar Simo <bobbens@gmail.com> |
---|---|
date | Sun, 28 Feb 2010 09:23:23 +0000 |
parents | f7b03b6838cb |
children | e1664f94f026 |
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), |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
93 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_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 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
187 renderer->DisplayModeChanged = GDI_DisplayModeChanged; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
188 renderer->CreateTexture = GDI_CreateTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
189 renderer->QueryTexturePixels = GDI_QueryTexturePixels; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
190 renderer->SetTexturePalette = GDI_SetTexturePalette; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
191 renderer->GetTexturePalette = GDI_GetTexturePalette; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
192 renderer->SetTextureAlphaMod = GDI_SetTextureAlphaMod; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
193 renderer->SetTextureBlendMode = GDI_SetTextureBlendMode; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
194 renderer->SetTextureScaleMode = GDI_SetTextureScaleMode; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
195 renderer->UpdateTexture = GDI_UpdateTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
196 renderer->LockTexture = GDI_LockTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
197 renderer->UnlockTexture = GDI_UnlockTexture; |
2927
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
198 renderer->SetDrawBlendMode = GDI_SetDrawBlendMode; |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
199 renderer->RenderDrawPoints = GDI_RenderDrawPoints; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
200 renderer->RenderDrawLines = GDI_RenderDrawLines; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
201 renderer->RenderDrawRects = GDI_RenderDrawRects; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
202 renderer->RenderFillRects = GDI_RenderFillRects; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
203 renderer->RenderCopy = GDI_RenderCopy; |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
204 renderer->RenderReadPixels = GDI_RenderReadPixels; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
205 renderer->RenderWritePixels = GDI_RenderWritePixels; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
206 renderer->RenderPresent = GDI_RenderPresent; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
207 renderer->DestroyTexture = GDI_DestroyTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
208 renderer->DestroyRenderer = GDI_DestroyRenderer; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
209 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
|
210 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
|
211 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
|
212 |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
213 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
|
214 |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
215 data->hwnd = windowdata->hwnd; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
216 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
|
217 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
|
218 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
|
219 |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
220 #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
|
221 /* 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
|
222 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
|
223 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
|
224 if (!data->bmi) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
225 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
|
226 SDL_OutOfMemory(); |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
227 return NULL; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
228 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
229 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
|
230 |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
231 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
|
232 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
|
233 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
|
234 DeleteObject(hbm); |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
235 #endif |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
236 |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
237 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
|
238 renderer->info.flags |= |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
239 (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
|
240 n = 0; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
241 } else if (flags & SDL_RENDERER_PRESENTFLIP2) { |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
242 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
|
243 n = 2; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
244 } else if (flags & SDL_RENDERER_PRESENTFLIP3) { |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
245 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
|
246 n = 3; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
247 } else { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
248 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
|
249 n = 1; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
250 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
251 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
|
252 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
|
253 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
|
254 if (!data->hbm[i]) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
255 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
|
256 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
|
257 return NULL; |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
258 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
259 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
260 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
|
261 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
|
262 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
|
263 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
|
264 } else { |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
265 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
|
266 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
|
267 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
268 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
|
269 |
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
|
270 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
|
271 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 static int |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
274 GDI_DisplayModeChanged(SDL_Renderer * renderer) |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
275 { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
276 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
|
277 SDL_Window *window = renderer->window; |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
278 int i, n; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
279 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
280 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
|
281 n = 0; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
282 } 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
|
283 n = 2; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
284 } 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
|
285 n = 3; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
286 } else { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
287 n = 1; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
288 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
289 for (i = 0; i < n; ++i) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
290 if (data->hbm[i]) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
291 DeleteObject(data->hbm[i]); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
292 data->hbm[i] = NULL; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
293 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
294 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
295 for (i = 0; i < n; ++i) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
296 data->hbm[i] = |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
297 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
|
298 if (!data->hbm[i]) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
299 WIN_SetError("CreateCompatibleBitmap()"); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
300 return -1; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
301 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
302 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
303 if (n > 0) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
304 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
|
305 } |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2786
diff
changeset
|
306 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
|
307 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
308 return 0; |
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 |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
311 static HBITMAP |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
312 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
|
313 HPALETTE * hpal, void ** pixels) |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
314 { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
315 int bmi_size; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
316 LPBITMAPINFO bmi; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
317 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
318 bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
319 bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
320 if (!bmi) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
321 SDL_OutOfMemory(); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
322 return NULL; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
323 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
324 bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
325 bmi->bmiHeader.biWidth = w; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
326 bmi->bmiHeader.biHeight = -h; /* topdown bitmap */ |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
327 bmi->bmiHeader.biPlanes = 1; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
328 bmi->bmiHeader.biSizeImage = h * pitch; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
329 bmi->bmiHeader.biXPelsPerMeter = 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
330 bmi->bmiHeader.biYPelsPerMeter = 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
331 bmi->bmiHeader.biClrUsed = 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
332 bmi->bmiHeader.biClrImportant = 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
333 bmi->bmiHeader.biBitCount = SDL_BYTESPERPIXEL(format) * 8; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
334 if (SDL_ISPIXELFORMAT_INDEXED(format)) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
335 bmi->bmiHeader.biCompression = BI_RGB; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
336 if (hpal) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
337 int i, ncolors; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
338 LOGPALETTE *palette; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
339 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
340 ncolors = (1 << SDL_BITSPERPIXEL(format)); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
341 palette = |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
342 (LOGPALETTE *) SDL_malloc(sizeof(*palette) + |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
343 ncolors * sizeof(PALETTEENTRY)); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
344 if (!palette) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
345 SDL_free(bmi); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
346 SDL_OutOfMemory(); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
347 return NULL; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
348 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
349 palette->palVersion = 0x300; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
350 palette->palNumEntries = ncolors; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
351 for (i = 0; i < ncolors; ++i) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
352 palette->palPalEntry[i].peRed = 0xFF; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
353 palette->palPalEntry[i].peGreen = 0xFF; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
354 palette->palPalEntry[i].peBlue = 0xFF; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
355 palette->palPalEntry[i].peFlags = 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
356 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
357 *hpal = CreatePalette(palette); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
358 SDL_free(palette); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
359 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
360 } else { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
361 int bpp; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
362 Uint32 Rmask, Gmask, Bmask, Amask; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
363 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
364 bmi->bmiHeader.biCompression = BI_BITFIELDS; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
365 SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
366 &Amask); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
367 ((Uint32 *) bmi->bmiColors)[0] = Rmask; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
368 ((Uint32 *) bmi->bmiColors)[1] = Gmask; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
369 ((Uint32 *) bmi->bmiColors)[2] = Bmask; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
370 if (hpal) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
371 *hpal = NULL; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
372 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
373 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
374 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
|
375 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
376 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
377 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
378 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
|
379 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
380 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
|
381 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
|
382 SDL_VideoDisplay *display = window->display; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
383 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
|
384 |
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
|
385 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
|
386 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
|
387 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
|
388 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
|
389 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 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
|
392 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
2786 | 394 data->yuv = |
395 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
|
396 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
|
397 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
|
398 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 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
|
400 } 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
|
401 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
|
402 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 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
|
404 |
2222
926294b2bb4e
Emphasized the separation between SDL_Surface and SDL_Texture
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
405 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
|
406 || texture->format != display->current_mode.format) { |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
407 data->hbm = GDI_CreateDIBSection(renderdata->memory_hdc, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
408 texture->w, texture->h, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
409 data->pitch, data->format, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
410 &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
|
411 } else { |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
412 data->hbm = CreateCompatibleBitmap(renderdata->window_hdc, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
413 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
|
414 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 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
|
416 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
|
417 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
|
418 } |
c121d94672cb
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 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
|
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 |
c121d94672cb
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 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
423 GDI_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
424 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
|
425 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
426 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
|
427 |
c121d94672cb
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 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
|
429 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
|
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 *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
|
432 *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
|
433 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
|
434 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
438 GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
439 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
|
440 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
441 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
442 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
|
443 |
c121d94672cb
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 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
|
445 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
|
446 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
|
447 } 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
|
448 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
|
449 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
|
450 |
c121d94672cb
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 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
|
452 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
|
453 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
|
454 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
|
455 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
|
456 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 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
|
458 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
|
459 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
|
460 } |
c121d94672cb
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 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
|
462 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 } |
c121d94672cb
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 |
c121d94672cb
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 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
466 GDI_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
467 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
|
468 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
469 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
|
470 |
c121d94672cb
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 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
|
472 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
|
473 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
|
474 } 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
|
475 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
|
476 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
|
477 |
c121d94672cb
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 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
|
479 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
|
480 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
|
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 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
|
484 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
|
485 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
|
486 } |
c121d94672cb
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 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
|
488 } |
c121d94672cb
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 } |
c121d94672cb
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 |
c121d94672cb
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 static int |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
492 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
|
493 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
494 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
495 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
496 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
497 static int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
498 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
|
499 { |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
500 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
|
501 |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
502 switch (texture->blendMode) { |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
503 case SDL_BLENDMODE_NONE: |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
504 if (data->premultiplied) { |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
505 /* 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
|
506 } |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
507 return 0; |
3139 | 508 #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
|
509 case SDL_BLENDMODE_MASK: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
510 case SDL_BLENDMODE_BLEND: |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
511 if (!data->premultiplied && data->pixels) { |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
512 switch (texture->format) { |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
513 case SDL_PIXELFORMAT_ARGB8888: |
3055 | 514 SDL_PreMultiplyAlphaARGB8888(texture->w, texture->h, |
515 (Uint32 *) data->pixels, | |
516 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
517 data->premultiplied = SDL_TRUE; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
518 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
519 case SDL_PIXELFORMAT_RGBA8888: |
3055 | 520 SDL_PreMultiplyAlphaRGBA8888(texture->w, texture->h, |
521 (Uint32 *) data->pixels, | |
522 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
523 data->premultiplied = SDL_TRUE; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
524 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
525 case SDL_PIXELFORMAT_ABGR8888: |
3055 | 526 SDL_PreMultiplyAlphaABGR8888(texture->w, texture->h, |
527 (Uint32 *) data->pixels, | |
528 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
529 data->premultiplied = SDL_TRUE; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
530 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
531 case SDL_PIXELFORMAT_BGRA8888: |
3055 | 532 SDL_PreMultiplyAlphaBGRA8888(texture->w, texture->h, |
533 (Uint32 *) data->pixels, | |
534 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
535 data->premultiplied = SDL_TRUE; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
536 break; |
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 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
539 return 0; |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
540 #endif |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
541 default: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
542 SDL_Unsupported(); |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
543 texture->blendMode = SDL_BLENDMODE_NONE; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
544 return -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
545 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
546 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
547 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
548 static int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
549 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
|
550 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
551 switch (texture->scaleMode) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
552 case SDL_TEXTURESCALEMODE_NONE: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
553 case SDL_TEXTURESCALEMODE_FAST: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
554 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
555 case SDL_TEXTURESCALEMODE_SLOW: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
556 case SDL_TEXTURESCALEMODE_BEST: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
557 SDL_Unsupported(); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
558 texture->scaleMode = SDL_TEXTURESCALEMODE_FAST; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
559 return -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
560 default: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
561 SDL_Unsupported(); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
562 texture->scaleMode = SDL_TEXTURESCALEMODE_NONE; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
563 return -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
564 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
565 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
566 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
567 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
568 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
569 GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
570 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
|
571 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
572 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
|
573 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 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
|
575 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
|
576 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
|
577 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
578 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
|
579 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
|
580 } else { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
581 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
|
582 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
583 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
|
584 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
|
585 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
|
586 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
|
587 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 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
|
589 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
|
590 (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
|
591 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
|
592 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
|
593 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
|
594 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
|
595 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
|
596 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
|
597 } |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
598 if (data->premultiplied) { |
3055 | 599 Uint32 *pixels = |
600 (Uint32 *) data->pixels + rect->y * (data->pitch / 4) + | |
601 rect->x; | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
602 switch (texture->format) { |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
603 case SDL_PIXELFORMAT_ARGB8888: |
3055 | 604 SDL_PreMultiplyAlphaARGB8888(rect->w, rect->h, pixels, |
605 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
606 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
607 case SDL_PIXELFORMAT_RGBA8888: |
3055 | 608 SDL_PreMultiplyAlphaRGBA8888(rect->w, rect->h, pixels, |
609 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
610 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
611 case SDL_PIXELFORMAT_ABGR8888: |
3055 | 612 SDL_PreMultiplyAlphaABGR8888(rect->w, rect->h, pixels, |
613 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
614 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
615 case SDL_PIXELFORMAT_BGRA8888: |
3055 | 616 SDL_PreMultiplyAlphaBGRA8888(rect->w, rect->h, pixels, |
617 data->pitch); | |
3054
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
618 break; |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
619 } |
8d93bfecb9dc
Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents:
2929
diff
changeset
|
620 } |
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
|
621 } 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
|
622 #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
|
623 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
|
624 (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
|
625 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
|
626 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
|
627 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
|
628 } |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
629 #else |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
630 SDL_SetError("FIXME: Update Texture"); |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
631 return -1; |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
632 #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
|
633 } 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
|
634 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
|
635 ("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
|
636 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
|
637 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
638 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
|
639 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
640 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
641 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
643 GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
644 const SDL_Rect * rect, int markDirty, void **pixels, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
645 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
|
646 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
647 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
|
648 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
649 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
|
650 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
|
651 pitch); |
1898
f89e49e51e89
Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents:
1897
diff
changeset
|
652 } else if (data->pixels) { |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
653 #ifndef _WIN32_WCE |
3139 | 654 /* 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
|
655 GdiFlush(); |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
656 #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
|
657 *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
|
658 (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
|
659 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
|
660 *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
|
661 return 0; |
1898
f89e49e51e89
Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents:
1897
diff
changeset
|
662 } else { |
f89e49e51e89
Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents:
1897
diff
changeset
|
663 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
|
664 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
|
665 } |
c121d94672cb
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 } |
c121d94672cb
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 |
c121d94672cb
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 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
669 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
|
670 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
671 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
|
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 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
|
674 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
|
675 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
|
676 } |
c121d94672cb
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 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
678 |
c121d94672cb
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 static int |
2927
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
680 GDI_SetDrawBlendMode(SDL_Renderer * renderer) |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
681 { |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
682 switch (renderer->blendMode) { |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
683 case SDL_BLENDMODE_NONE: |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
684 return 0; |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
685 default: |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
686 SDL_Unsupported(); |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
687 renderer->blendMode = SDL_BLENDMODE_NONE; |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
688 return -1; |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
689 } |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
690 } |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
691 |
2133d2d300fd
SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents:
2926
diff
changeset
|
692 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
693 GDI_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
694 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
|
695 { |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
696 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
|
697 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
698 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
|
699 |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
700 if (data->makedirty) { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
701 /* 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
|
702 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
|
703 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
|
704 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
705 rect.x = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
706 rect.y = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
707 rect.w = window->w; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
708 rect.h = window->h; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
709 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
|
710 /* Nothing to draw */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
711 return 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
712 } |
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
|
713 |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
714 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
|
715 } |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
716 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
717 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
|
718 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
|
719 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
|
720 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
721 |
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
|
722 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
|
723 } |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
724 |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
725 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
726 GDI_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
727 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
|
728 { |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
729 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
|
730 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
|
731 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
|
732 |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
733 if (data->makedirty) { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
734 /* 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
|
735 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
|
736 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
|
737 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
738 clip.x = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
739 clip.y = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
740 clip.w = window->w; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
741 clip.h = window->h; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
742 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
|
743 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
|
744 /* Nothing to draw */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
745 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
|
746 } |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
747 |
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
|
748 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
|
749 } |
27f2b5e7e899
In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents:
2919
diff
changeset
|
750 |
3056
a434fe6360df
Oh, Polyline() uses a pen, not a brush. Doh! :)
Sam Lantinga <slouken@libsdl.org>
parents:
3055
diff
changeset
|
751 /* 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
|
752 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
|
753 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
|
754 { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
755 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
|
756 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
757 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
758 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
|
759 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
|
760 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
|
761 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
762 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
|
763 SDL_stack_free(p); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
764 } |
3056
a434fe6360df
Oh, Polyline() uses a pen, not a brush. Doh! :)
Sam Lantinga <slouken@libsdl.org>
parents:
3055
diff
changeset
|
765 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
|
766 |
3535
b403f790df65
Hey, those automated tests are coming in handy! Fixed GDI rendering semantics
Sam Lantinga <slouken@libsdl.org>
parents:
3534
diff
changeset
|
767 /* 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
|
768 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
|
769 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
|
770 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
|
771 } |
3535
b403f790df65
Hey, those automated tests are coming in handy! Fixed GDI rendering semantics
Sam Lantinga <slouken@libsdl.org>
parents:
3534
diff
changeset
|
772 |
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
|
773 if (!status) { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
774 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
|
775 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
|
776 } |
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 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
|
778 } |
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 |
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 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
781 GDI_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
782 int count) |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
783 { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
784 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
785 HPEN pen; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
786 POINT vertices[5]; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
787 int i, status = 1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
788 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
789 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
|
790 SDL_Window *window = renderer->window; |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
791 SDL_Rect clip, rect; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
792 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
793 clip.x = 0; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
794 clip.y = 0; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
795 clip.w = window->w; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
796 clip.h = window->h; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
797 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
798 for (i = 0; i < count; ++i) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
799 if (SDL_IntersectRect(rects[i], &clip, &rect)) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
800 SDL_AddDirtyRect(&data->dirty, &rect); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
801 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
802 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
803 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
804 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
805 /* 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
|
806 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
|
807 SelectObject(data->current_hdc, pen); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
808 for (i = 0; i < count; ++i) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
809 const SDL_Rect *rect = rects[i]; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
810 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
811 vertices[0].x = rect->x; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
812 vertices[0].y = rect->y; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
813 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
814 vertices[1].x = rect->x+rect->w-1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
815 vertices[1].y = rect->y; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
816 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
817 vertices[2].x = rect->x+rect->w-1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
818 vertices[2].y = rect->y+rect->h-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 vertices[3].x = rect->x; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
821 vertices[3].y = rect->y+rect->h-1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
822 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
823 vertices[4].x = rect->x; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
824 vertices[4].y = rect->y; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
825 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
826 status &= Polyline(data->current_hdc, vertices, 5); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
827 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
828 DeleteObject(pen); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
829 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
830 if (!status) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
831 WIN_SetError("Polyline()"); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
832 return -1; |
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 return 0; |
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 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
837 static int |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
838 GDI_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
839 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
|
840 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
841 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
|
842 RECT rc; |
1899 | 843 HBRUSH brush; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
844 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
|
845 |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
846 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
|
847 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
|
848 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
|
849 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
850 clip.x = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
851 clip.y = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
852 clip.w = window->w; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
853 clip.h = window->h; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
854 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
855 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
|
856 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
|
857 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
|
858 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
859 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
860 } |
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
|
861 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
862 /* 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
|
863 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
|
864 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
|
865 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
|
866 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
|
867 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
868 rc.left = rect->x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
869 rc.top = rect->y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
870 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
|
871 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
|
872 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3535
diff
changeset
|
873 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
|
874 } |
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
|
875 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
|
876 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
877 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
|
878 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
|
879 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
|
880 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
881 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
|
882 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
883 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
884 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
885 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
|
886 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
|
887 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
888 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
889 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
|
890 |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
891 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
|
892 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
|
893 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
894 |
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->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
|
896 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
|
897 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
|
898 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
|
899 } |
3055 | 900 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
|
901 #ifdef _WIN32_WCE |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
902 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
|
903 return -1; |
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
904 #else |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
905 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
|
906 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
|
907 0, |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1975
diff
changeset
|
908 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
|
909 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
|
910 }; |
c121d94672cb
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 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
|
912 (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
|
913 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
|
914 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
|
915 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
|
916 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
|
917 } |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
918 #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
|
919 } 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
|
920 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
|
921 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
|
922 (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
|
923 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
|
924 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
|
925 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
|
926 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
|
927 } |
c121d94672cb
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 } 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
|
929 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
|
930 (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
|
931 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
|
932 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
|
933 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
|
934 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
|
935 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
936 } |
c121d94672cb
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 } |
c121d94672cb
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 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
|
939 } |
c121d94672cb
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 |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
941 static int |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
942 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
|
943 Uint32 format, void * pixels, int pitch) |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
944 { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
945 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
|
946 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
|
947 SDL_VideoDisplay *display = window->display; |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
948 struct { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
949 HBITMAP hbm; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
950 void *pixels; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
951 int pitch; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
952 Uint32 format; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
953 } data; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
954 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
955 data.format = display->current_mode.format; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
956 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
|
957 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
958 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
|
959 data.pitch, data.format, NULL, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
960 &data.pixels); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
961 if (!data.hbm) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
962 WIN_SetError("Couldn't create bitmap"); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
963 return -1; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
964 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
965 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
966 SelectObject(renderdata->memory_hdc, data.hbm); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
967 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
|
968 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
|
969 WIN_SetError("BitBlt()"); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
970 DeleteObject(data.hbm); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
971 return -1; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
972 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
973 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
974 SDL_ConvertPixels(rect->w, rect->h, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
975 data.format, data.pixels, data.pitch, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
976 format, pixels, pitch); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
977 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
978 DeleteObject(data.hbm); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
979 return 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
980 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
981 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
982 static int |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
983 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
|
984 Uint32 format, const void * pixels, int pitch) |
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 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
|
987 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
|
988 SDL_VideoDisplay *display = window->display; |
3534
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
989 struct { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
990 HBITMAP hbm; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
991 void *pixels; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
992 int pitch; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
993 Uint32 format; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
994 } data; |
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 data.format = display->current_mode.format; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
997 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
|
998 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
999 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
|
1000 data.pitch, data.format, |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1001 NULL, &data.pixels); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1002 if (!data.hbm) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1003 WIN_SetError("Couldn't create bitmap"); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1004 return -1; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1005 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1006 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1007 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
|
1008 data.format, data.pixels, data.pitch); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1009 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1010 SelectObject(renderdata->memory_hdc, data.hbm); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1011 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
|
1012 renderdata->memory_hdc, 0, 0, SRCCOPY)) { |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1013 WIN_SetError("BitBlt()"); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1014 DeleteObject(data.hbm); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1015 return -1; |
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 |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1018 DeleteObject(data.hbm); |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1019 return 0; |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1020 } |
9d129e1d0782
Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
1021 |
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
|
1022 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1023 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
|
1024 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1025 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
|
1026 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
|
1027 |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1028 /* Send the data to the display */ |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
1029 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
|
1030 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
|
1031 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
|
1032 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
|
1033 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
|
1034 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1035 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
|
1036 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1037 |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1038 /* Update the flipping chain, if any */ |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
1039 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
|
1040 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
|
1041 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
|
1042 } 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
|
1043 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
|
1044 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
|
1045 } |
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
|
1046 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1047 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1048 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1049 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
|
1050 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1051 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
|
1052 |
c121d94672cb
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 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
|
1054 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
|
1055 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1056 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
|
1057 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
|
1058 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1059 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
|
1060 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
|
1061 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1062 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
|
1063 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
|
1064 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1065 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
|
1066 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
|
1067 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1068 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1069 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1070 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
|
1071 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1072 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
|
1073 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
|
1074 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1075 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
|
1076 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
|
1077 DeleteDC(data->memory_hdc); |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
1078 #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
|
1079 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
|
1080 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
|
1081 } |
3097
0d12e8f1de3c
Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
3056
diff
changeset
|
1082 #endif |
1897
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1083 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
|
1084 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
|
1085 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
|
1086 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1087 } |
c2a27da60b18
Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1088 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
|
1089 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
|
1090 } |
c121d94672cb
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 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
|
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 |
c121d94672cb
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 #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
|
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 /* vi: set ts=4 sw=4 expandtab: */ |