1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

merged contents

This commit is contained in:
Eduardo P. Gomez 2023-09-20 21:52:09 -03:00
parent 6380022aa1
commit 555849a1fb
6 changed files with 86 additions and 28 deletions

View File

@ -51,6 +51,38 @@ BOOL ShowWindow(HWND window, int nCmdShow) {
return r; return r;
} }
BOOL DestroyWindow(HWND window) {
gtk_window_destroy(GTK_WINDOW(window));
return true;
}
BOOL GetMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax) {
BOOL r = g_main_context_pending(NULL);
//i know this is wrong, but i need to get the sample working
if (r) {
g_main_context_iteration(NULL, true);
} else {
lpMsg->message = WM_QUIT;
}
return r;
}
BOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg) {
BOOL r = g_main_context_pending(NULL);
//i know this is wrong, but i need to get the sample working
if (r) {
g_main_context_iteration(NULL, true);
} else {
lpMsg->message = WM_QUIT;
}
return r;
}
/* /*
* OpenDX utility class * OpenDX utility class
*/ */

View File

@ -1,10 +1,10 @@
#pragma once #pragma once
#include <windows.h>
#define WINAPI __stdcall /*
#define HINSTANCE void* * ref: https://learn.microsoft.com/en-us/windows/win32/api/windef/ns-windef-point
#define LPSTR char* */
#define LPCTSTR const char* typedef struct tagPOINT {
#define HWND GtkWidget LONG x;
#define HMENU void* LONG y;
} POINT, *PPOINT, *NPPOINT, *LPPOINT;
#define DWORD unsigned long

View File

@ -15,6 +15,8 @@
#if defined(__GNUC__) #if defined(__GNUC__)
#define __stdcall __attribute__((stdcall)) #define __stdcall __attribute__((stdcall))
#endif #endif
#define WINAPI __stdcall
#define __int64 long long
//windows types: //windows types:
#define WCHAR wchar_t #define WCHAR wchar_t
@ -25,8 +27,9 @@
#define LONG long #define LONG long
#define BOOL bool #define BOOL bool
#define BYTE unsigned char #define BYTE unsigned char
#define LPCTSTR const char* #define LPSTR char*
#define LPCSTR const char* #define LPCSTR const char*
#define LPCTSTR const char*
#define LPCWSTR const char* #define LPCWSTR const char*
#include <stdarg.h> #include <stdarg.h>
@ -34,9 +37,12 @@
#include <winnt.h> #include <winnt.h>
//#include <gtk/gtk.h> //#include <gtk/gtk.h>
#define LPCTSTR const char*
#define DWORD unsigned long #define DWORD unsigned long
#define HWND void* #define HWND GtkWidget*
#define HMENU void* #define HMENU void*
#define HINSTANCE void* #define HINSTANCE void*
#define LPVOID void* #define LPVOID void*
#define LONG_PTR __int64
#define LPARAM LONG_PTR
#define WPARAM unsigned __int64

View File

@ -4,6 +4,22 @@
#pragma once #pragma once
#include <windows.h> #include <windows.h>
/*
* MSG
* ref: https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-msg
*/
typedef struct tagMSG {
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
DWORD lPrivate;
} MSG, *PMSG, *NPMSG, *LPMSG;
#define WM_QUIT 0x0012
/** /**
* Extended Window Styles * Extended Window Styles
* ref: https://learn.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles * ref: https://learn.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles
@ -84,8 +100,14 @@ HWND CreateWindowExA(
); );
BOOL ShowWindow(HWND window, int nCmdShow); BOOL ShowWindow(HWND window, int nCmdShow);
BOOL DestroyWindow(HWND window);
BOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg);
#define CreateWindowExW CreateWindowExA #define CreateWindowExW CreateWindowExA
#define PeekMessageW PeekMessageA
#define PM_NOREMOVE 0x0000
#define PM_REMOVE 0x0001
#define PM_NOYIELD 0x0002
// https://www.codeproject.com/Answers/136442/Differences-Between-CreateWindow-and-CreateWindowE#answer3 // https://www.codeproject.com/Answers/136442/Differences-Between-CreateWindow-and-CreateWindowE#answer3
#define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\ #define CreateWindowA(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)\
@ -96,6 +118,8 @@ CreateWindowExW(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, h
//TODO: check if it's needed in a linux environment //TODO: check if it's needed in a linux environment
#if UNICODE #if UNICODE
#define CreateWindow CreateWindowW #define CreateWindow CreateWindowW
#define PeekMessage PeekMessageW
#else #else
#define CreateWindow CreateWindowA #define CreateWindow CreateWindowA
#define PeekMessage PeekMessageA
#endif #endif

2
run.sh
View File

@ -1,3 +1,3 @@
# Run dxdiag from build directory # Run dxdiag from build directory
cd build cd build
./dxdiag ./tests/sample

View File

@ -25,37 +25,33 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
LPDIRECT3DDEVICE9 pDevice = NULL; LPDIRECT3DDEVICE9 pDevice = NULL;
D3DPRESENT_PARAMETERS pp; D3DPRESENT_PARAMETERS pp;
//ZeroMemory(&pp, sizeof(pp));
//wait 5 seconds (Linux):
sleep(5);
/*ZeroMemory(&pp, sizeof(pp));
pp.Windowed = TRUE; pp.Windowed = TRUE;
pp.SwapEffect = D3DSWAPEFFECT_DISCARD; pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &pp, &pDevice); //pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &pp, &pDevice);
// Enter the message loop // Enter the message loop
MSG msg; MSG msg;
ZeroMemory(&msg, sizeof(msg)); //ZeroMemory(&msg, sizeof(msg));
while (msg.message != WM_QUIT) { while (msg.message != WM_QUIT) {
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg); //TranslateMessage(&msg);
DispatchMessage(&msg); //DispatchMessage(&msg);
} } else {
else {
// Render the scene // Render the scene
pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0); /*pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);
pDevice->BeginScene(); pDevice->BeginScene();
pDevice->EndScene(); pDevice->EndScene();
pDevice->Present(NULL, NULL, NULL, NULL); pDevice->Present(NULL, NULL, NULL, NULL);*/
} }
} }
sleep(5);
// Clean up // Clean up
pDevice->Release(); //pDevice->Release(); //causes a segfault
pD3D->Release(); //pD3D->Release();
DestroyWindow(hWnd); DestroyWindow(hWnd);
return msg.wParam;*/ //return msg.wParam;
return 0; return 0;
} }