annotate src/video/win32/SDL_gdirender.c @ 3535:b403f790df65

Hey, those automated tests are coming in handy! Fixed GDI rendering semantics
author Sam Lantinga <slouken@libsdl.org>
date Mon, 07 Dec 2009 10:08:24 +0000
parents 9d129e1d0782
children 0267b8b1595c
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
2859
99210400e8b9 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 2811
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #if SDL_VIDEO_RENDER_GDI
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #include "SDL_win32video.h"
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
27 #include "../SDL_rect_c.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 #include "../SDL_yuv_sw_c.h"
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
29 #include "../SDL_alphamult.h"
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
31 #ifdef _WIN32_WCE
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
32 #define NO_GETDIBBITS 1
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
33 #endif
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
34
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 /* GDI renderer implementation */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
37 static SDL_Renderer *GDI_CreateRenderer(SDL_Window * window, Uint32 flags);
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
38 static int GDI_DisplayModeChanged(SDL_Renderer * renderer);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
39 static int GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
40 static int GDI_QueryTexturePixels(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
41 SDL_Texture * texture, void **pixels,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
42 int *pitch);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
43 static int GDI_SetTexturePalette(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
44 SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
45 const SDL_Color * colors, int firstcolor,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
46 int ncolors);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
47 static int GDI_GetTexturePalette(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
48 SDL_Texture * texture, SDL_Color * colors,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
49 int firstcolor, int ncolors);
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
50 static int GDI_SetTextureAlphaMod(SDL_Renderer * renderer,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
51 SDL_Texture * texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
52 static int GDI_SetTextureBlendMode(SDL_Renderer * renderer,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
53 SDL_Texture * texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
54 static int GDI_SetTextureScaleMode(SDL_Renderer * renderer,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
55 SDL_Texture * texture);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
56 static int GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
57 const SDL_Rect * rect, const void *pixels,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
58 int pitch);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
59 static int GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
60 const SDL_Rect * rect, int markDirty,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
61 void **pixels, int *pitch);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
62 static void GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
2927
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
63 static int GDI_SetDrawBlendMode(SDL_Renderer * renderer);
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
64 static int GDI_RenderPoint(SDL_Renderer * renderer, int x, int y);
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
65 static int GDI_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
66 int y2);
2919
2f91a3847ae8 Fixed compiling Windows renderers. Lines and points will be implemented later.
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
67 static int GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
68 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
69 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
70 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
71 Uint32 format, void * pixels, int pitch);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
72 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
73 Uint32 format, const void * pixels, int pitch);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
74 static void GDI_RenderPresent(SDL_Renderer * renderer);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
75 static void GDI_DestroyTexture(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
76 SDL_Texture * texture);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
77 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
78
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
80 SDL_RenderDriver GDI_RenderDriver = {
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
81 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
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 "gdi",
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
84 (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
85 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
86 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED),
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
87 (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
88 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK),
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
89 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST),
2811
7af2419ad5b0 Fixed the list of supported YUV formats
Sam Lantinga <slouken@libsdl.org>
parents: 2810
diff changeset
90 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
91 {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
92 SDL_PIXELFORMAT_INDEX8,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
93 SDL_PIXELFORMAT_RGB555,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
94 SDL_PIXELFORMAT_RGB565,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
95 SDL_PIXELFORMAT_RGB888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
96 SDL_PIXELFORMAT_BGR888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
97 SDL_PIXELFORMAT_ARGB8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
98 SDL_PIXELFORMAT_RGBA8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
99 SDL_PIXELFORMAT_ABGR8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
100 SDL_PIXELFORMAT_BGRA8888,
2811
7af2419ad5b0 Fixed the list of supported YUV formats
Sam Lantinga <slouken@libsdl.org>
parents: 2810
diff changeset
101 SDL_PIXELFORMAT_YV12,
7af2419ad5b0 Fixed the list of supported YUV formats
Sam Lantinga <slouken@libsdl.org>
parents: 2810
diff changeset
102 SDL_PIXELFORMAT_IYUV,
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
103 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
104 SDL_PIXELFORMAT_UYVY,
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents: 2786
diff changeset
105 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
106 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
107 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
108 };
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109
c121d94672cb 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 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
111 {
c121d94672cb 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 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
113 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
114 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
115 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
116 HDC current_hdc;
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
117 #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
118 LPBITMAPINFO bmi;
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
119 #endif
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
120 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
121 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
122 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
123 SDL_bool makedirty;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
124 } 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
125
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 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
127 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 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
129 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
130 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
131 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
132 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
133 int pitch;
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
134 SDL_bool premultiplied;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
135 } 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
136
c121d94672cb 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 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
138 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
139 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
140 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
141 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
142
c121d94672cb 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 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
144 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
145 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
146 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
147 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
148 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
149 }
c121d94672cb 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
c121d94672cb 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 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
152 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
153 {
3520
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
154 int i;
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
155 for (i = 0; i < _this->num_displays; ++i) {
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
156 SDL_AddRenderDriver(&_this->displays[i], &GDI_RenderDriver);
83518f8fcd61 Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
157 }
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
158 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 SDL_Renderer *
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
161 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
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 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
164 SDL_Renderer *renderer;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
165 GDI_RenderData *data;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 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
167 HBITMAP hbm;
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
168 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
169
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
170 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
171 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
172 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
173 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
174 }
c121d94672cb 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 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
177 if (!data) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
178 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
179 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
180 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
181 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
183 renderer->DisplayModeChanged = GDI_DisplayModeChanged;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
184 renderer->CreateTexture = GDI_CreateTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
185 renderer->QueryTexturePixels = GDI_QueryTexturePixels;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
186 renderer->SetTexturePalette = GDI_SetTexturePalette;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
187 renderer->GetTexturePalette = GDI_GetTexturePalette;
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
188 renderer->SetTextureAlphaMod = GDI_SetTextureAlphaMod;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
189 renderer->SetTextureBlendMode = GDI_SetTextureBlendMode;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
190 renderer->SetTextureScaleMode = GDI_SetTextureScaleMode;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
191 renderer->UpdateTexture = GDI_UpdateTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
192 renderer->LockTexture = GDI_LockTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
193 renderer->UnlockTexture = GDI_UnlockTexture;
2927
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
194 renderer->SetDrawBlendMode = GDI_SetDrawBlendMode;
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
195 renderer->RenderPoint = GDI_RenderPoint;
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
196 renderer->RenderLine = GDI_RenderLine;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
197 renderer->RenderFill = GDI_RenderFill;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
198 renderer->RenderCopy = GDI_RenderCopy;
3534
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
199 renderer->RenderReadPixels = GDI_RenderReadPixels;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
200 renderer->RenderWritePixels = GDI_RenderWritePixels;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
201 renderer->RenderPresent = GDI_RenderPresent;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
202 renderer->DestroyTexture = GDI_DestroyTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
203 renderer->DestroyRenderer = GDI_DestroyRenderer;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
204 renderer->info = GDI_RenderDriver.info;
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
205 renderer->window = window->id;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 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
207
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
208 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
209
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
210 data->hwnd = windowdata->hwnd;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
211 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
212 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
213 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
214
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
215 #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
216 /* 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
217 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
218 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
219 if (!data->bmi) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
220 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
221 SDL_OutOfMemory();
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
222 return NULL;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
223 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
224 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
225
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
226 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
227 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
228 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
229 DeleteObject(hbm);
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
230 #endif
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
231
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
232 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
233 renderer->info.flags |=
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
234 (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
235 n = 0;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
236 } else if (flags & SDL_RENDERER_PRESENTFLIP2) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
237 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
238 n = 2;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
239 } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
240 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
241 n = 3;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
242 } else {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
243 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
244 n = 1;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
245 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
246 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
247 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
248 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
249 if (!data->hbm[i]) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
250 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
251 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
252 return NULL;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
253 }
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 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
256 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
257 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
258 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
259 } else {
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
260 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
261 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
262 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
263 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
264
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
265 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
266 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 static int
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
269 GDI_DisplayModeChanged(SDL_Renderer * renderer)
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
270 {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
271 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
272 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
273 int i, n;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
274
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
275 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
276 n = 0;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
277 } 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
278 n = 2;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
279 } 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
280 n = 3;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
281 } else {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
282 n = 1;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
283 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
284 for (i = 0; i < n; ++i) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
285 if (data->hbm[i]) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
286 DeleteObject(data->hbm[i]);
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
287 data->hbm[i] = NULL;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
288 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
289 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
290 for (i = 0; i < n; ++i) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
291 data->hbm[i] =
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
292 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
293 if (!data->hbm[i]) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
294 WIN_SetError("CreateCompatibleBitmap()");
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
295 return -1;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
296 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
297 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
298 if (n > 0) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
299 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
300 }
2810
27cb878a278e Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents: 2786
diff changeset
301 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
302
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
303 return 0;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
304 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
305
3534
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
306 static HBITMAP
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
307 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
308 HPALETTE * hpal, void ** pixels)
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
309 {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
310 int bmi_size;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
311 LPBITMAPINFO bmi;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
312
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
313 bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
314 bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
315 if (!bmi) {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
316 SDL_OutOfMemory();
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
317 return NULL;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
318 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
319 bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
320 bmi->bmiHeader.biWidth = w;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
321 bmi->bmiHeader.biHeight = -h; /* topdown bitmap */
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
322 bmi->bmiHeader.biPlanes = 1;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
323 bmi->bmiHeader.biSizeImage = h * pitch;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
324 bmi->bmiHeader.biXPelsPerMeter = 0;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
325 bmi->bmiHeader.biYPelsPerMeter = 0;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
326 bmi->bmiHeader.biClrUsed = 0;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
327 bmi->bmiHeader.biClrImportant = 0;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
328 bmi->bmiHeader.biBitCount = SDL_BYTESPERPIXEL(format) * 8;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
329 if (SDL_ISPIXELFORMAT_INDEXED(format)) {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
330 bmi->bmiHeader.biCompression = BI_RGB;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
331 if (hpal) {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
332 int i, ncolors;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
333 LOGPALETTE *palette;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
334
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
335 ncolors = (1 << SDL_BITSPERPIXEL(format));
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
336 palette =
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
337 (LOGPALETTE *) SDL_malloc(sizeof(*palette) +
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
338 ncolors * sizeof(PALETTEENTRY));
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
339 if (!palette) {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
340 SDL_free(bmi);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
341 SDL_OutOfMemory();
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
342 return NULL;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
343 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
344 palette->palVersion = 0x300;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
345 palette->palNumEntries = ncolors;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
346 for (i = 0; i < ncolors; ++i) {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
347 palette->palPalEntry[i].peRed = 0xFF;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
348 palette->palPalEntry[i].peGreen = 0xFF;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
349 palette->palPalEntry[i].peBlue = 0xFF;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
350 palette->palPalEntry[i].peFlags = 0;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
351 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
352 *hpal = CreatePalette(palette);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
353 SDL_free(palette);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
354 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
355 } else {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
356 int bpp;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
357 Uint32 Rmask, Gmask, Bmask, Amask;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
358
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
359 bmi->bmiHeader.biCompression = BI_BITFIELDS;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
360 SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask,
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
361 &Amask);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
362 ((Uint32 *) bmi->bmiColors)[0] = Rmask;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
363 ((Uint32 *) bmi->bmiColors)[1] = Gmask;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
364 ((Uint32 *) bmi->bmiColors)[2] = Bmask;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
365 if (hpal) {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
366 *hpal = NULL;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
367 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
368 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
369 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
370 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
371
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
372 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
373 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
374 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
375 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
376 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
377 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
378 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
379
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
380 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
381 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
382 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
383 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
384 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 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
387
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
2786
Sam Lantinga <slouken@libsdl.org>
parents: 2781
diff changeset
389 data->yuv =
Sam Lantinga <slouken@libsdl.org>
parents: 2781
diff changeset
390 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
391 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
392 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
393 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 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
395 } 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
396 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
397 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
398 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
399
2222
926294b2bb4e Emphasized the separation between SDL_Surface and SDL_Texture
Sam Lantinga <slouken@libsdl.org>
parents: 1985
diff changeset
400 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
401 || texture->format != display->current_mode.format) {
3534
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
402 data->hbm = GDI_CreateDIBSection(renderdata->memory_hdc,
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
403 texture->w, texture->h,
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
404 data->pitch, data->format,
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
405 &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
406 } else {
3534
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
407 data->hbm = CreateCompatibleBitmap(renderdata->window_hdc,
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
408 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
409 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 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
411 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
412 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
413 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 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
415 }
c121d94672cb 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
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
418 GDI_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
419 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
420 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
421 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
422
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 if (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
424 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
425 } 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
426 *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
427 *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
428 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
429 }
c121d94672cb 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
c121d94672cb 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 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
433 GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
434 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
435 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
436 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
437 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
438
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
439 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
440 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
441 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
442 } 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
443 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
444 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
445
c121d94672cb 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 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
447 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
448 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
449 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
450 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
451 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
452 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
453 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
454 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
455 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 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
457 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459
c121d94672cb 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 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
461 GDI_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
462 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
463 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
464 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
465
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466 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
467 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
468 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
469 } 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
470 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
471 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
472
c121d94672cb 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 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
474 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
475 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
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 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
478 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
479 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
480 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
481 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 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
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 }
c121d94672cb 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
c121d94672cb 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 static int
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
487 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
488 {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
489 return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
490 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
491
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
492 static int
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
493 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
494 {
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
495 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
496
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
497 switch (texture->blendMode) {
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
498 case SDL_BLENDMODE_NONE:
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
499 if (data->premultiplied) {
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
500 /* 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
501 }
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
502 return 0;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3097
diff changeset
503 #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
504 case SDL_BLENDMODE_MASK:
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
505 case SDL_BLENDMODE_BLEND:
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
506 if (!data->premultiplied && data->pixels) {
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
507 switch (texture->format) {
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
508 case SDL_PIXELFORMAT_ARGB8888:
3055
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
509 SDL_PreMultiplyAlphaARGB8888(texture->w, texture->h,
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
510 (Uint32 *) data->pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
511 data->pitch);
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
512 data->premultiplied = SDL_TRUE;
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
513 break;
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
514 case SDL_PIXELFORMAT_RGBA8888:
3055
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
515 SDL_PreMultiplyAlphaRGBA8888(texture->w, texture->h,
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
516 (Uint32 *) data->pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
517 data->pitch);
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
518 data->premultiplied = SDL_TRUE;
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
519 break;
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
520 case SDL_PIXELFORMAT_ABGR8888:
3055
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
521 SDL_PreMultiplyAlphaABGR8888(texture->w, texture->h,
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
522 (Uint32 *) data->pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
523 data->pitch);
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
524 data->premultiplied = SDL_TRUE;
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
525 break;
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
526 case SDL_PIXELFORMAT_BGRA8888:
3055
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
527 SDL_PreMultiplyAlphaBGRA8888(texture->w, texture->h,
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
528 (Uint32 *) data->pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
529 data->pitch);
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
530 data->premultiplied = SDL_TRUE;
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
531 break;
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
532 }
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
533 }
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
534 return 0;
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
535 #endif
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
536 default:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
537 SDL_Unsupported();
2884
9dde605c7540 Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2859
diff changeset
538 texture->blendMode = SDL_BLENDMODE_NONE;
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
539 return -1;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
540 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
541 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
542
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
543 static int
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
544 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
545 {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
546 switch (texture->scaleMode) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
547 case SDL_TEXTURESCALEMODE_NONE:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
548 case SDL_TEXTURESCALEMODE_FAST:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
549 return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
550 case SDL_TEXTURESCALEMODE_SLOW:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
551 case SDL_TEXTURESCALEMODE_BEST:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
552 SDL_Unsupported();
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
553 texture->scaleMode = SDL_TEXTURESCALEMODE_FAST;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
554 return -1;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
555 default:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
556 SDL_Unsupported();
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
557 texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
558 return -1;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
559 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
560 return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
561 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
562
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
563 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
564 GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
565 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
566 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
567 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
568
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 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
570 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
571 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
572 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 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
574 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
575 } else {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
576 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
577
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578 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
579 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
580 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
581 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
582
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
583 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
584 dst =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
585 (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
586 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
587 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
588 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
589 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
590 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
591 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
592 }
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
593 if (data->premultiplied) {
3055
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
594 Uint32 *pixels =
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
595 (Uint32 *) data->pixels + rect->y * (data->pitch / 4) +
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
596 rect->x;
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
597 switch (texture->format) {
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
598 case SDL_PIXELFORMAT_ARGB8888:
3055
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
599 SDL_PreMultiplyAlphaARGB8888(rect->w, rect->h, pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
600 data->pitch);
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
601 break;
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
602 case SDL_PIXELFORMAT_RGBA8888:
3055
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
603 SDL_PreMultiplyAlphaRGBA8888(rect->w, rect->h, pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
604 data->pitch);
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
605 break;
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
606 case SDL_PIXELFORMAT_ABGR8888:
3055
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
607 SDL_PreMultiplyAlphaABGR8888(rect->w, rect->h, pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
608 data->pitch);
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
609 break;
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
610 case SDL_PIXELFORMAT_BGRA8888:
3055
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
611 SDL_PreMultiplyAlphaBGRA8888(rect->w, rect->h, pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
612 data->pitch);
3054
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
613 break;
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
614 }
8d93bfecb9dc Fixed alpha blending textures with the GDI renderer
Sam Lantinga <slouken@libsdl.org>
parents: 2929
diff changeset
615 }
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
616 } 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
617 #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
618 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
619 (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
620 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
621 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
622 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
623 }
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
624 #else
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
625 SDL_SetError("FIXME: Update Texture");
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
626 return -1;
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
627 #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
628 } 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
629 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
630 ("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
631 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
632 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
633 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
634 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
635 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
636
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
637 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
638 GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
639 const SDL_Rect * rect, int markDirty, void **pixels,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
640 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
641 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
642 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
643
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
644 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
645 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
646 pitch);
1898
f89e49e51e89 Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents: 1897
diff changeset
647 } else if (data->pixels) {
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
648 #ifndef _WIN32_WCE
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3097
diff changeset
649 /* 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
650 GdiFlush();
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
651 #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
652 *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
653 (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
654 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
655 *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
656 return 0;
1898
f89e49e51e89 Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents: 1897
diff changeset
657 } else {
f89e49e51e89 Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents: 1897
diff changeset
658 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
659 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
660 }
c121d94672cb 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 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
662
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
663 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
664 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
665 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
666 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
667
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
668 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
669 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
670 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
671 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
672 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
673
c121d94672cb 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 static int
2927
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
675 GDI_SetDrawBlendMode(SDL_Renderer * renderer)
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
676 {
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
677 switch (renderer->blendMode) {
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
678 case SDL_BLENDMODE_NONE:
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
679 return 0;
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
680 default:
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
681 SDL_Unsupported();
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
682 renderer->blendMode = SDL_BLENDMODE_NONE;
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
683 return -1;
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
684 }
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
685 }
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
686
2133d2d300fd SetDrawColor() and SetDrawBlendMode() are optional
Sam Lantinga <slouken@libsdl.org>
parents: 2926
diff changeset
687 static int
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
688 GDI_RenderPoint(SDL_Renderer * renderer, int x, int y)
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
689 {
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
690 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
691
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
692 if (data->makedirty) {
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
693 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
694
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
695 rect.x = x;
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
696 rect.y = y;
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
697 rect.w = 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
698 rect.h = 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
699
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
700 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
701 }
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
702
2929
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
703 SetPixel(data->current_hdc, x, y,
Sam Lantinga <slouken@libsdl.org>
parents: 2927
diff changeset
704 RGB(renderer->r, renderer->g, renderer->b));
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
705 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
706 }
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
707
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
708 static int
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
709 GDI_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
710 {
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
711 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
712 POINT points[2];
3056
a434fe6360df Oh, Polyline() uses a pen, not a brush. Doh! :)
Sam Lantinga <slouken@libsdl.org>
parents: 3055
diff changeset
713 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
714 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
715
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
716 if (data->makedirty) {
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
717 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
718
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
719 if (x1 < x2) {
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
720 rect.x = x1;
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
721 rect.w = (x2 - x1) + 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
722 } else {
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
723 rect.x = x2;
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
724 rect.w = (x1 - x2) + 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
725 }
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
726 if (y1 < y2) {
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
727 rect.y = y1;
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 rect.h = (y2 - y1) + 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
729 } else {
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
730 rect.y = y2;
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
731 rect.h = (y1 - y2) + 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
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 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
734 }
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
735
3056
a434fe6360df Oh, Polyline() uses a pen, not a brush. Doh! :)
Sam Lantinga <slouken@libsdl.org>
parents: 3055
diff changeset
736 /* 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
737 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
738 SelectObject(data->current_hdc, 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
739 points[0].x = x1;
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
740 points[0].y = y1;
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
741 points[1].x = x2;
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
742 points[1].y = y2;
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
743 status = Polyline(data->current_hdc, points, 2);
3056
a434fe6360df Oh, Polyline() uses a pen, not a brush. Doh! :)
Sam Lantinga <slouken@libsdl.org>
parents: 3055
diff changeset
744 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
745
3535
b403f790df65 Hey, those automated tests are coming in handy! Fixed GDI rendering semantics
Sam Lantinga <slouken@libsdl.org>
parents: 3534
diff changeset
746 /* Need to close the endpoint of the line */
b403f790df65 Hey, those automated tests are coming in handy! Fixed GDI rendering semantics
Sam Lantinga <slouken@libsdl.org>
parents: 3534
diff changeset
747 SetPixel(data->current_hdc, x2, y2,
b403f790df65 Hey, those automated tests are coming in handy! Fixed GDI rendering semantics
Sam Lantinga <slouken@libsdl.org>
parents: 3534
diff changeset
748 RGB(renderer->r, renderer->g, renderer->b));
b403f790df65 Hey, those automated tests are coming in handy! Fixed GDI rendering semantics
Sam Lantinga <slouken@libsdl.org>
parents: 3534
diff changeset
749
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
750 if (!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
751 WIN_SetError("FillRect()");
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
752 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
753 }
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
754 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
755 }
27f2b5e7e899 In theory this implements GDI rendering, but it doesn't work for some reason.
Sam Lantinga <slouken@libsdl.org>
parents: 2919
diff changeset
756
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 static int
2919
2f91a3847ae8 Fixed compiling Windows renderers. Lines and points will be implemented later.
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
758 GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
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
759 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
760 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
761 RECT rc;
1899
6a11e61bf805 debug cleanup
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
762 HBRUSH brush;
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
763 int 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
764
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
765 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
766 SDL_AddDirtyRect(&data->dirty, rect);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
767 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
768
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
769 rc.left = rect->x;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
770 rc.top = rect->y;
3535
b403f790df65 Hey, those automated tests are coming in handy! Fixed GDI rendering semantics
Sam Lantinga <slouken@libsdl.org>
parents: 3534
diff changeset
771 rc.right = rect->x + rect->w;
b403f790df65 Hey, those automated tests are coming in handy! Fixed GDI rendering semantics
Sam Lantinga <slouken@libsdl.org>
parents: 3534
diff changeset
772 rc.bottom = rect->y + rect->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
773
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
774 /* 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
775 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
776 SelectObject(data->current_hdc, 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
777 status = FillRect(data->current_hdc, &rc, 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
778 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
779
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
780 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
781 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
782 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
783 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
784 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
785 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
786
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
787 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
788 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
789 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
790 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
791 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
792 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
793
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
794 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
795 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
796 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
797
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
798 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
799 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
800 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
801 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
802 }
3055
Sam Lantinga <slouken@libsdl.org>
parents: 3054
diff changeset
803 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
804 #ifdef _WIN32_WCE
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
805 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
806 return -1;
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
807 #else
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
808 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
809 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
810 0,
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1975
diff changeset
811 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
812 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
813 };
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
814 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
815 (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
816 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
817 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
818 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
819 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
820 }
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
821 #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
822 } 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
823 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
824 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
825 (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
826 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
827 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
828 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
829 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
830 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
831 } 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
832 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
833 (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
834 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
835 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
836 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
837 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
838 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
839 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
840 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
841 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
842 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
843
3534
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
844 static int
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
845 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
846 Uint32 format, void * pixels, int pitch)
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
847 {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
848 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
849 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
850 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
851 struct {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
852 HBITMAP hbm;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
853 void *pixels;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
854 int pitch;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
855 Uint32 format;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
856 } data;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
857
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
858 data.format = display->current_mode.format;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
859 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
860
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
861 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
862 data.pitch, data.format, NULL,
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
863 &data.pixels);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
864 if (!data.hbm) {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
865 WIN_SetError("Couldn't create bitmap");
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
866 return -1;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
867 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
868
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
869 SelectObject(renderdata->memory_hdc, data.hbm);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
870 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
871 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
872 WIN_SetError("BitBlt()");
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
873 DeleteObject(data.hbm);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
874 return -1;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
875 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
876
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
877 SDL_ConvertPixels(rect->w, rect->h,
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
878 data.format, data.pixels, data.pitch,
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
879 format, pixels, pitch);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
880
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
881 DeleteObject(data.hbm);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
882 return 0;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
883 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
884
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
885 static int
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
886 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
887 Uint32 format, const void * pixels, int pitch)
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
888 {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
889 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
890 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
891 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
892 struct {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
893 HBITMAP hbm;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
894 void *pixels;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
895 int pitch;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
896 Uint32 format;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
897 } data;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
898
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
899 data.format = display->current_mode.format;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
900 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
901
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
902 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
903 data.pitch, data.format,
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
904 NULL, &data.pixels);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
905 if (!data.hbm) {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
906 WIN_SetError("Couldn't create bitmap");
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
907 return -1;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
908 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
909
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
910 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
911 data.format, data.pixels, data.pitch);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
912
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
913 SelectObject(renderdata->memory_hdc, data.hbm);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
914 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
915 renderdata->memory_hdc, 0, 0, SRCCOPY)) {
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
916 WIN_SetError("BitBlt()");
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
917 DeleteObject(data.hbm);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
918 return -1;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
919 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
920
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
921 DeleteObject(data.hbm);
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
922 return 0;
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
923 }
9d129e1d0782 Implemented RenderReadPixels() and RenderWritePixels() for GDI renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
924
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
925 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
926 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
927 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
928 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
929 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
930
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
931 /* Send the data to the display */
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
932 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
933 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
934 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
935 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
936 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
937 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
938 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
939 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
940
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
941 /* Update the flipping chain, if any */
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
942 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
943 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
944 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
945 } 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
946 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
947 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
948 }
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
949 }
c121d94672cb 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
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
951 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
952 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
953 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
954 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
955
c121d94672cb 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 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
957 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
958 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
959 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
960 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
961 }
c121d94672cb 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 (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
963 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
964 }
c121d94672cb 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 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
966 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
967 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
968 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
969 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
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
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
972 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
973 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
974 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
975 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
976 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
977
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
978 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
979 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
980 DeleteDC(data->memory_hdc);
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
981 #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
982 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
983 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
984 }
3097
0d12e8f1de3c Date: Thu, 05 Feb 2009 18:07:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 3056
diff changeset
985 #endif
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
986 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
987 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
988 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
989 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
990 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
991 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
992 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
993 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
994 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
995 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
996
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
997 #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
998
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
999 /* vi: set ts=4 sw=4 expandtab: */