mirror of
https://github.com/isledecomp/isle-portable.git
synced 2026-01-11 18:41:14 +00:00
Sky color controls (#149)
* d3drm: Clear background color * Update miniwin/miniwin/src/include/miniwin_d3drmviewport_p.h Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com> * Update miniwin/miniwin/src/include/miniwin_d3drmframe_p.h --------- Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
This commit is contained in:
parent
92ee03ec4d
commit
0441296d37
@ -28,6 +28,8 @@ struct Direct3DRMFrameImpl : public Direct3DRMObjectBase<IDirect3DRMFrame2> {
|
|||||||
HRESULT SetMaterialMode(D3DRMMATERIALMODE mode) override;
|
HRESULT SetMaterialMode(D3DRMMATERIALMODE mode) override;
|
||||||
HRESULT GetChildren(IDirect3DRMFrameArray** children) override;
|
HRESULT GetChildren(IDirect3DRMFrameArray** children) override;
|
||||||
|
|
||||||
|
D3DCOLOR m_backgroundColor = 0xFF000000;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IDirect3DRMFrameArray* m_children;
|
IDirect3DRMFrameArray* m_children;
|
||||||
IDirect3DRMLightArray* m_lights;
|
IDirect3DRMLightArray* m_lights;
|
||||||
|
|||||||
@ -4,4 +4,7 @@
|
|||||||
|
|
||||||
struct Direct3DRMLightImpl : public Direct3DRMObjectBase<IDirect3DRMLight> {
|
struct Direct3DRMLightImpl : public Direct3DRMObjectBase<IDirect3DRMLight> {
|
||||||
HRESULT SetColorRGB(float r, float g, float b) override;
|
HRESULT SetColorRGB(float r, float g, float b) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
D3DCOLOR m_color = 0xFFFFFFFF;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -38,13 +38,14 @@ struct Direct3DRMViewportImpl : public Direct3DRMObjectBase<IDirect3DRMViewport>
|
|||||||
HRESULT InverseTransform(D3DVECTOR* world, D3DRMVECTOR4D* screen) override;
|
HRESULT InverseTransform(D3DVECTOR* world, D3DRMVECTOR4D* screen) override;
|
||||||
HRESULT Pick(float x, float y, LPDIRECT3DRMPICKEDARRAY* pickedArray) override;
|
HRESULT Pick(float x, float y, LPDIRECT3DRMPICKEDARRAY* pickedArray) override;
|
||||||
void CloseDevice();
|
void CloseDevice();
|
||||||
void Update();
|
void CollectSceneData(IDirect3DRMFrame* group);
|
||||||
|
void PushVertices(const PositionColorVertex* vertices, size_t count);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void FreeDeviceResources();
|
void FreeDeviceResources();
|
||||||
int m_vertexBufferCount = 0;
|
int m_vertexBufferCount = 0;
|
||||||
int m_vertexCount;
|
int m_vertexCount;
|
||||||
bool m_updated = false;
|
D3DCOLOR m_backgroundColor = 0xFF000000;
|
||||||
DWORD m_width;
|
DWORD m_width;
|
||||||
DWORD m_height;
|
DWORD m_height;
|
||||||
IDirect3DRMFrame* m_camera = nullptr;
|
IDirect3DRMFrame* m_camera = nullptr;
|
||||||
|
|||||||
@ -105,12 +105,7 @@ D3DRMRENDERMODE Direct3DRMDevice2Impl::GetRenderMode()
|
|||||||
|
|
||||||
HRESULT Direct3DRMDevice2Impl::Update()
|
HRESULT Direct3DRMDevice2Impl::Update()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < m_viewports->GetSize(); i++) {
|
MINIWIN_NOT_IMPLEMENTED();
|
||||||
IDirect3DRMViewport* viewport;
|
|
||||||
m_viewports->GetElement(i, &viewport);
|
|
||||||
static_cast<Direct3DRMViewportImpl*>(viewport)->Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,8 @@ HRESULT Direct3DRMFrameImpl::DeleteChild(IDirect3DRMFrame* child)
|
|||||||
|
|
||||||
HRESULT Direct3DRMFrameImpl::SetSceneBackgroundRGB(float r, float g, float b)
|
HRESULT Direct3DRMFrameImpl::SetSceneBackgroundRGB(float r, float g, float b)
|
||||||
{
|
{
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
m_backgroundColor = (0xFF << 24) | (static_cast<BYTE>(r * 255.0f) << 16) | (static_cast<BYTE>(g * 255.0f) << 8) |
|
||||||
|
(static_cast<BYTE>(b * 255.0f));
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
HRESULT Direct3DRMLightImpl::SetColorRGB(float r, float g, float b)
|
HRESULT Direct3DRMLightImpl::SetColorRGB(float r, float g, float b)
|
||||||
{
|
{
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
m_color = (0xFF << 24) | (static_cast<BYTE>(r * 255.0f) << 16) | (static_cast<BYTE>(g * 255.0f) << 8) |
|
||||||
|
(static_cast<BYTE>(b * 255.0f));
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include "miniwin_d3drm_p.h"
|
#include "miniwin_d3drm_p.h"
|
||||||
|
#include "miniwin_d3drmframe_p.h"
|
||||||
#include "miniwin_d3drmviewport_p.h"
|
#include "miniwin_d3drmviewport_p.h"
|
||||||
#include "miniwin_p.h"
|
#include "miniwin_p.h"
|
||||||
|
|
||||||
@ -28,22 +29,30 @@ Direct3DRMViewportImpl::~Direct3DRMViewportImpl()
|
|||||||
FreeDeviceResources();
|
FreeDeviceResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Direct3DRMViewportImpl::Update()
|
void Direct3DRMViewportImpl::CollectSceneData(IDirect3DRMFrame* group)
|
||||||
{
|
{
|
||||||
int newVertexCount = 3;
|
m_backgroundColor = static_cast<Direct3DRMFrameImpl*>(group)->m_backgroundColor;
|
||||||
|
|
||||||
if (newVertexCount > m_vertexBufferCount) {
|
std::vector<PositionColorVertex> vertices =
|
||||||
|
{{-1, -1, 0, 0, 255, 0, 255}, {1, -1, 0, 0, 0, 255, 255}, {0, 1, 0, 255, 0, 0, 128}};
|
||||||
|
|
||||||
|
PushVertices(vertices.data(), vertices.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Direct3DRMViewportImpl::PushVertices(const PositionColorVertex* vertices, size_t count)
|
||||||
|
{
|
||||||
|
if (count > m_vertexBufferCount) {
|
||||||
if (m_vertexBuffer) {
|
if (m_vertexBuffer) {
|
||||||
SDL_ReleaseGPUBuffer(m_device, m_vertexBuffer);
|
SDL_ReleaseGPUBuffer(m_device, m_vertexBuffer);
|
||||||
}
|
}
|
||||||
SDL_GPUBufferCreateInfo bufferCreateInfo = {};
|
SDL_GPUBufferCreateInfo bufferCreateInfo = {};
|
||||||
bufferCreateInfo.usage = SDL_GPU_BUFFERUSAGE_VERTEX;
|
bufferCreateInfo.usage = SDL_GPU_BUFFERUSAGE_VERTEX;
|
||||||
bufferCreateInfo.size = static_cast<Uint32>(sizeof(PositionColorVertex) * newVertexCount);
|
bufferCreateInfo.size = static_cast<Uint32>(sizeof(PositionColorVertex) * count);
|
||||||
m_vertexBuffer = SDL_CreateGPUBuffer(m_device, &bufferCreateInfo);
|
m_vertexBuffer = SDL_CreateGPUBuffer(m_device, &bufferCreateInfo);
|
||||||
m_vertexBufferCount = newVertexCount;
|
m_vertexBufferCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vertexCount = newVertexCount;
|
m_vertexCount = count;
|
||||||
|
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
MINIWIN_NOT_IMPLEMENTED();
|
||||||
SDL_GPUTransferBufferCreateInfo transferCreateInfo = {};
|
SDL_GPUTransferBufferCreateInfo transferCreateInfo = {};
|
||||||
@ -54,9 +63,7 @@ void Direct3DRMViewportImpl::Update()
|
|||||||
PositionColorVertex* transferData =
|
PositionColorVertex* transferData =
|
||||||
(PositionColorVertex*) SDL_MapGPUTransferBuffer(m_device, transferBuffer, false);
|
(PositionColorVertex*) SDL_MapGPUTransferBuffer(m_device, transferBuffer, false);
|
||||||
|
|
||||||
transferData[0] = {-1, -1, 0, 255, 0, 0, 255};
|
memcpy(transferData, vertices, m_vertexCount * sizeof(PositionColorVertex));
|
||||||
transferData[1] = {1, -1, 0, 0, 0, 255, 255};
|
|
||||||
transferData[2] = {0, 1, 0, 0, 255, 0, 128};
|
|
||||||
|
|
||||||
SDL_UnmapGPUTransferBuffer(m_device, transferBuffer);
|
SDL_UnmapGPUTransferBuffer(m_device, transferBuffer);
|
||||||
|
|
||||||
@ -77,20 +84,16 @@ void Direct3DRMViewportImpl::Update()
|
|||||||
SDL_EndGPUCopyPass(copyPass);
|
SDL_EndGPUCopyPass(copyPass);
|
||||||
SDL_SubmitGPUCommandBuffer(uploadCmdBuf);
|
SDL_SubmitGPUCommandBuffer(uploadCmdBuf);
|
||||||
SDL_ReleaseGPUTransferBuffer(m_device, transferBuffer);
|
SDL_ReleaseGPUTransferBuffer(m_device, transferBuffer);
|
||||||
|
|
||||||
m_updated = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT Direct3DRMViewportImpl::Render(IDirect3DRMFrame* group)
|
HRESULT Direct3DRMViewportImpl::Render(IDirect3DRMFrame* group)
|
||||||
{
|
{
|
||||||
if (!m_updated) {
|
|
||||||
return DDERR_GENERIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_device) {
|
if (!m_device) {
|
||||||
return DDERR_GENERIC;
|
return DDERR_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CollectSceneData(group);
|
||||||
|
|
||||||
SDL_GPUCommandBuffer* cmdbuf = SDL_AcquireGPUCommandBuffer(m_device);
|
SDL_GPUCommandBuffer* cmdbuf = SDL_AcquireGPUCommandBuffer(m_device);
|
||||||
if (cmdbuf == NULL) {
|
if (cmdbuf == NULL) {
|
||||||
return DDERR_GENERIC;
|
return DDERR_GENERIC;
|
||||||
@ -133,8 +136,6 @@ HRESULT Direct3DRMViewportImpl::Render(IDirect3DRMFrame* group)
|
|||||||
return DDERR_GENERIC;
|
return DDERR_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_updated = false;
|
|
||||||
|
|
||||||
SDL_DestroySurface(m_renderedImage);
|
SDL_DestroySurface(m_renderedImage);
|
||||||
m_renderedImage = SDL_CreateSurfaceFrom(
|
m_renderedImage = SDL_CreateSurfaceFrom(
|
||||||
DDBackBuffer->w,
|
DDBackBuffer->w,
|
||||||
@ -188,7 +189,16 @@ HRESULT Direct3DRMViewportImpl::ForceUpdate(int x, int y, int w, int h)
|
|||||||
|
|
||||||
HRESULT Direct3DRMViewportImpl::Clear()
|
HRESULT Direct3DRMViewportImpl::Clear()
|
||||||
{
|
{
|
||||||
MINIWIN_NOT_IMPLEMENTED();
|
if (!DDBackBuffer) {
|
||||||
|
return DDERR_GENERIC;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t r = (m_backgroundColor >> 16) & 0xFF;
|
||||||
|
uint8_t g = (m_backgroundColor >> 8) & 0xFF;
|
||||||
|
uint8_t b = m_backgroundColor & 0xFF;
|
||||||
|
|
||||||
|
Uint32 color = SDL_MapRGB(SDL_GetPixelFormatDetails(DDBackBuffer->format), nullptr, r, g, b);
|
||||||
|
SDL_FillSurfaceRect(DDBackBuffer, NULL, color);
|
||||||
return DD_OK;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user