annotate src/video/win32/SDL_gdirender.c @ 1975:ccef0d0c40c6

Added resize support for GDI and Direct3D renderers
author Sam Lantinga <slouken@libsdl.org>
date Mon, 07 Aug 2006 05:24:13 +0000
parents a788656ca29a
children 8055185ae4ed
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
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2006 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
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"
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
c121d94672cb 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 /* 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
31
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
32 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
33 static int GDI_DisplayModeChanged(SDL_Renderer * renderer);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
34 static int GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
35 static int GDI_QueryTexturePixels(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
36 SDL_Texture * texture, void **pixels,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
37 int *pitch);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
38 static int GDI_SetTexturePalette(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
39 SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
40 const SDL_Color * colors, int firstcolor,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
41 int ncolors);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
42 static int GDI_GetTexturePalette(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
43 SDL_Texture * texture, SDL_Color * colors,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
44 int firstcolor, int ncolors);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
45 static int GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
46 const SDL_Rect * rect, const void *pixels,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
47 int pitch);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
48 static int GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
49 const SDL_Rect * rect, int markDirty,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
50 void **pixels, int *pitch);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
51 static void GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
52 static void GDI_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
53 int numrects, const SDL_Rect * rects);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
54 static int GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
55 Uint32 color);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
56 static int GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
57 const SDL_Rect * srcrect, const SDL_Rect * dstrect,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
58 int blendMode, int scaleMode);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
59 static void GDI_RenderPresent(SDL_Renderer * renderer);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
60 static void GDI_DestroyTexture(SDL_Renderer * renderer,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
61 SDL_Texture * texture);
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
62 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
63
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
65 SDL_RenderDriver GDI_RenderDriver = {
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
66 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
67 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 "gdi",
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
69 (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
70 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
71 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED),
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
72 (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
73 SDL_TEXTUREBLENDMODE_BLEND),
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
74 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST),
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 11,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
77 SDL_PIXELFORMAT_INDEX8,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
78 SDL_PIXELFORMAT_RGB555,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
79 SDL_PIXELFORMAT_RGB565,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
80 SDL_PIXELFORMAT_RGB888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
81 SDL_PIXELFORMAT_BGR888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
82 SDL_PIXELFORMAT_ARGB8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
83 SDL_PIXELFORMAT_RGBA8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
84 SDL_PIXELFORMAT_ABGR8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
85 SDL_PIXELFORMAT_BGRA8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
86 SDL_PIXELFORMAT_YUY2,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
87 SDL_PIXELFORMAT_UYVY},
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 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
89 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
90 };
c121d94672cb 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
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 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
93 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 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
95 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
96 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
97 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
98 HDC current_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
99 LPBITMAPINFO bmi;
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
100 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
101 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
102 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
103 SDL_bool makedirty;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
104 } 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
105
c121d94672cb 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 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
107 {
c121d94672cb 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 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
109 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
110 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
111 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
112 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
113 int pitch;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
114 } 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
115
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 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
117 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
118 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
119 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
120 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
121
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 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
123 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
124 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
125 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
126 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
127 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
128 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 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
131 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
132 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
133 SDL_AddRenderDriver(0, &GDI_RenderDriver);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135
c121d94672cb 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 SDL_Renderer *
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
137 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
138 {
c121d94672cb 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 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
140 SDL_Renderer *renderer;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
141 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
142 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
143 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
144 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
145
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
146 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
147 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
148 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
149 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
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
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
152 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
153 if (!data) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
154 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
155 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
156 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
157 }
c121d94672cb 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
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
159 renderer->DisplayModeChanged = GDI_DisplayModeChanged;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
160 renderer->CreateTexture = GDI_CreateTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
161 renderer->QueryTexturePixels = GDI_QueryTexturePixels;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
162 renderer->SetTexturePalette = GDI_SetTexturePalette;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
163 renderer->GetTexturePalette = GDI_GetTexturePalette;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
164 renderer->UpdateTexture = GDI_UpdateTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
165 renderer->LockTexture = GDI_LockTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
166 renderer->UnlockTexture = GDI_UnlockTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
167 renderer->DirtyTexture = GDI_DirtyTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
168 renderer->RenderFill = GDI_RenderFill;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
169 renderer->RenderCopy = GDI_RenderCopy;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
170 renderer->RenderPresent = GDI_RenderPresent;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
171 renderer->DestroyTexture = GDI_DestroyTexture;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
172 renderer->DestroyRenderer = GDI_DestroyRenderer;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
173 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
174 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
175 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
176
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
177 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
178
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
179 data->hwnd = windowdata->hwnd;
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
180 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
181 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
182 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
183
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
184 /* 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
185 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
186 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
187 if (!data->bmi) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
188 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
189 SDL_OutOfMemory();
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
190 return NULL;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
191 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
192 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
193
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
194 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
195 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
196 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
197 DeleteObject(hbm);
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
198
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
199 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
200 renderer->info.flags |=
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
201 (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
202 n = 0;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
203 } else if (flags & SDL_RENDERER_PRESENTFLIP2) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
204 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
205 n = 2;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
206 } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
207 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
208 n = 3;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
209 } else {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
210 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
211 n = 1;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
212 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
213 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
214 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
215 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
216 if (!data->hbm[i]) {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
217 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
218 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
219 return NULL;
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
220 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
221 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
222 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
223 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
224 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
225 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
226 } else {
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
227 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
228 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
229 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
230 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
231
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 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
233 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 static int
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
236 GDI_DisplayModeChanged(SDL_Renderer * renderer)
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
237 {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
238 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
239 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
240 int i, n;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
241
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
242 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
243 n = 0;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
244 } 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
245 n = 2;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
246 } 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
247 n = 3;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
248 } else {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
249 n = 1;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
250 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
251 for (i = 0; i < n; ++i) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
252 if (data->hbm[i]) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
253 DeleteObject(data->hbm[i]);
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
254 data->hbm[i] = NULL;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
255 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
256 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
257 for (i = 0; i < n; ++i) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
258 data->hbm[i] =
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
259 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
260 if (!data->hbm[i]) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
261 WIN_SetError("CreateCompatibleBitmap()");
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
262 return -1;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
263 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
264 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
265 if (n > 0) {
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
266 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
267 }
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
268 return 0;
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
269 }
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 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
272 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
273 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
274 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
275 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
276 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
277 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
278
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
279 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
280 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
281 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
282 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
283 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 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
286
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 if (SDL_ISPIXELFORMAT_FOURCC(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
288 data->yuv = SDL_SW_CreateYUVTexture(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
289 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
290 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
291 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 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
293 } 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
294 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
295 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 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
297
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
298 if (data->yuv || texture->access == SDL_TEXTUREACCESS_LOCAL
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
299 || texture->format != display->current_mode.format) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 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
301 LPBITMAPINFO 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
302
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 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
304 bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 if (!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
306 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
307 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
308 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 bmi->bmiHeader.biWidth = 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
311 bmi->bmiHeader.biHeight = -texture->h; /* topdown 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
312 bmi->bmiHeader.biPlanes = 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
313 bmi->bmiHeader.biSizeImage = texture->h * 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
314 bmi->bmiHeader.biXPelsPerMeter = 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
315 bmi->bmiHeader.biYPelsPerMeter = 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
316 bmi->bmiHeader.biClrUsed = 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
317 bmi->bmiHeader.biClrImportant = 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
318 bmi->bmiHeader.biBitCount = SDL_BYTESPERPIXEL(data->format) * 8;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 if (SDL_ISPIXELFORMAT_INDEXED(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
320 int i, ncolors;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 LOGPALETTE *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
322
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 bmi->bmiHeader.biCompression = BI_RGB;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 ncolors = (1 << SDL_BITSPERPIXEL(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
325 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
326 (LOGPALETTE *) SDL_malloc(sizeof(*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
327 ncolors * sizeof(PALETTEENTRY));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 if (!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
329 SDL_free(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
330 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
331 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
332 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 palette->palVersion = 0x300;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 palette->palNumEntries = ncolors;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 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
336 palette->palPalEntry[i].peRed = 0xFF;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 palette->palPalEntry[i].peGreen = 0xFF;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 palette->palPalEntry[i].peBlue = 0xFF;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 palette->palPalEntry[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
340 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 data->hpal = CreatePalette(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
342 SDL_free(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
343 } 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
344 int bpp;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 Uint32 Rmask, Gmask, Bmask, Amask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 bmi->bmiHeader.biCompression = BI_BITFIELDS;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 SDL_PixelFormatEnumToMasks(data->format, &bpp, &Rmask, &Gmask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 &Bmask, &Amask);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 ((Uint32 *) bmi->bmiColors)[0] = Rmask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 ((Uint32 *) bmi->bmiColors)[1] = Gmask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 ((Uint32 *) bmi->bmiColors)[2] = Bmask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 data->hpal = 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
354 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
355 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
356 CreateDIBSection(renderdata->memory_hdc, 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
357 &data->pixels, NULL, 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
358 } 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
359 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
360 CreateCompatibleBitmap(renderdata->window_hdc, 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
361 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
362 data->pixels = 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
363 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 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
365 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
366 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
367 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 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
369 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
372 GDI_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
373 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
374 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
375 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
376
c121d94672cb 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 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
378 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
379 } 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
380 *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
381 *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
382 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
383 }
c121d94672cb 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 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
387 GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
388 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
389 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
390 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
391 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
392
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 if (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
394 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
395 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
396 } 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
397 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
398 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
399
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 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
401 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
402 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
403 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
404 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
405 }
c121d94672cb 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 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
407 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
408 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
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 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
411 }
c121d94672cb 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 }
c121d94672cb 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 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
415 GDI_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
416 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
417 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
418 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
419
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 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
421 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
422 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
423 } 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
424 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
425 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
426
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 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
428 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
429 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 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
432 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
433 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
434 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
435 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436 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
437 }
c121d94672cb 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
c121d94672cb 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 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
441 GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
442 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
443 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
444 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
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 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
447 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
448 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
449 }
c121d94672cb 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 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
451 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
452 } else {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
453 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
454
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 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
456 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
457 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
458 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
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 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
461 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
462 (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
463 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
464 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
465 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
466 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
467 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
468 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
469 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470 } else if (rect->w == texture->w && 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
471 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
472 (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
473 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
474 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
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 } 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
478 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
479 ("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
480 return -1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 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
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
487 GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
488 const SDL_Rect * rect, int markDirty, void **pixels,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
489 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
490 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
491 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
492
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 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
494 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
495 pitch);
1898
f89e49e51e89 Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents: 1897
diff changeset
496 } else if (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
497 GdiFlush();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498 *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
499 (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
500 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
501 *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
502 return 0;
1898
f89e49e51e89 Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents: 1897
diff changeset
503 } else {
f89e49e51e89 Playing around, trying to find a fast path with GDI
Sam Lantinga <slouken@libsdl.org>
parents: 1897
diff changeset
504 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
505 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
506 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
508
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
510 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
511 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
512 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
513
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514 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
515 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
516 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
517 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
521 GDI_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
522 const SDL_Rect * rects)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
525
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
526 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
527 GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 color)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
529 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
530 Uint8 r, g, 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
531 RECT rc;
1899
6a11e61bf805 debug cleanup
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
532 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
533 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
534
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
535 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
536 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
537 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
538
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 r = (Uint8) ((color >> 16) & 0xFF);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 g = (Uint8) ((color >> 8) & 0xFF);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 b = (Uint8) (color & 0xFF);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
543 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
544 rc.top = rect->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
545 rc.right = rect->x + rect->w + 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
546 rc.bottom = rect->y + rect->h + 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
547
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548 /* Should we cache the brushes? .. it looks like GDI does for us. :) */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549 brush = CreateSolidBrush(RGB(r, g, 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
550 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
551 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
552 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
553
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 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
555 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
556 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
557 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 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
559 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
561 static int
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
562 GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
563 const SDL_Rect * srcrect, const SDL_Rect * dstrect,
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
564 int blendMode, int scaleMode)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
566 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
567 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
568
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
569 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
570 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
571 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
572
1895
c121d94672cb 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 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
574 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
575 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
576 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
577 }
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
578 if (blendMode & (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND)) {
1895
c121d94672cb 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 static BLENDFUNCTION 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
580 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
581 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
582 255,
c121d94672cb 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 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
584 };
c121d94672cb 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 /* FIXME: GDI uses premultiplied 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
586 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
587 (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
588 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
589 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
590 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
591 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
592 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593 } 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
594 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
595 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
596 (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
597 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
598 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
599 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
600 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
601 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
602 } 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
603 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
604 (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
605 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
606 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
607 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
608 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
609 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
610 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
611 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
612 return 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
614
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
616 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
617 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
618 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
619 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
620
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
621 /* Send the data to the display */
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
622 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
623 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
624 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
625 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
626 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
627 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
628 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
629 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
630
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
631 /* Update the flipping chain, if any */
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1924
diff changeset
632 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
633 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
634 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
635 } 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
636 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
637 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
638 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
639 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
640
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
641 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
642 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
643 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
644 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
645
c121d94672cb 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 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
647 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
648 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
649 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
650 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
651 }
c121d94672cb 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 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
653 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
654 }
c121d94672cb 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 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
656 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
657 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
658 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
659 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
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
1975
ccef0d0c40c6 Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
662 static void
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
663 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
664 {
1913
83420da906a5 Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
665 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
666 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
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) {
c121d94672cb 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 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
670 DeleteDC(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
671 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
672 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
673 }
1897
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
674 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
675 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
676 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
677 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
678 }
c2a27da60b18 Solved the performance problems by introducing the concept of a single-buffered
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
679 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
680 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
681 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
682 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
683 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
685 #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
686
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
687 /* vi: set ts=4 sw=4 expandtab: */