Add a PositionTranslate func and add Errors for TextureSize mismatch
This commit is contained in:
@@ -21,10 +21,14 @@ class OsCtx {
|
||||
virtual bool Mainloop() { return false; }
|
||||
virtual void ClearViewPort() {}
|
||||
virtual void SwapBuffers() {}
|
||||
PD::fvec2 SizeTranslate(PD::fvec2 in) {
|
||||
PD::fvec2 PositionTranslate(PD::fvec2 in) {
|
||||
return fvec2(in.x * pViewPort.x, in.y * pViewPort.y);
|
||||
}
|
||||
|
||||
PD::fvec2 SizeTranslate(PD::fvec2 in) {
|
||||
return fvec2(in.x * pViewPort.y, in.y * pViewPort.y);
|
||||
}
|
||||
|
||||
protected:
|
||||
PD::ivec2 pViewPort;
|
||||
const Driver pDriver;
|
||||
|
||||
@@ -42,11 +42,12 @@ int main(int argc, char** argv) {
|
||||
while (pOs->Mainloop()) {
|
||||
pOs->ClearViewPort();
|
||||
PD::Li::ResetPools();
|
||||
pList.PathRect(pOs->SizeTranslate(0.05), pOs->SizeTranslate(0.4f), 10.f);
|
||||
pList.PathRect(pOs->PositionTranslate(0.05), pOs->PositionTranslate(0.4f),
|
||||
10.f);
|
||||
pList.PathFill(0xff00ffff);
|
||||
pList.BindTexture(pTex);
|
||||
pList.DrawRectFilled(pOs->SizeTranslate(PD::fvec2(0.02f, 0.5f)),
|
||||
pOs->SizeTranslate(PD::fvec2(0.14, 0.3)), 0xffffffff);
|
||||
pList.DrawRectFilled(pOs->PositionTranslate(PD::fvec2(0.02f, 0.5f)),
|
||||
pOs->SizeTranslate(PD::fvec2(0.3)), 0xffffffff);
|
||||
PD::Gfx::Reset();
|
||||
PD::Gfx::Draw(pList);
|
||||
pList.Clear();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <os/desktopos.hpp>
|
||||
#include <pdsystem>
|
||||
|
||||
#if !defined(__SWITCH__) && !defined(__3DS__)
|
||||
#define GLFW_INCLUDE_NONE
|
||||
@@ -11,8 +12,6 @@
|
||||
#include <GLFW/glfw3native.h>
|
||||
#endif
|
||||
|
||||
#include <pdsystem>
|
||||
|
||||
namespace PD {
|
||||
struct DesktopOS::Impl {
|
||||
GLFWwindow* win = nullptr;
|
||||
@@ -62,9 +61,9 @@ void DesktopOS::Init() {
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.hDeviceWindow = hwnd;
|
||||
|
||||
HRESULT hr = impl->d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
|
||||
D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp,
|
||||
&impl->dx9_device);
|
||||
HRESULT hr = impl->d3d->CreateDevice(
|
||||
D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
|
||||
D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &impl->dx9_device);
|
||||
if (FAILED(hr)) {
|
||||
MessageBoxW(nullptr, L"Failed to create D3D9 device", L"Error", MB_OK);
|
||||
std::abort();
|
||||
@@ -91,9 +90,19 @@ bool DesktopOS::Mainloop() {
|
||||
|
||||
void DesktopOS::ClearViewPort() {
|
||||
PD::Gfx::SetViewPort(pViewPort);
|
||||
glClearColor(0.1, 0.1, 0.1, 0.1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glViewport(0, 0, pViewPort.x, pViewPort.y);
|
||||
if (pDriver == Driver::OpenGL3 || pDriver == Driver::OpenGL2) {
|
||||
glClearColor(0.1, 0.1, 0.1, 0.1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glViewport(0, 0, pViewPort.x, pViewPort.y);
|
||||
} else if (pDriver == Driver::DirectX9) {
|
||||
#ifdef _WIN32
|
||||
if (impl->dx9_device) {
|
||||
impl->dx9_device->Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
|
||||
D3DCOLOR_XRGB(25, 25, 25), 1.0f, 0);
|
||||
impl->dx9_device->BeginScene();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void DesktopOS::SwapBuffers() { glfwSwapBuffers(impl->win); }
|
||||
|
||||
Reference in New Issue
Block a user