mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 18:41:14 +00:00
Implement all D3DRM interfaces (#99)
* Implement (most) IDirect3DRMObject methods * Implement all interfaces --------- Co-authored-by: Anonymous Maarten <anonymous.maarten@gmail.com>
This commit is contained in:
parent
b1dfbe9925
commit
543edf292a
@ -24,8 +24,6 @@
|
||||
|
||||
#define FAILED(hr) (((HRESULT) (hr)) < 0)
|
||||
#define InterlockedIncrement(x) __sync_add_and_fetch(x, 1)
|
||||
#define INVALID_HANDLE ((HANDLE) -1)
|
||||
#define INVALID_HANDLE_VALUE ((HANDLE) -1)
|
||||
#define HKEY_LOCAL_MACHINE ((HKEY) 0x80000002)
|
||||
#define LOWORD(l) ((WORD) (((DWORD_PTR) (l)) & 0xffff))
|
||||
#define MAKEINTRESOURCE(i) (reinterpret_cast<LPCTSTR>((ULONG_PTR) ((WORD) (i))))
|
||||
@ -130,7 +128,7 @@ struct CMenu {
|
||||
|
||||
struct CWinApp {
|
||||
CWinApp();
|
||||
virtual ~CWinApp() = default;
|
||||
~CWinApp() = default;
|
||||
virtual BOOL InitInstance() = 0;
|
||||
virtual int ExitInstance();
|
||||
};
|
||||
|
||||
@ -143,7 +143,7 @@ struct IUnknown {
|
||||
virtual HRESULT QueryInterface(const GUID& riid, void** ppvObject);
|
||||
virtual ~IUnknown() = default;
|
||||
|
||||
private:
|
||||
protected:
|
||||
int m_refCount;
|
||||
};
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#define D3DRM_OK DD_OK
|
||||
#define MAXSHORT ((short) 0x7fff)
|
||||
#define SUCCEEDED(hr) ((hr) >= D3DRM_OK)
|
||||
#define D3DRMERR_NOTFOUND MAKE_DDHRESULT(785)
|
||||
|
||||
// --- Typedefs ---
|
||||
typedef float D3DVAL;
|
||||
@ -16,6 +17,9 @@ typedef unsigned long D3DRMGROUPINDEX;
|
||||
typedef DWORD D3DCOLOR, *LPD3DCOLOR;
|
||||
typedef float D3DVALUE, *LPD3DVALUE;
|
||||
|
||||
typedef struct IDirect3DRMObject* LPDIRECT3DRMOBJECT;
|
||||
typedef void (*D3DRMOBJECTCALLBACK)(LPDIRECT3DRMOBJECT obj, LPVOID arg);
|
||||
|
||||
// --- Enums ---
|
||||
#define D3DRMCOMBINE_REPLACE D3DRMCOMBINETYPE::REPLACE
|
||||
enum class D3DRMCOMBINETYPE {
|
||||
@ -140,35 +144,31 @@ struct D3DRMVERTEX {
|
||||
float tu, tv;
|
||||
};
|
||||
|
||||
struct IDirect3DRMVisual : virtual public IUnknown {};
|
||||
typedef IDirect3DRMVisual* LPDIRECT3DRMVISUAL;
|
||||
|
||||
struct IDirect3DRMObject : virtual public IUnknown {
|
||||
struct IDirect3DRMObject : public IUnknown {
|
||||
virtual HRESULT Clone(void** ppObject) = 0;
|
||||
virtual HRESULT AddDestroyCallback(void (*cb)(IDirect3DRMObject*, void*), void* arg) = 0;
|
||||
virtual HRESULT DeleteDestroyCallback(void (*cb)(IDirect3DRMObject*, void*), void* arg) = 0;
|
||||
virtual HRESULT AddDestroyCallback(D3DRMOBJECTCALLBACK callback, void* arg) = 0;
|
||||
virtual HRESULT DeleteDestroyCallback(D3DRMOBJECTCALLBACK callback, void* arg) = 0;
|
||||
virtual HRESULT SetAppData(LPD3DRM_APPDATA appData) = 0;
|
||||
virtual LPVOID GetAppData() = 0;
|
||||
virtual HRESULT SetName(const char* name) = 0;
|
||||
virtual HRESULT GetName(DWORD* size, char* name) = 0;
|
||||
virtual HRESULT GetClassName(DWORD* size, char* name) = 0;
|
||||
};
|
||||
struct IDirect3DRMTexture : virtual public IUnknown {
|
||||
virtual HRESULT AddDestroyCallback(void (*cb)(IDirect3DRMObject*, void*), void* arg) = 0;
|
||||
virtual LPVOID GetAppData() = 0;
|
||||
virtual HRESULT SetAppData(LPD3DRM_APPDATA appData) = 0;
|
||||
virtual HRESULT SetTexture(const IDirect3DRMTexture* texture) = 0;
|
||||
virtual HRESULT Changed(BOOL arg1, BOOL arg2) = 0;
|
||||
|
||||
struct IDirect3DRMVisual : public IDirect3DRMObject {};
|
||||
typedef IDirect3DRMVisual* LPDIRECT3DRMVISUAL;
|
||||
|
||||
struct IDirect3DRMTexture : public IDirect3DRMVisual {
|
||||
virtual HRESULT Changed(BOOL pixels, BOOL palette) = 0;
|
||||
};
|
||||
typedef IDirect3DRMTexture* LPDIRECT3DRMTEXTURE;
|
||||
|
||||
struct IDirect3DRMTexture2 : public IDirect3DRMTexture {};
|
||||
typedef IDirect3DRMTexture2* LPDIRECT3DRMTEXTURE2;
|
||||
|
||||
struct IDirect3DRMMaterial : virtual public IUnknown {};
|
||||
struct IDirect3DRMMaterial : public IDirect3DRMObject {};
|
||||
typedef IDirect3DRMMaterial *LPDIRECT3DRMMATERIAL, **LPLPDIRECT3DRMMATERIAL;
|
||||
|
||||
struct IDirect3DRMMesh : virtual public IUnknown {
|
||||
struct IDirect3DRMMesh : public IDirect3DRMVisual {
|
||||
virtual HRESULT Clone(int flags, GUID iid, void** object) = 0;
|
||||
virtual HRESULT GetBox(D3DRMBOX* box) = 0;
|
||||
virtual HRESULT AddGroup(
|
||||
@ -188,7 +188,7 @@ struct IDirect3DRMMesh : virtual public IUnknown {
|
||||
) = 0;
|
||||
virtual HRESULT SetGroupColor(int groupIndex, D3DCOLOR color) = 0;
|
||||
virtual HRESULT SetGroupColorRGB(int groupIndex, float r, float g, float b) = 0;
|
||||
virtual HRESULT SetGroupTexture(int groupIndex, const IDirect3DRMTexture* texture) = 0;
|
||||
virtual HRESULT SetGroupTexture(int groupIndex, IDirect3DRMTexture* texture) = 0;
|
||||
virtual HRESULT SetGroupMaterial(int groupIndex, IDirect3DRMMaterial* material) = 0;
|
||||
virtual HRESULT SetGroupMapping(D3DRMGROUPINDEX groupIndex, D3DRMMAPPING mapping) = 0;
|
||||
virtual HRESULT SetGroupQuality(int groupIndex, D3DRMRENDERQUALITY quality) = 0;
|
||||
@ -200,24 +200,28 @@ struct IDirect3DRMMesh : virtual public IUnknown {
|
||||
virtual HRESULT GetVertices(int groupIndex, int startIndex, int count, D3DRMVERTEX* vertices) = 0;
|
||||
};
|
||||
|
||||
struct IDirect3DRMLight : virtual public IUnknown {
|
||||
struct IDirect3DRMLight : public IDirect3DRMObject {
|
||||
virtual HRESULT SetColorRGB(float r, float g, float b) = 0;
|
||||
};
|
||||
|
||||
struct IDirect3DRMLightArray : virtual public IUnknown {
|
||||
struct IDirect3DRMArray : public IUnknown {
|
||||
virtual DWORD GetSize() = 0;
|
||||
virtual HRESULT GetElement(int index, IDirect3DRMLight** light) const = 0;
|
||||
};
|
||||
|
||||
struct IDirect3DRMVisualArray : virtual public IUnknown {
|
||||
virtual DWORD GetSize() = 0;
|
||||
virtual HRESULT GetElement(int index, IDirect3DRMVisual** visual) const = 0;
|
||||
struct IDirect3DRMLightArray : public IDirect3DRMArray {
|
||||
virtual HRESULT GetElement(DWORD index, IDirect3DRMLight** out) = 0;
|
||||
virtual HRESULT AddElement(IDirect3DRMLight* in) = 0;
|
||||
virtual HRESULT DeleteElement(IDirect3DRMLight* element) = 0;
|
||||
};
|
||||
|
||||
struct IDirect3DRMVisualArray : public IDirect3DRMArray {
|
||||
virtual HRESULT GetElement(DWORD index, IDirect3DRMVisual** out) = 0;
|
||||
virtual HRESULT AddElement(IDirect3DRMVisual* in) = 0;
|
||||
virtual HRESULT DeleteElement(IDirect3DRMVisual* element) = 0;
|
||||
};
|
||||
|
||||
typedef struct IDirect3DRMFrameArray* LPDIRECT3DRMFRAMEARRAY;
|
||||
struct IDirect3DRMFrame : virtual public IUnknown {
|
||||
virtual HRESULT SetAppData(LPD3DRM_APPDATA appData) = 0;
|
||||
virtual LPVOID GetAppData() = 0;
|
||||
struct IDirect3DRMFrame : public IDirect3DRMVisual {
|
||||
virtual HRESULT AddChild(IDirect3DRMFrame* child) = 0;
|
||||
virtual HRESULT DeleteChild(IDirect3DRMFrame* child) = 0;
|
||||
virtual HRESULT SetSceneBackgroundRGB(float r, float g, float b) = 0;
|
||||
@ -232,7 +236,7 @@ struct IDirect3DRMFrame : virtual public IUnknown {
|
||||
virtual HRESULT AddVisual(IDirect3DRMFrame* visual) = 0;
|
||||
virtual HRESULT DeleteVisual(IDirect3DRMFrame* visual) = 0;
|
||||
virtual HRESULT GetVisuals(IDirect3DRMVisualArray** visuals) = 0;
|
||||
virtual HRESULT SetTexture(const IDirect3DRMTexture* texture) = 0;
|
||||
virtual HRESULT SetTexture(IDirect3DRMTexture* texture) = 0;
|
||||
virtual HRESULT GetTexture(IDirect3DRMTexture** texture) = 0;
|
||||
virtual HRESULT SetColor(float r, float g, float b, float a) = 0;
|
||||
virtual HRESULT SetColor(D3DCOLOR) = 0;
|
||||
@ -242,22 +246,22 @@ struct IDirect3DRMFrame : virtual public IUnknown {
|
||||
};
|
||||
typedef IDirect3DRMFrame* LPDIRECT3DRMFRAME;
|
||||
|
||||
struct IDirect3DRMFrameArray : public IDirect3DRMArray {
|
||||
virtual HRESULT GetElement(DWORD index, IDirect3DRMFrame** out) = 0;
|
||||
virtual HRESULT AddElement(IDirect3DRMFrame* in) = 0;
|
||||
virtual HRESULT DeleteElement(IDirect3DRMFrame* element) = 0;
|
||||
};
|
||||
|
||||
struct IDirect3DRMFrame2 : public IDirect3DRMFrame {};
|
||||
typedef IDirect3DRMFrame2* LPDIRECT3DRMFRAME2;
|
||||
|
||||
struct IDirect3DRMFrameArray : virtual public IUnknown {
|
||||
virtual DWORD GetSize() = 0;
|
||||
virtual HRESULT GetElement(DWORD index, IDirect3DRMFrame** frame) = 0;
|
||||
};
|
||||
|
||||
struct D3DRMPICKDESC {
|
||||
IDirect3DRMVisual* visual;
|
||||
IDirect3DRMFrame* frame;
|
||||
float dist;
|
||||
};
|
||||
|
||||
struct IDirect3DRMPickedArray : virtual public IUnknown {
|
||||
virtual DWORD GetSize() = 0;
|
||||
struct IDirect3DRMPickedArray : public IDirect3DRMArray {
|
||||
virtual HRESULT GetPick(
|
||||
DWORD index,
|
||||
IDirect3DRMVisual** visual,
|
||||
@ -288,19 +292,20 @@ struct IDirect3DRMViewport : public IDirect3DRMObject {
|
||||
virtual HRESULT Pick(float x, float y, LPDIRECT3DRMPICKEDARRAY* pickedArray) = 0;
|
||||
};
|
||||
|
||||
struct IDirect3DRMWinDevice : virtual public IUnknown {
|
||||
struct IDirect3DRMViewportArray : public IDirect3DRMArray {
|
||||
virtual HRESULT GetElement(DWORD index, IDirect3DRMViewport** out) = 0;
|
||||
virtual HRESULT AddElement(IDirect3DRMViewport* in) = 0;
|
||||
virtual HRESULT DeleteElement(IDirect3DRMViewport* element) = 0;
|
||||
};
|
||||
|
||||
struct IDirect3DRMWinDevice : virtual public IDirect3DRMObject {
|
||||
virtual HRESULT Activate() = 0;
|
||||
virtual HRESULT Paint() = 0;
|
||||
virtual void HandleActivate(WORD wParam) = 0;
|
||||
virtual void HandlePaint(void* p_dc) = 0;
|
||||
};
|
||||
|
||||
struct IDirect3DRMViewportArray : virtual public IUnknown {
|
||||
virtual DWORD GetSize() = 0;
|
||||
virtual HRESULT GetElement(int index, IDirect3DRMViewport** viewport) = 0;
|
||||
};
|
||||
|
||||
struct IDirect3DRMDevice2 : virtual public IUnknown {
|
||||
struct IDirect3DRMDevice : virtual public IDirect3DRMObject {
|
||||
virtual unsigned long GetWidth() = 0;
|
||||
virtual unsigned long GetHeight() = 0;
|
||||
virtual HRESULT SetBufferCount(int count) = 0;
|
||||
@ -316,9 +321,12 @@ struct IDirect3DRMDevice2 : virtual public IUnknown {
|
||||
virtual HRESULT SetRenderMode(D3DRMRENDERMODE mode) = 0;
|
||||
virtual D3DRMRENDERMODE GetRenderMode() = 0;
|
||||
virtual HRESULT Update() = 0;
|
||||
virtual HRESULT AddViewport(IDirect3DRMViewport* viewport) = 0;
|
||||
virtual HRESULT GetViewports(IDirect3DRMViewportArray** ppViewportArray) = 0;
|
||||
};
|
||||
|
||||
struct IDirect3DRMDevice2 : virtual public IDirect3DRMDevice {};
|
||||
|
||||
struct IDirect3DRM : virtual public IUnknown {
|
||||
virtual HRESULT CreateDeviceFromD3D(
|
||||
const IDirect3D2* d3d,
|
||||
|
||||
@ -39,5 +39,6 @@ struct DirectDrawSurfaceImpl : public IDirectDrawSurface3 {
|
||||
HRESULT Unlock(LPVOID lpSurfaceData) override;
|
||||
|
||||
private:
|
||||
SDL_Texture* texture = nullptr;
|
||||
SDL_Texture* m_texture = nullptr;
|
||||
IDirectDrawPalette* m_palette = nullptr;
|
||||
};
|
||||
|
||||
@ -3,24 +3,271 @@
|
||||
#include "miniwin_ddsurface_p.h"
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
|
||||
struct Direct3DRMTextureImpl : public IDirect3DRMTexture2 {
|
||||
HRESULT AddDestroyCallback(void (*cb)(IDirect3DRMObject*, void*), void* arg) override { return DD_OK; }
|
||||
LPVOID GetAppData() override { return m_data; }
|
||||
HRESULT SetAppData(LPD3DRM_APPDATA appData) override
|
||||
template <typename InterfaceType, typename ArrayInterface>
|
||||
class Direct3DRMArrayBase : public ArrayInterface {
|
||||
public:
|
||||
~Direct3DRMArrayBase() override
|
||||
{
|
||||
m_data = appData;
|
||||
for (auto* item : items) {
|
||||
if (item) {
|
||||
item->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
DWORD GetSize() override { return static_cast<DWORD>(items.size()); }
|
||||
HRESULT AddElement(InterfaceType* in) override
|
||||
{
|
||||
if (!in) {
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
in->AddRef();
|
||||
items.push_back(in);
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT SetTexture(const IDirect3DRMTexture* texture) override { return DD_OK; }
|
||||
HRESULT Changed(BOOL arg1, BOOL arg2) override { return DD_OK; }
|
||||
HRESULT GetElement(DWORD index, InterfaceType** out) override
|
||||
{
|
||||
if (index >= items.size()) {
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
*out = static_cast<InterfaceType*>(items[index]);
|
||||
if (*out) {
|
||||
(*out)->AddRef();
|
||||
}
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT DeleteElement(InterfaceType* element) override
|
||||
{
|
||||
auto it = std::find(items.begin(), items.end(), element);
|
||||
if (it == items.end()) {
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
private:
|
||||
LPD3DRM_APPDATA m_data;
|
||||
(*it)->Release();
|
||||
items.erase(it);
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<InterfaceType*> items;
|
||||
};
|
||||
|
||||
struct Direct3DRMDevice2Impl : public IDirect3DRMDevice2 {
|
||||
struct Direct3DRMFrameArrayImpl : public Direct3DRMArrayBase<IDirect3DRMFrame, IDirect3DRMFrameArray> {
|
||||
using Direct3DRMArrayBase::Direct3DRMArrayBase;
|
||||
};
|
||||
|
||||
struct Direct3DRMLightArrayImpl : public Direct3DRMArrayBase<IDirect3DRMLight, IDirect3DRMLightArray> {
|
||||
using Direct3DRMArrayBase::Direct3DRMArrayBase;
|
||||
};
|
||||
|
||||
struct Direct3DRMViewportArrayImpl : public Direct3DRMArrayBase<IDirect3DRMViewport, IDirect3DRMViewportArray> {
|
||||
using Direct3DRMArrayBase::Direct3DRMArrayBase;
|
||||
};
|
||||
|
||||
struct Direct3DRMVisualArrayImpl : public Direct3DRMArrayBase<IDirect3DRMVisual, IDirect3DRMVisualArray> {
|
||||
using Direct3DRMArrayBase::Direct3DRMArrayBase;
|
||||
};
|
||||
|
||||
struct PickRecord {
|
||||
IDirect3DRMVisual* visual;
|
||||
IDirect3DRMFrameArray* frameArray;
|
||||
D3DRMPICKDESC desc;
|
||||
};
|
||||
|
||||
struct Direct3DRMPickedArrayImpl : public IDirect3DRMPickedArray {
|
||||
~Direct3DRMPickedArrayImpl() override
|
||||
{
|
||||
for (PickRecord& pick : picks) {
|
||||
if (pick.visual) {
|
||||
pick.visual->Release();
|
||||
}
|
||||
if (pick.frameArray) {
|
||||
pick.frameArray->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
DWORD GetSize() override { return static_cast<DWORD>(picks.size()); }
|
||||
HRESULT GetPick(DWORD index, IDirect3DRMVisual** visual, IDirect3DRMFrameArray** frameArray, D3DRMPICKDESC* desc)
|
||||
override
|
||||
{
|
||||
if (index >= picks.size()) {
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
const PickRecord& pick = picks[index];
|
||||
|
||||
*visual = pick.visual;
|
||||
*frameArray = pick.frameArray;
|
||||
*desc = pick.desc;
|
||||
|
||||
if (*visual) {
|
||||
(*visual)->AddRef();
|
||||
}
|
||||
if (*frameArray) {
|
||||
(*frameArray)->AddRef();
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<PickRecord> picks;
|
||||
};
|
||||
|
||||
struct Direct3DRMWinDeviceImpl : public IDirect3DRMWinDevice {
|
||||
HRESULT Activate() override { return DD_OK; }
|
||||
HRESULT Paint() override { return DD_OK; }
|
||||
void HandleActivate(WORD wParam) override {}
|
||||
void HandlePaint(void* p_dc) override {}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct Direct3DRMObjectBase : public T {
|
||||
ULONG Release() override
|
||||
{
|
||||
if (IUnknown::m_refCount == 1) {
|
||||
for (auto it = m_callbacks.cbegin(); it != m_callbacks.cend(); it++) {
|
||||
it->first(this, it->second);
|
||||
}
|
||||
}
|
||||
return this->T::Release();
|
||||
}
|
||||
HRESULT AddDestroyCallback(D3DRMOBJECTCALLBACK callback, void* arg) override
|
||||
{
|
||||
m_callbacks.push_back(std::make_pair(callback, arg));
|
||||
return D3DRM_OK;
|
||||
}
|
||||
HRESULT DeleteDestroyCallback(D3DRMOBJECTCALLBACK callback, void* arg) override
|
||||
{
|
||||
for (auto it = m_callbacks.cbegin(); it != m_callbacks.cend(); it++) {
|
||||
if (it->first == callback && it->second == arg) {
|
||||
m_callbacks.erase(it);
|
||||
return D3DRM_OK;
|
||||
}
|
||||
}
|
||||
return D3DRMERR_NOTFOUND;
|
||||
}
|
||||
HRESULT SetAppData(LPD3DRM_APPDATA appData) override
|
||||
{
|
||||
m_appData = appData;
|
||||
return D3DRM_OK;
|
||||
}
|
||||
LPVOID GetAppData() override { return m_appData; }
|
||||
HRESULT SetName(const char* name) override
|
||||
{
|
||||
SDL_free(m_name);
|
||||
m_name = NULL;
|
||||
if (name) {
|
||||
m_name = SDL_strdup(name);
|
||||
}
|
||||
return D3DRM_OK;
|
||||
}
|
||||
HRESULT GetName(DWORD* size, char* name) override
|
||||
{
|
||||
if (!size) {
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
const char* s = m_name ? m_name : "";
|
||||
size_t l = SDL_strlen(s);
|
||||
if (name) {
|
||||
SDL_strlcpy(name, s, *size);
|
||||
}
|
||||
else {
|
||||
*size = l + 1;
|
||||
}
|
||||
return D3DRM_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<std::pair<D3DRMOBJECTCALLBACK, void*>> m_callbacks;
|
||||
LPD3DRM_APPDATA m_appData = NULL;
|
||||
char* m_name = nullptr;
|
||||
};
|
||||
|
||||
struct Direct3DRMMeshImpl : public Direct3DRMObjectBase<IDirect3DRMMesh> {
|
||||
HRESULT Clone(void** ppObject) override
|
||||
{
|
||||
*ppObject = static_cast<void*>(new Direct3DRMMeshImpl);
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT Clone(int flags, GUID iid, void** object) override
|
||||
{
|
||||
if (SDL_memcmp(&iid, &IID_IDirect3DRMMesh, sizeof(GUID)) == 0) {
|
||||
*object = static_cast<IDirect3DRMMesh*>(new Direct3DRMMeshImpl);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
HRESULT GetBox(D3DRMBOX* box) override { return DD_OK; }
|
||||
HRESULT AddGroup(int vertexCount, int faceCount, int vertexPerFace, void* faceBuffer, D3DRMGROUPINDEX* groupIndex)
|
||||
override
|
||||
{
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT GetGroup(
|
||||
int groupIndex,
|
||||
unsigned int* vertexCount,
|
||||
unsigned int* faceCount,
|
||||
unsigned int* vertexPerFace,
|
||||
DWORD* dataSize,
|
||||
unsigned int* data
|
||||
) override
|
||||
{
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT SetGroupColor(int groupIndex, D3DCOLOR color) override { return DD_OK; }
|
||||
HRESULT SetGroupColorRGB(int groupIndex, float r, float g, float b) override { return DD_OK; }
|
||||
HRESULT SetGroupMaterial(int groupIndex, IDirect3DRMMaterial* material) override { return DD_OK; }
|
||||
HRESULT SetGroupMapping(D3DRMGROUPINDEX groupIndex, D3DRMMAPPING mapping) override { return DD_OK; }
|
||||
HRESULT SetGroupQuality(int groupIndex, D3DRMRENDERQUALITY quality) override { return DD_OK; }
|
||||
HRESULT SetVertices(int groupIndex, int offset, int count, D3DRMVERTEX* vertices) override { return DD_OK; }
|
||||
HRESULT SetGroupTexture(int groupIndex, IDirect3DRMTexture* texture) override
|
||||
{
|
||||
m_groupTexture = texture;
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT GetGroupTexture(int groupIndex, LPDIRECT3DRMTEXTURE* texture) override
|
||||
{
|
||||
if (!m_groupTexture) {
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
*texture = m_groupTexture;
|
||||
return DD_OK;
|
||||
}
|
||||
D3DRMMAPPING GetGroupMapping(int groupIndex) override { return D3DRMMAP_PERSPCORRECT; }
|
||||
D3DRMRENDERQUALITY GetGroupQuality(int groupIndex) override { return D3DRMRENDER_GOURAUD; }
|
||||
HRESULT GetGroupColor(D3DRMGROUPINDEX index) override { return DD_OK; }
|
||||
HRESULT GetVertices(int groupIndex, int startIndex, int count, D3DRMVERTEX* vertices) override { return DD_OK; }
|
||||
|
||||
private:
|
||||
IDirect3DRMTexture* m_groupTexture;
|
||||
};
|
||||
|
||||
struct Direct3DRMTextureImpl : public Direct3DRMObjectBase<IDirect3DRMTexture2> {
|
||||
HRESULT Clone(void** ppObject) override
|
||||
{
|
||||
*ppObject = static_cast<void*>(new Direct3DRMTextureImpl);
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT Changed(BOOL pixels, BOOL palette) override { return DD_OK; }
|
||||
};
|
||||
|
||||
struct Direct3DRMDevice2Impl : public Direct3DRMObjectBase<IDirect3DRMDevice2> {
|
||||
Direct3DRMDevice2Impl()
|
||||
{
|
||||
m_viewports = new Direct3DRMViewportArrayImpl;
|
||||
m_viewports->AddRef();
|
||||
}
|
||||
~Direct3DRMDevice2Impl() override { m_viewports->Release(); }
|
||||
HRESULT Clone(void** ppObject) override
|
||||
{
|
||||
*ppObject = static_cast<void*>(new Direct3DRMDevice2Impl);
|
||||
return DD_OK;
|
||||
}
|
||||
unsigned long GetWidth() override { return 640; }
|
||||
unsigned long GetHeight() override { return 480; }
|
||||
HRESULT SetBufferCount(int count) override { return DD_OK; }
|
||||
@ -36,83 +283,82 @@ struct Direct3DRMDevice2Impl : public IDirect3DRMDevice2 {
|
||||
HRESULT SetRenderMode(D3DRMRENDERMODE mode) override { return DD_OK; }
|
||||
D3DRMRENDERMODE GetRenderMode() override { return D3DRMRENDERMODE::BLENDEDTRANSPARENCY; }
|
||||
HRESULT Update() override { return DD_OK; }
|
||||
HRESULT AddViewport(IDirect3DRMViewport* viewport) override { return m_viewports->AddElement(viewport); }
|
||||
HRESULT GetViewports(IDirect3DRMViewportArray** ppViewportArray) override
|
||||
{
|
||||
assert(false && "unimplemented");
|
||||
return DDERR_GENERIC;
|
||||
*ppViewportArray = m_viewports;
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
IDirect3DRMViewportArray* m_viewports;
|
||||
};
|
||||
|
||||
struct Direct3DRMFrameImpl : public IDirect3DRMFrame2 {
|
||||
HRESULT SetAppData(LPD3DRM_APPDATA appData) override
|
||||
struct Direct3DRMFrameImpl : public Direct3DRMObjectBase<IDirect3DRMFrame2> {
|
||||
Direct3DRMFrameImpl()
|
||||
{
|
||||
m_data = appData;
|
||||
return DD_OK;
|
||||
}
|
||||
LPVOID GetAppData() override { return m_data; }
|
||||
HRESULT AddChild(IDirect3DRMFrame* child) override
|
||||
{
|
||||
child->AddRef();
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT DeleteChild(IDirect3DRMFrame* child) override
|
||||
{
|
||||
child->Release();
|
||||
m_children = new Direct3DRMFrameArrayImpl;
|
||||
m_children->AddRef();
|
||||
m_lights = new Direct3DRMLightArrayImpl;
|
||||
m_lights->AddRef();
|
||||
m_visuals = new Direct3DRMVisualArrayImpl;
|
||||
m_visuals->AddRef();
|
||||
}
|
||||
~Direct3DRMFrameImpl() override
|
||||
{
|
||||
m_children->Release();
|
||||
m_lights->Release();
|
||||
m_visuals->Release();
|
||||
if (m_texture) {
|
||||
m_texture->Release();
|
||||
}
|
||||
}
|
||||
HRESULT Clone(void** ppObject) override
|
||||
{
|
||||
*ppObject = static_cast<void*>(new Direct3DRMFrameImpl);
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT AddChild(IDirect3DRMFrame* child) override { return m_children->AddElement(child); }
|
||||
HRESULT DeleteChild(IDirect3DRMFrame* child) override { return m_children->DeleteElement(child); }
|
||||
HRESULT SetSceneBackgroundRGB(float r, float g, float b) override { return DD_OK; }
|
||||
HRESULT AddLight(IDirect3DRMLight* light) override
|
||||
{
|
||||
light->AddRef();
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT AddLight(IDirect3DRMLight* light) override { return m_lights->AddElement(light); }
|
||||
HRESULT GetLights(IDirect3DRMLightArray** lightArray) override
|
||||
{
|
||||
assert(false && "unimplemented");
|
||||
return DDERR_GENERIC;
|
||||
*lightArray = m_lights;
|
||||
m_lights->AddRef();
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT AddTransform(D3DRMCOMBINETYPE combine, D3DRMMATRIX4D matrix) override { return DD_OK; }
|
||||
HRESULT GetPosition(int index, D3DVECTOR* position) override { return DD_OK; }
|
||||
HRESULT AddVisual(IDirect3DRMVisual* visual) override
|
||||
{
|
||||
visual->AddRef();
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT DeleteVisual(IDirect3DRMVisual* visual) override
|
||||
{
|
||||
visual->Release();
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT AddVisual(IDirect3DRMMesh* visual) override
|
||||
{
|
||||
visual->AddRef();
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT DeleteVisual(IDirect3DRMMesh* visual) override
|
||||
{
|
||||
visual->Release();
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT AddVisual(IDirect3DRMFrame* visual) override
|
||||
{
|
||||
visual->AddRef();
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT DeleteVisual(IDirect3DRMFrame* visual) override
|
||||
{
|
||||
visual->Release();
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT AddVisual(IDirect3DRMVisual* visual) override { return m_visuals->AddElement(visual); }
|
||||
HRESULT DeleteVisual(IDirect3DRMVisual* visual) override { return m_visuals->DeleteElement(visual); }
|
||||
HRESULT AddVisual(IDirect3DRMMesh* visual) override { return m_visuals->AddElement(visual); }
|
||||
HRESULT DeleteVisual(IDirect3DRMMesh* visual) override { return m_visuals->DeleteElement(visual); }
|
||||
HRESULT AddVisual(IDirect3DRMFrame* visual) override { return m_visuals->AddElement(visual); }
|
||||
HRESULT DeleteVisual(IDirect3DRMFrame* visual) override { return m_visuals->DeleteElement(visual); }
|
||||
HRESULT GetVisuals(IDirect3DRMVisualArray** visuals) override
|
||||
{
|
||||
assert(false && "unimplemented");
|
||||
return DDERR_GENERIC;
|
||||
*visuals = m_visuals;
|
||||
m_visuals->AddRef();
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT SetTexture(IDirect3DRMTexture* texture) override
|
||||
{
|
||||
if (m_texture) {
|
||||
m_texture->Release();
|
||||
}
|
||||
m_texture = texture;
|
||||
m_texture->AddRef();
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT SetTexture(const IDirect3DRMTexture* texture) override { return DD_OK; }
|
||||
HRESULT GetTexture(IDirect3DRMTexture** texture) override
|
||||
{
|
||||
assert(false && "unimplemented");
|
||||
return DDERR_GENERIC;
|
||||
if (!m_texture) {
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
*texture = m_texture;
|
||||
m_texture->AddRef();
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT SetColor(float r, float g, float b, float a) override { return DD_OK; }
|
||||
HRESULT SetColor(D3DCOLOR) override { return DD_OK; }
|
||||
@ -120,40 +366,36 @@ struct Direct3DRMFrameImpl : public IDirect3DRMFrame2 {
|
||||
HRESULT SetMaterialMode(D3DRMMATERIALMODE mode) override { return DD_OK; }
|
||||
HRESULT GetChildren(IDirect3DRMFrameArray** children) override
|
||||
{
|
||||
assert(false && "unimplemented");
|
||||
return DDERR_GENERIC;
|
||||
*children = m_children;
|
||||
m_children->AddRef();
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
LPD3DRM_APPDATA m_data;
|
||||
IDirect3DRMFrameArray* m_children;
|
||||
IDirect3DRMLightArray* m_lights;
|
||||
IDirect3DRMVisualArray* m_visuals;
|
||||
IDirect3DRMTexture* m_texture;
|
||||
};
|
||||
|
||||
struct Direct3DRMViewportImpl : public IDirect3DRMViewport {
|
||||
Direct3DRMViewportImpl() : m_data(nullptr) {}
|
||||
struct Direct3DRMViewportImpl : public Direct3DRMObjectBase<IDirect3DRMViewport> {
|
||||
HRESULT Clone(void** ppObject) override
|
||||
{
|
||||
assert(false && "unimplemented");
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
HRESULT AddDestroyCallback(void (*cb)(IDirect3DRMObject*, void*), void* arg) override { return DD_OK; }
|
||||
HRESULT DeleteDestroyCallback(void (*cb)(IDirect3DRMObject*, void*), void* arg) override { return DD_OK; }
|
||||
HRESULT SetAppData(LPD3DRM_APPDATA appData) override
|
||||
{
|
||||
m_data = appData;
|
||||
*ppObject = static_cast<void*>(new Direct3DRMViewportImpl);
|
||||
return DD_OK;
|
||||
}
|
||||
LPVOID GetAppData() override { return m_data; }
|
||||
HRESULT SetName(const char* name) override { return DD_OK; }
|
||||
HRESULT GetName(DWORD* size, char* name) override { return DD_OK; }
|
||||
HRESULT GetClassName(DWORD* size, char* name) override { return DD_OK; }
|
||||
HRESULT Render(IDirect3DRMFrame* group) override { return DD_OK; }
|
||||
HRESULT ForceUpdate(int x, int y, int w, int h) override { return DD_OK; }
|
||||
HRESULT Clear() override { return DD_OK; }
|
||||
HRESULT SetCamera(IDirect3DRMFrame* camera) override { return DD_OK; }
|
||||
HRESULT SetCamera(IDirect3DRMFrame* camera) override
|
||||
{
|
||||
m_camera = camera;
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT GetCamera(IDirect3DRMFrame** camera) override
|
||||
{
|
||||
assert(false && "unimplemented");
|
||||
return DDERR_GENERIC;
|
||||
*camera = m_camera;
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT SetProjection(D3DRMPROJECTIONTYPE type) override { return DD_OK; }
|
||||
D3DRMPROJECTIONTYPE GetProjection() override { return D3DRMPROJECTIONTYPE::PERSPECTIVE; }
|
||||
@ -170,14 +412,27 @@ struct Direct3DRMViewportImpl : public IDirect3DRMViewport {
|
||||
HRESULT Pick(float x, float y, LPDIRECT3DRMPICKEDARRAY* pickedArray) override { return DD_OK; }
|
||||
|
||||
private:
|
||||
LPD3DRM_APPDATA m_data;
|
||||
IDirect3DRMFrame* m_camera;
|
||||
};
|
||||
|
||||
struct Direct3DRMLightImpl : public IDirect3DRMLight {
|
||||
struct Direct3DRMLightImpl : public Direct3DRMObjectBase<IDirect3DRMLight> {
|
||||
HRESULT Clone(void** ppObject) override
|
||||
{
|
||||
*ppObject = static_cast<void*>(new Direct3DRMLightImpl);
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT SetColorRGB(float r, float g, float b) override { return DD_OK; }
|
||||
};
|
||||
|
||||
struct Direct3DRMImpl : public IDirect3DRM2 {
|
||||
struct Direct3DRMMaterialImpl : public Direct3DRMObjectBase<IDirect3DRMMaterial> {
|
||||
HRESULT Clone(void** ppObject) override
|
||||
{
|
||||
*ppObject = static_cast<void*>(new Direct3DRMMaterialImpl);
|
||||
return DD_OK;
|
||||
}
|
||||
};
|
||||
|
||||
struct Direct3DRMImpl : virtual public IDirect3DRM2 {
|
||||
// IUnknown interface
|
||||
HRESULT QueryInterface(const GUID& riid, void** ppvObject) override
|
||||
{
|
||||
@ -203,27 +458,27 @@ struct Direct3DRMImpl : public IDirect3DRM2 {
|
||||
IDirect3DRMDevice2** outDevice
|
||||
) override
|
||||
{
|
||||
assert(false && "unimplemented");
|
||||
return DDERR_GENERIC;
|
||||
*outDevice = static_cast<IDirect3DRMDevice2*>(new Direct3DRMDevice2Impl);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CreateTexture(D3DRMIMAGE* image, IDirect3DRMTexture2** outTexture) override
|
||||
{
|
||||
*outTexture = static_cast<IDirect3DRMTexture2*>(new Direct3DRMTextureImpl);
|
||||
return DDERR_GENERIC;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CreateTextureFromSurface(LPDIRECTDRAWSURFACE surface, IDirect3DRMTexture2** outTexture) override
|
||||
{
|
||||
*outTexture = static_cast<IDirect3DRMTexture2*>(new Direct3DRMTextureImpl);
|
||||
return DDERR_GENERIC;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CreateMesh(IDirect3DRMMesh** outMesh) override
|
||||
{
|
||||
// TODO
|
||||
*outMesh = static_cast<IDirect3DRMMesh*>(new Direct3DRMMeshImpl);
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
HRESULT CreateMaterial(D3DVAL power, IDirect3DRMMaterial** outMaterial) override
|
||||
{
|
||||
*outMaterial = new IDirect3DRMMaterial;
|
||||
*outMaterial = static_cast<IDirect3DRMMaterial*>(new Direct3DRMMaterialImpl);
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT CreateLightRGB(D3DRMLIGHTTYPE type, D3DVAL r, D3DVAL g, D3DVAL b, IDirect3DRMLight** outLight) override
|
||||
@ -247,6 +502,7 @@ struct Direct3DRMImpl : public IDirect3DRM2 {
|
||||
) override
|
||||
{
|
||||
*outViewport = static_cast<IDirect3DRMViewport*>(new Direct3DRMViewportImpl);
|
||||
device->AddViewport(*outViewport);
|
||||
return DD_OK;
|
||||
}
|
||||
HRESULT SetDefaultTextureShades(unsigned int count) override { return DD_OK; }
|
||||
|
||||
@ -113,10 +113,6 @@ HRESULT DirectDrawImpl::EnumDisplayModes(
|
||||
LPDDENUMMODESCALLBACK lpEnumModesCallback
|
||||
)
|
||||
{
|
||||
if (!lpEnumModesCallback) {
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
SDL_DisplayID displayID = SDL_GetPrimaryDisplay();
|
||||
if (!displayID) {
|
||||
return DDERR_GENERIC;
|
||||
@ -181,10 +177,6 @@ HRESULT DirectDrawImpl::GetCaps(LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps)
|
||||
|
||||
HRESULT DirectDrawImpl::EnumDevices(LPD3DENUMDEVICESCALLBACK cb, void* ctx)
|
||||
{
|
||||
if (!cb) {
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
int numDrivers = SDL_GetNumRenderDrivers();
|
||||
if (numDrivers <= 0) {
|
||||
return DDERR_GENERIC;
|
||||
@ -288,9 +280,6 @@ HRESULT DirectDrawCreate(LPGUID lpGuid, LPDIRECTDRAW* lplpDD, IUnknown* pUnkOute
|
||||
if (lpGuid) {
|
||||
MINIWIN_ERROR("Specifying a DirectDraw driver is not implemented");
|
||||
}
|
||||
if (!lplpDD) {
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
|
||||
*lplpDD = new DirectDrawImpl;
|
||||
|
||||
|
||||
@ -10,16 +10,16 @@ DirectDrawSurfaceImpl::DirectDrawSurfaceImpl()
|
||||
|
||||
DirectDrawSurfaceImpl::DirectDrawSurfaceImpl(int width, int height)
|
||||
{
|
||||
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, width, height);
|
||||
if (!texture) {
|
||||
m_texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, width, height);
|
||||
if (!m_texture) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to create texture: %s", SDL_GetError());
|
||||
}
|
||||
}
|
||||
|
||||
DirectDrawSurfaceImpl::~DirectDrawSurfaceImpl()
|
||||
{
|
||||
if (texture) {
|
||||
SDL_DestroyTexture(texture);
|
||||
if (m_texture) {
|
||||
SDL_DestroyTexture(m_texture);
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ HRESULT DirectDrawSurfaceImpl::Blt(
|
||||
}
|
||||
SDL_FRect srcRect = ConvertRect(lpSrcRect);
|
||||
SDL_FRect dstRect = ConvertRect(lpDestRect);
|
||||
SDL_RenderTexture(renderer, static_cast<DirectDrawSurfaceImpl*>(lpDDSrcSurface)->texture, &srcRect, &dstRect);
|
||||
SDL_RenderTexture(renderer, static_cast<DirectDrawSurfaceImpl*>(lpDDSrcSurface)->m_texture, &srcRect, &dstRect);
|
||||
SDL_RenderPresent(renderer);
|
||||
return DD_OK;
|
||||
}
|
||||
@ -76,20 +76,20 @@ HRESULT DirectDrawSurfaceImpl::BltFast(
|
||||
(float) (lpSrcRect->bottom - lpSrcRect->top)
|
||||
};
|
||||
SDL_FRect srcRect = ConvertRect(lpSrcRect);
|
||||
SDL_RenderTexture(renderer, static_cast<DirectDrawSurfaceImpl*>(lpDDSrcSurface)->texture, &srcRect, &dstRect);
|
||||
SDL_RenderTexture(renderer, static_cast<DirectDrawSurfaceImpl*>(lpDDSrcSurface)->m_texture, &srcRect, &dstRect);
|
||||
SDL_RenderPresent(renderer);
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
HRESULT DirectDrawSurfaceImpl::Flip(LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, DDFlipFlags dwFlags)
|
||||
{
|
||||
if (!renderer || !texture) {
|
||||
if (!renderer || !m_texture) {
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
float width, height;
|
||||
SDL_GetTextureSize(texture, &width, &height);
|
||||
SDL_GetTextureSize(m_texture, &width, &height);
|
||||
SDL_FRect rect{0, 0, width, height};
|
||||
SDL_RenderTexture(renderer, texture, &rect, &rect);
|
||||
SDL_RenderTexture(renderer, m_texture, &rect, &rect);
|
||||
SDL_RenderPresent(renderer);
|
||||
return DD_OK;
|
||||
}
|
||||
@ -120,8 +120,12 @@ HRESULT DirectDrawSurfaceImpl::GetOverlayPosition(LPLONG lplX, LPLONG lplY)
|
||||
|
||||
HRESULT DirectDrawSurfaceImpl::GetPalette(LPDIRECTDRAWPALETTE* lplpDDPalette)
|
||||
{
|
||||
assert(false && "unimplemented");
|
||||
return DDERR_GENERIC;
|
||||
if (!m_palette) {
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
m_palette->AddRef();
|
||||
*lplpDDPalette = m_palette;
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
HRESULT DirectDrawSurfaceImpl::GetPixelFormat(LPDDPIXELFORMAT lpDDPixelFormat)
|
||||
@ -133,10 +137,10 @@ HRESULT DirectDrawSurfaceImpl::GetPixelFormat(LPDDPIXELFORMAT lpDDPixelFormat)
|
||||
|
||||
HRESULT DirectDrawSurfaceImpl::GetSurfaceDesc(LPDDSURFACEDESC lpDDSurfaceDesc)
|
||||
{
|
||||
if (!texture) {
|
||||
if (!m_texture) {
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
const SDL_PixelFormatDetails* format = SDL_GetPixelFormatDetails(texture->format);
|
||||
const SDL_PixelFormatDetails* format = SDL_GetPixelFormatDetails(m_texture->format);
|
||||
lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB;
|
||||
lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = (format->bits_per_pixel == 8) ? 8 : 16;
|
||||
lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = format->Rmask;
|
||||
@ -156,22 +160,19 @@ HRESULT DirectDrawSurfaceImpl::Lock(
|
||||
HANDLE hEvent
|
||||
)
|
||||
{
|
||||
if (!lpDDSurfaceDesc) {
|
||||
return DDERR_INVALIDPARAMS;
|
||||
}
|
||||
if (!texture) {
|
||||
if (!m_texture) {
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
|
||||
int pitch = 0;
|
||||
void* pixels = nullptr;
|
||||
if (SDL_LockTexture(texture, (SDL_Rect*) lpDestRect, &pixels, &pitch) < 0) {
|
||||
if (SDL_LockTexture(m_texture, (SDL_Rect*) lpDestRect, &pixels, &pitch) < 0) {
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
|
||||
lpDDSurfaceDesc->lpSurface = pixels;
|
||||
lpDDSurfaceDesc->lPitch = pitch;
|
||||
const SDL_PixelFormatDetails* format = SDL_GetPixelFormatDetails(texture->format);
|
||||
const SDL_PixelFormatDetails* format = SDL_GetPixelFormatDetails(m_texture->format);
|
||||
lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB;
|
||||
lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = (format->bits_per_pixel == 8) ? 8 : 16;
|
||||
lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = format->Rmask;
|
||||
@ -208,9 +209,9 @@ HRESULT DirectDrawSurfaceImpl::SetPalette(LPDIRECTDRAWPALETTE lpDDPalette)
|
||||
|
||||
HRESULT DirectDrawSurfaceImpl::Unlock(LPVOID lpSurfaceData)
|
||||
{
|
||||
if (!texture) {
|
||||
if (!m_texture) {
|
||||
return DDERR_GENERIC;
|
||||
}
|
||||
SDL_UnlockTexture(texture);
|
||||
SDL_UnlockTexture(m_texture);
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user