remove the explicit use of the DirectDraw interface by using the c++ API
SVN revision: 34148
This commit is contained in:
parent
7ec35857f1
commit
6b9fb388a4
|
@ -86,7 +86,7 @@ endif
|
||||||
|
|
||||||
if BUILD_SOFTWARE_DDRAW
|
if BUILD_SOFTWARE_DDRAW
|
||||||
expedite_SOURCES += \
|
expedite_SOURCES += \
|
||||||
engine_software_ddraw.c engine_software_ddraw.h
|
engine_software_ddraw.cpp engine_software_ddraw.h
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if BUILD_SOFTWARE_16_DDRAW
|
if BUILD_SOFTWARE_16_DDRAW
|
||||||
|
|
|
@ -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_DDraw.h>
|
#include <Evas_Engine_Software_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,
|
||||||
|
@ -15,38 +16,38 @@ _directdraw_init (HWND window,
|
||||||
LPDIRECTDRAW *object,
|
LPDIRECTDRAW *object,
|
||||||
LPDIRECTDRAWSURFACE *surface_primary,
|
LPDIRECTDRAWSURFACE *surface_primary,
|
||||||
LPDIRECTDRAWSURFACE *surface_back,
|
LPDIRECTDRAWSURFACE *surface_back,
|
||||||
|
LPDIRECTDRAWCLIPPER *clipper,
|
||||||
int *depth)
|
int *depth)
|
||||||
{
|
{
|
||||||
DDSURFACEDESC2 surface_desc;
|
DDSURFACEDESC surface_desc;
|
||||||
DDPIXELFORMAT pixel_format;
|
DDPIXELFORMAT pixel_format;
|
||||||
LPDIRECTDRAWCLIPPER clipper;
|
|
||||||
LPDIRECTDRAW o;
|
LPDIRECTDRAW o;
|
||||||
DDSURFACEDESC2 *sd;
|
DDSURFACEDESC *sd;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = IDirectDraw7_CreateClipper (o, 0, &clipper, NULL);
|
res = o->CreateClipper (0, clipper, NULL);
|
||||||
if (FAILED(res))
|
if (FAILED(res))
|
||||||
{
|
{
|
||||||
IDirectDraw7_Release (o);
|
o->Release ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = IDirectDrawClipper_SetHWnd (clipper, 0, window);
|
res = (*clipper)->SetHWnd (0, window);
|
||||||
if (FAILED(res))
|
if (FAILED(res))
|
||||||
{
|
{
|
||||||
IDirectDrawClipper_Release (clipper);
|
(*clipper)->Release ();
|
||||||
IDirectDraw7_Release (o);
|
o->Release ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,22 +56,20 @@ _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))
|
||||||
{
|
{
|
||||||
IDirectDrawClipper_Release (clipper);
|
(*clipper)->Release ();
|
||||||
IDirectDraw7_Release (o);
|
o->Release ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = IDirectDrawSurface7_SetClipper (*surface_primary, clipper);
|
res = (*surface_primary)->SetClipper (*clipper);
|
||||||
if (FAILED(res))
|
if (FAILED(res))
|
||||||
{
|
{
|
||||||
IDirectDrawClipper_Release (clipper);
|
(*surface_primary)->Release ();
|
||||||
IDirectDrawSurface7_Release (*surface_primary);
|
(*clipper)->Release ();
|
||||||
IDirectDraw7_Release (o);
|
o->Release ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,20 +80,18 @@ _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))
|
||||||
{
|
{
|
||||||
IDirectDrawClipper_Release (clipper);
|
(*surface_primary)->Release ();
|
||||||
IDirectDrawSurface7_Release (*surface_primary);
|
(*clipper)->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;
|
*object = o;
|
||||||
*depth = pixel_format.dwRGBBitCount;
|
*depth = pixel_format.dwRGBBitCount;
|
||||||
|
@ -269,7 +266,10 @@ engine_software_ddraw_args(int argc, char **argv)
|
||||||
LPDIRECTDRAW object;
|
LPDIRECTDRAW object;
|
||||||
LPDIRECTDRAWSURFACE surface_primary;
|
LPDIRECTDRAWSURFACE surface_primary;
|
||||||
LPDIRECTDRAWSURFACE surface_back;
|
LPDIRECTDRAWSURFACE surface_back;
|
||||||
|
LPDIRECTDRAWCLIPPER clipper;
|
||||||
Evas_Engine_Info_Software_DDraw *einfo;
|
Evas_Engine_Info_Software_DDraw *einfo;
|
||||||
|
DWORD style;
|
||||||
|
DWORD exstyle;
|
||||||
int depth;
|
int depth;
|
||||||
int i;
|
int i;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
|
@ -286,41 +286,52 @@ engine_software_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;
|
||||||
wc.hInstance = hinstance;
|
wc.hInstance = hinstance;
|
||||||
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
|
wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
|
||||||
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
|
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
|
wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
|
||||||
wc.lpszMenuName = NULL;
|
wc.lpszMenuName = NULL;
|
||||||
wc.lpszClassName = "Evas_Software_DDraw_Test";
|
wc.lpszClassName = "Evas_Software_DDraw_Test";
|
||||||
|
|
||||||
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,
|
fprintf (stderr, " * 1 %d %d\n",
|
||||||
|
(int)(rect.right - rect.left), (int)(rect.bottom - rect.top));
|
||||||
|
|
||||||
|
window = CreateWindowEx(exstyle,
|
||||||
"Evas_Software_DDraw_Test",
|
"Evas_Software_DDraw_Test",
|
||||||
"Evas_Software_DDraw_Test",
|
"Evas_Software_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);
|
||||||
if (!window) return EXIT_FAILURE;
|
if (!window) return EXIT_FAILURE;
|
||||||
|
|
||||||
|
fprintf (stderr, " * 2\n");
|
||||||
|
|
||||||
if (!_directdraw_init(window, win_w, win_h,
|
if (!_directdraw_init(window, win_w, win_h,
|
||||||
&object,
|
&object,
|
||||||
&surface_primary,
|
&surface_primary,
|
||||||
&surface_back,
|
&surface_back,
|
||||||
|
&clipper,
|
||||||
&depth))
|
&depth))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
fprintf (stderr, " * 3\n");
|
||||||
|
|
||||||
evas_output_method_set(evas, evas_render_method_lookup("software_ddraw"));
|
evas_output_method_set(evas, evas_render_method_lookup("software_ddraw"));
|
||||||
einfo = (Evas_Engine_Info_Software_DDraw *)evas_engine_info_get(evas);
|
einfo = (Evas_Engine_Info_Software_DDraw *)evas_engine_info_get(evas);
|
||||||
if (!einfo)
|
if (!einfo)
|
||||||
|
@ -360,3 +371,6 @@ engine_software_ddraw_loop(void)
|
||||||
|
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -2,8 +2,18 @@
|
||||||
#define __ENGINE_SOFTWARE_DDRAW_H__
|
#define __ENGINE_SOFTWARE_DDRAW_H__
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int engine_software_ddraw_args(int argc, char **argv);
|
int engine_software_ddraw_args(int argc, char **argv);
|
||||||
void engine_software_ddraw_loop(void);
|
void engine_software_ddraw_loop(void);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* __ENGINE_SOFTWARE_DDRAW_H__ */
|
#endif /* __ENGINE_SOFTWARE_DDRAW_H__ */
|
||||||
|
|
Loading…
Reference in New Issue