remove the explicit use of the DirectDraw interface by using the c++ API
SVN revision: 34153
This commit is contained in:
parent
65f5d568ce
commit
7d1d8020a4
|
@ -57,7 +57,7 @@ image_blend_occlude2_very_many.c \
|
||||||
image_blend_occlude3_very_many.c \
|
image_blend_occlude3_very_many.c \
|
||||||
poly_blend.c
|
poly_blend.c
|
||||||
|
|
||||||
expedite_LDFLAGS = @EVAS_LIBS@ @SDL_LIBS@ @x_libs@ @ddraw_libs@ @ddraw_16_libs@ @d3d_libs@ @glew_libs@ @DIRECTFB_LIBS@ -lm
|
expedite_LDADD = @EVAS_LIBS@ @SDL_LIBS@ @x_libs@ @ddraw_libs@ @ddraw_16_libs@ @d3d_libs@ @glew_libs@ @DIRECTFB_LIBS@ -lm
|
||||||
|
|
||||||
if BUILD_SOFTWARE_X11
|
if BUILD_SOFTWARE_X11
|
||||||
expedite_SOURCES += \
|
expedite_SOURCES += \
|
||||||
|
@ -91,7 +91,7 @@ endif
|
||||||
|
|
||||||
if BUILD_SOFTWARE_16_DDRAW
|
if BUILD_SOFTWARE_16_DDRAW
|
||||||
expedite_SOURCES += \
|
expedite_SOURCES += \
|
||||||
engine_software_16_ddraw.c engine_software_16_ddraw.h
|
engine_software_16_ddraw.cpp engine_software_16_ddraw.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if BUILD_DIRECT3D
|
if BUILD_DIRECT3D
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#include <ddraw.h>
|
|
||||||
#include <Evas_Engine_Software_16_DDraw.h>
|
#include <Evas_Engine_Software_16_DDraw.h>
|
||||||
|
|
||||||
|
|
||||||
static HWND window;
|
static HWND window;
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_directdraw_init (HWND window,
|
_directdraw_init (HWND window,
|
||||||
int width,
|
int width,
|
||||||
|
@ -18,21 +19,20 @@ _directdraw_init (HWND window,
|
||||||
LPDIRECTDRAWSURFACE *surface_source,
|
LPDIRECTDRAWSURFACE *surface_source,
|
||||||
int *depth)
|
int *depth)
|
||||||
{
|
{
|
||||||
DDSURFACEDESC2 surface_desc;
|
DDSURFACEDESC surface_desc;
|
||||||
DDPIXELFORMAT pixel_format;
|
DDPIXELFORMAT pixel_format;
|
||||||
LPDIRECTDRAW o;
|
LPDIRECTDRAW o;
|
||||||
DDSURFACEDESC2 *sd;
|
void *source;
|
||||||
void *source;
|
HRESULT res;
|
||||||
HRESULT res;
|
|
||||||
|
|
||||||
res = DirectDrawCreateEx (NULL, (void **)&o, &IID_IDirectDraw7, NULL);
|
res = DirectDrawCreate (NULL, &o, NULL);
|
||||||
if (FAILED(res))
|
if (FAILED(res))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
res = IDirectDraw7_SetCooperativeLevel (o, window, DDSCL_NORMAL);
|
res = o->SetCooperativeLevel (window, DDSCL_NORMAL);
|
||||||
if (FAILED(res))
|
if (FAILED(res))
|
||||||
{
|
{
|
||||||
IDirectDraw7_Release (o);
|
o->Release ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,12 +41,10 @@ _directdraw_init (HWND window,
|
||||||
surface_desc.dwFlags = DDSD_CAPS;
|
surface_desc.dwFlags = DDSD_CAPS;
|
||||||
surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
surface_desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
||||||
|
|
||||||
sd=&surface_desc;
|
res = o->CreateSurface (&surface_desc, surface_primary, NULL);
|
||||||
res = IDirectDraw7_CreateSurface (o, (DDSURFACEDESC *)sd,
|
|
||||||
surface_primary, NULL);
|
|
||||||
if (FAILED(res))
|
if (FAILED(res))
|
||||||
{
|
{
|
||||||
IDirectDraw7_Release (o);
|
o->Release ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,28 +55,23 @@ _directdraw_init (HWND window,
|
||||||
surface_desc.dwWidth = width;
|
surface_desc.dwWidth = width;
|
||||||
surface_desc.dwHeight = height;
|
surface_desc.dwHeight = height;
|
||||||
|
|
||||||
sd=&surface_desc;
|
res = o->CreateSurface (&surface_desc, surface_back, NULL);
|
||||||
res = IDirectDraw7_CreateSurface (o, (DDSURFACEDESC *)sd,
|
|
||||||
surface_back, NULL);
|
|
||||||
if (FAILED(res))
|
if (FAILED(res))
|
||||||
{
|
{
|
||||||
IDirectDrawSurface7_Release (*surface_primary);
|
(*surface_primary)->Release ();
|
||||||
IDirectDraw7_Release (o);
|
o->Release ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMemory(&pixel_format, sizeof(pixel_format));
|
ZeroMemory(&pixel_format, sizeof(pixel_format));
|
||||||
pixel_format.dwSize = sizeof(pixel_format);
|
pixel_format.dwSize = sizeof(pixel_format);
|
||||||
IDirectDrawSurface7_GetPixelFormat(*surface_primary, &pixel_format);
|
(*surface_primary)->GetPixelFormat(&pixel_format);
|
||||||
|
|
||||||
*object = o;
|
|
||||||
*depth = pixel_format.dwRGBBitCount;
|
|
||||||
|
|
||||||
source = malloc(width * height * 2);
|
source = malloc(width * height * 2);
|
||||||
if (!source)
|
if (!source)
|
||||||
{
|
{
|
||||||
IDirectDrawSurface7_Release (*surface_primary);
|
(*surface_primary)->Release ();
|
||||||
IDirectDraw7_Release (o);
|
o->Release ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,22 +85,19 @@ _directdraw_init (HWND window,
|
||||||
surface_desc.dwHeight = height;
|
surface_desc.dwHeight = height;
|
||||||
surface_desc.lPitch = 2 * surface_desc.dwWidth;
|
surface_desc.lPitch = 2 * surface_desc.dwWidth;
|
||||||
surface_desc.lpSurface = source;
|
surface_desc.lpSurface = source;
|
||||||
|
|
||||||
surface_desc.ddpfPixelFormat = pixel_format;
|
surface_desc.ddpfPixelFormat = pixel_format;
|
||||||
|
|
||||||
/* Hack to cleanly remove a warning */
|
if (FAILED(o->CreateSurface(&surface_desc, surface_source, NULL)))
|
||||||
sd = &surface_desc;
|
|
||||||
if (FAILED(IDirectDraw7_CreateSurface(*object,
|
|
||||||
(DDSURFACEDESC *)sd,
|
|
||||||
surface_source,
|
|
||||||
NULL)))
|
|
||||||
{
|
{
|
||||||
free(source);
|
free(source);
|
||||||
IDirectDrawSurface7_Release (*surface_primary);
|
(*surface_primary)->Release ();
|
||||||
IDirectDraw7_Release (o);
|
o->Release ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*object = o;
|
||||||
|
*depth = pixel_format.dwRGBBitCount;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,6 +270,8 @@ engine_software_16_ddraw_args(int argc, char **argv)
|
||||||
LPDIRECTDRAWSURFACE surface_back;
|
LPDIRECTDRAWSURFACE surface_back;
|
||||||
LPDIRECTDRAWSURFACE surface_source;
|
LPDIRECTDRAWSURFACE surface_source;
|
||||||
Evas_Engine_Info_Software_16_DDraw *einfo;
|
Evas_Engine_Info_Software_16_DDraw *einfo;
|
||||||
|
DWORD style;
|
||||||
|
DWORD exstyle;
|
||||||
int depth;
|
int depth;
|
||||||
int i;
|
int i;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
|
@ -296,7 +288,7 @@ engine_software_16_ddraw_args(int argc, char **argv)
|
||||||
|
|
||||||
hinstance = GetModuleHandle(0);
|
hinstance = GetModuleHandle(0);
|
||||||
|
|
||||||
wc.style = 0;
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
wc.lpfnWndProc = MainWndProc;
|
wc.lpfnWndProc = MainWndProc;
|
||||||
wc.cbClsExtra = 0;
|
wc.cbClsExtra = 0;
|
||||||
wc.cbWndExtra = 0;
|
wc.cbWndExtra = 0;
|
||||||
|
@ -309,16 +301,19 @@ engine_software_16_ddraw_args(int argc, char **argv)
|
||||||
|
|
||||||
if(!RegisterClass(&wc)) return EXIT_FAILURE;
|
if(!RegisterClass(&wc)) return EXIT_FAILURE;
|
||||||
|
|
||||||
|
style = WS_OVERLAPPEDWINDOW | WS_SIZEBOX;
|
||||||
|
exstyle = 0;
|
||||||
|
|
||||||
rect.left = 0;
|
rect.left = 0;
|
||||||
rect.top = 0;
|
rect.top = 0;
|
||||||
rect.right = win_w;
|
rect.right = win_w;
|
||||||
rect.bottom = win_h;
|
rect.bottom = win_h;
|
||||||
AdjustWindowRect (&rect, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, FALSE);
|
AdjustWindowRectEx(&rect, style, FALSE, exstyle);
|
||||||
|
|
||||||
window = CreateWindowEx(0,
|
window = CreateWindowEx(exstyle,
|
||||||
"Evas_Software_16_DDraw_Test",
|
"Evas_Software_16_DDraw_Test",
|
||||||
"Evas_Software_16_DDraw_Test",
|
"Evas_Software_16_DDraw_Test",
|
||||||
WS_OVERLAPPEDWINDOW | WS_SIZEBOX,
|
style,
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
rect.right - rect.left, rect.bottom - rect.top,
|
rect.right - rect.left, rect.bottom - rect.top,
|
||||||
NULL, NULL, hinstance, NULL);
|
NULL, NULL, hinstance, NULL);
|
||||||
|
@ -330,14 +325,14 @@ engine_software_16_ddraw_args(int argc, char **argv)
|
||||||
&surface_back,
|
&surface_back,
|
||||||
&surface_source,
|
&surface_source,
|
||||||
&depth))
|
&depth))
|
||||||
return 0;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
evas_output_method_set(evas, evas_render_method_lookup("software_16_ddraw"));
|
evas_output_method_set(evas, evas_render_method_lookup("software_16_ddraw"));
|
||||||
einfo = (Evas_Engine_Info_Software_16_DDraw *)evas_engine_info_get(evas);
|
einfo = (Evas_Engine_Info_Software_16_DDraw *)evas_engine_info_get(evas);
|
||||||
if (!einfo)
|
if (!einfo)
|
||||||
{
|
{
|
||||||
printf("Evas does not support the 16bit Software DirectDraw Engine\n");
|
fprintf(stderr, "Evas does not support the 16 bits Software DirectDraw Engine\n");
|
||||||
return 0;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
einfo->info.window = window;
|
einfo->info.window = window;
|
|
@ -2,8 +2,18 @@
|
||||||
#define __ENGINE_SOFTWARE_16_DDRAW_H__
|
#define __ENGINE_SOFTWARE_16_DDRAW_H__
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int engine_software_16_ddraw_args(int argc, char **argv);
|
int engine_software_16_ddraw_args(int argc, char **argv);
|
||||||
void engine_software_16_ddraw_loop(void);
|
void engine_software_16_ddraw_loop(void);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* __ENGINE_SOFTWARE_16_DDRAW_H__ */
|
#endif /* __ENGINE_SOFTWARE_16_DDRAW_H__ */
|
||||||
|
|
Loading…
Reference in New Issue