summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/Makefile.am4
-rw-r--r--src/bin/engine_software_16_ddraw.cpp (renamed from src/bin/engine_software_16_ddraw.c)81
-rw-r--r--src/bin/engine_software_16_ddraw.h10
3 files changed, 50 insertions, 45 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index c5eed08..69cb54c 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -57,7 +57,7 @@ image_blend_occlude2_very_many.c \
57image_blend_occlude3_very_many.c \ 57image_blend_occlude3_very_many.c \
58poly_blend.c 58poly_blend.c
59 59
60expedite_LDFLAGS = @EVAS_LIBS@ @SDL_LIBS@ @x_libs@ @ddraw_libs@ @ddraw_16_libs@ @d3d_libs@ @glew_libs@ @DIRECTFB_LIBS@ -lm 60expedite_LDADD = @EVAS_LIBS@ @SDL_LIBS@ @x_libs@ @ddraw_libs@ @ddraw_16_libs@ @d3d_libs@ @glew_libs@ @DIRECTFB_LIBS@ -lm
61 61
62if BUILD_SOFTWARE_X11 62if BUILD_SOFTWARE_X11
63expedite_SOURCES += \ 63expedite_SOURCES += \
@@ -91,7 +91,7 @@ endif
91 91
92if BUILD_SOFTWARE_16_DDRAW 92if BUILD_SOFTWARE_16_DDRAW
93expedite_SOURCES += \ 93expedite_SOURCES += \
94engine_software_16_ddraw.c engine_software_16_ddraw.h 94engine_software_16_ddraw.cpp engine_software_16_ddraw.h
95endif 95endif
96 96
97if BUILD_DIRECT3D 97if BUILD_DIRECT3D
diff --git a/src/bin/engine_software_16_ddraw.c b/src/bin/engine_software_16_ddraw.cpp
index 2c0153f..0c11eec 100644
--- a/src/bin/engine_software_16_ddraw.c
+++ b/src/bin/engine_software_16_ddraw.cpp
@@ -1,13 +1,14 @@
1#include "main.h" 1#include "main.h"
2 2
3#include <windows.h>
4#include <windowsx.h> 3#include <windowsx.h>
5#include <ddraw.h>
6#include <Evas_Engine_Software_16_DDraw.h> 4#include <Evas_Engine_Software_16_DDraw.h>
7 5
8 6
9static HWND window; 7static HWND window;
10 8
9
10extern "C" {
11
11static int 12static int
12_directdraw_init (HWND window, 13_directdraw_init (HWND window,
13 int width, 14 int width,
@@ -18,21 +19,20 @@ _directdraw_init (HWND window,
18 LPDIRECTDRAWSURFACE *surface_source, 19 LPDIRECTDRAWSURFACE *surface_source,
19 int *depth) 20 int *depth)
20{ 21{
21 DDSURFACEDESC2 surface_desc; 22 DDSURFACEDESC surface_desc;
22 DDPIXELFORMAT pixel_format; 23 DDPIXELFORMAT pixel_format;
23 LPDIRECTDRAW o; 24 LPDIRECTDRAW o;
24 DDSURFACEDESC2 *sd; 25 void *source;
25 void *source; 26 HRESULT res;
26 HRESULT res; 27
27 28 res = DirectDrawCreate (NULL, &o, NULL);
28 res = DirectDrawCreateEx (NULL, (void **)&o, &IID_IDirectDraw7, NULL);
29 if (FAILED(res)) 29 if (FAILED(res))
30 return 0; 30 return 0;
31 31
32 res = IDirectDraw7_SetCooperativeLevel (o, window, DDSCL_NORMAL); 32 res = o->SetCooperativeLevel (window, DDSCL_NORMAL);
33 if (FAILED(res)) 33 if (FAILED(res))
34 { 34 {
35 IDirectDraw7_Release (o); 35 o->Release ();
36 return 0; 36 return 0;
37 } 37 }
38 38
@@ -41,12 +41,10 @@ _directdraw_init (HWND window,
41 surface_desc.dwFlags = DDSD_CAPS; 41 surface_desc.dwFlags = DDSD_CAPS;
42 surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; 42 surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
43 43
44 sd=&surface_desc; 44 res = o->CreateSurface (&surface_desc, surface_primary, NULL);
45 res = IDirectDraw7_CreateSurface (o, (DDSURFACEDESC *)sd,
46 surface_primary, NULL);
47 if (FAILED(res)) 45 if (FAILED(res))
48 { 46 {
49 IDirectDraw7_Release (o); 47 o->Release ();
50 return 0; 48 return 0;
51 } 49 }
52 50
@@ -57,28 +55,23 @@ _directdraw_init (HWND window,
57 surface_desc.dwWidth = width; 55 surface_desc.dwWidth = width;
58 surface_desc.dwHeight = height; 56 surface_desc.dwHeight = height;
59 57
60 sd=&surface_desc; 58 res = o->CreateSurface (&surface_desc, surface_back, NULL);
61 res = IDirectDraw7_CreateSurface (o, (DDSURFACEDESC *)sd,
62 surface_back, NULL);
63 if (FAILED(res)) 59 if (FAILED(res))
64 { 60 {
65 IDirectDrawSurface7_Release (*surface_primary); 61 (*surface_primary)->Release ();
66 IDirectDraw7_Release (o); 62 o->Release ();
67 return 0; 63 return 0;
68 } 64 }
69 65
70 ZeroMemory(&pixel_format, sizeof(pixel_format)); 66 ZeroMemory(&pixel_format, sizeof(pixel_format));
71 pixel_format.dwSize = sizeof(pixel_format); 67 pixel_format.dwSize = sizeof(pixel_format);
72 IDirectDrawSurface7_GetPixelFormat(*surface_primary, &pixel_format); 68 (*surface_primary)->GetPixelFormat(&pixel_format);
73
74 *object = o;
75 *depth = pixel_format.dwRGBBitCount;
76 69
77 source = malloc(width * height * 2); 70 source = malloc(width * height * 2);
78 if (!source) 71 if (!source)
79 { 72 {
80 IDirectDrawSurface7_Release (*surface_primary); 73 (*surface_primary)->Release ();
81 IDirectDraw7_Release (o); 74 o->Release ();
82 return 0; 75 return 0;
83 } 76 }
84 77
@@ -92,22 +85,19 @@ _directdraw_init (HWND window,
92 surface_desc.dwHeight = height; 85 surface_desc.dwHeight = height;
93 surface_desc.lPitch = 2 * surface_desc.dwWidth; 86 surface_desc.lPitch = 2 * surface_desc.dwWidth;
94 surface_desc.lpSurface = source; 87 surface_desc.lpSurface = source;
95
96 surface_desc.ddpfPixelFormat = pixel_format; 88 surface_desc.ddpfPixelFormat = pixel_format;
97 89
98 /* Hack to cleanly remove a warning */ 90 if (FAILED(o->CreateSurface(&surface_desc, surface_source, NULL)))
99 sd = &surface_desc;
100 if (FAILED(IDirectDraw7_CreateSurface(*object,
101 (DDSURFACEDESC *)sd,
102 surface_source,
103 NULL)))
104 { 91 {
105 free(source); 92 free(source);
106 IDirectDrawSurface7_Release (*surface_primary); 93 (*surface_primary)->Release ();
107 IDirectDraw7_Release (o); 94 o->Release ();
108 return 0; 95 return 0;
109 } 96 }
110 97
98 *object = o;
99 *depth = pixel_format.dwRGBBitCount;
100
111 return 1; 101 return 1;
112} 102}
113 103
@@ -280,6 +270,8 @@ engine_software_16_ddraw_args(int argc, char **argv)
280 LPDIRECTDRAWSURFACE surface_back; 270 LPDIRECTDRAWSURFACE surface_back;
281 LPDIRECTDRAWSURFACE surface_source; 271 LPDIRECTDRAWSURFACE surface_source;
282 Evas_Engine_Info_Software_16_DDraw *einfo; 272 Evas_Engine_Info_Software_16_DDraw *einfo;
273 DWORD style;
274 DWORD exstyle;
283 int depth; 275 int depth;
284 int i; 276 int i;
285 int ok = 0; 277 int ok = 0;
@@ -296,7 +288,7 @@ engine_software_16_ddraw_args(int argc, char **argv)
296 288
297 hinstance = GetModuleHandle(0); 289 hinstance = GetModuleHandle(0);
298 290
299 wc.style = 0; 291 wc.style = CS_HREDRAW | CS_VREDRAW;
300 wc.lpfnWndProc = MainWndProc; 292 wc.lpfnWndProc = MainWndProc;
301 wc.cbClsExtra = 0; 293 wc.cbClsExtra = 0;
302 wc.cbWndExtra = 0; 294 wc.cbWndExtra = 0;
@@ -309,16 +301,19 @@ engine_software_16_ddraw_args(int argc, char **argv)
309 301
310 if(!RegisterClass(&wc)) return EXIT_FAILURE; 302 if(!RegisterClass(&wc)) return EXIT_FAILURE;
311 303
304 style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX;
305 exstyle = 0;
306
312 rect.left = 0; 307 rect.left = 0;
313 rect.top = 0; 308 rect.top = 0;
314 rect.right = win_w; 309 rect.right = win_w;
315 rect.bottom = win_h; 310 rect.bottom = win_h;
316 AdjustWindowRect (&rect, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, FALSE); 311 AdjustWindowRectEx(&rect, style, FALSE, exstyle);
317 312
318 window = CreateWindowEx(0, 313 window = CreateWindowEx(exstyle,
319 "Evas_Software_16_DDraw_Test", 314 "Evas_Software_16_DDraw_Test",
320 "Evas_Software_16_DDraw_Test", 315 "Evas_Software_16_DDraw_Test",
321 WS_OVERLAPPEDWINDOW | WS_SIZEBOX, 316 style,
322 CW_USEDEFAULT, CW_USEDEFAULT, 317 CW_USEDEFAULT, CW_USEDEFAULT,
323 rect.right - rect.left, rect.bottom - rect.top, 318 rect.right - rect.left, rect.bottom - rect.top,
324 NULL, NULL, hinstance, NULL); 319 NULL, NULL, hinstance, NULL);
@@ -330,14 +325,14 @@ engine_software_16_ddraw_args(int argc, char **argv)
330 &surface_back, 325 &surface_back,
331 &surface_source, 326 &surface_source,
332 &depth)) 327 &depth))
333 return 0; 328 return EXIT_FAILURE;
334 329
335 evas_output_method_set(evas, evas_render_method_lookup("software_16_ddraw")); 330 evas_output_method_set(evas, evas_render_method_lookup("software_16_ddraw"));
336 einfo = (Evas_Engine_Info_Software_16_DDraw *)evas_engine_info_get(evas); 331 einfo = (Evas_Engine_Info_Software_16_DDraw *)evas_engine_info_get(evas);
337 if (!einfo) 332 if (!einfo)
338 { 333 {
339 printf("Evas does not support the 16bit Software DirectDraw Engine\n"); 334 fprintf(stderr, "Evas does not support the 16 bits Software DirectDraw Engine\n");
340 return 0; 335 return EXIT_FAILURE;
341 } 336 }
342 337
343 einfo->info.window = window; 338 einfo->info.window = window;
diff --git a/src/bin/engine_software_16_ddraw.h b/src/bin/engine_software_16_ddraw.h
index 9e3db78..e733a29 100644
--- a/src/bin/engine_software_16_ddraw.h
+++ b/src/bin/engine_software_16_ddraw.h
@@ -2,8 +2,18 @@
2#define __ENGINE_SOFTWARE_16_DDRAW_H__ 2#define __ENGINE_SOFTWARE_16_DDRAW_H__
3 3
4 4
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9
5int engine_software_16_ddraw_args(int argc, char **argv); 10int engine_software_16_ddraw_args(int argc, char **argv);
6void engine_software_16_ddraw_loop(void); 11void engine_software_16_ddraw_loop(void);
7 12
8 13
14#ifdef __cplusplus
15}
16#endif
17
18
9#endif /* __ENGINE_SOFTWARE_16_DDRAW_H__ */ 19#endif /* __ENGINE_SOFTWARE_16_DDRAW_H__ */