annotate src/video/windows/SDL_gdirender.c @ 5115:686d795b1b29

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