mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
merged contents
This commit is contained in:
parent
6380022aa1
commit
555849a1fb
@ -51,6 +51,38 @@ BOOL ShowWindow(HWND window, int nCmdShow) {
|
||||
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
|
||||
*/
|
||||
|
@ -1,10 +1,10 @@
|
||||
#pragma once
|
||||
#include <windows.h>
|
||||
|
||||
#define WINAPI __stdcall
|
||||
#define HINSTANCE void*
|
||||
#define LPSTR char*
|
||||
#define LPCTSTR const char*
|
||||
#define HWND GtkWidget
|
||||
#define HMENU void*
|
||||
|
||||
#define DWORD unsigned long
|
||||
/*
|
||||
* ref: https://learn.microsoft.com/en-us/windows/win32/api/windef/ns-windef-point
|
||||
*/
|
||||
typedef struct tagPOINT {
|
||||
LONG x;
|
||||
LONG y;
|
||||
} POINT, *PPOINT, *NPPOINT, *LPPOINT;
|
@ -15,6 +15,8 @@
|
||||
#if defined(__GNUC__)
|
||||
#define __stdcall __attribute__((stdcall))
|
||||
#endif
|
||||
#define WINAPI __stdcall
|
||||
#define __int64 long long
|
||||
|
||||
//windows types:
|
||||
#define WCHAR wchar_t
|
||||
@ -25,8 +27,9 @@
|
||||
#define LONG long
|
||||
#define BOOL bool
|
||||
#define BYTE unsigned char
|
||||
#define LPCTSTR const char*
|
||||
#define LPSTR char*
|
||||
#define LPCSTR const char*
|
||||
#define LPCTSTR const char*
|
||||
#define LPCWSTR const char*
|
||||
|
||||
#include <stdarg.h>
|
||||
@ -34,9 +37,12 @@
|
||||
#include <winnt.h>
|
||||
//#include <gtk/gtk.h>
|
||||
|
||||
#define LPCTSTR const char*
|
||||
#define DWORD unsigned long
|
||||
#define HWND void*
|
||||
#define HWND GtkWidget*
|
||||
#define HMENU void*
|
||||
#define HINSTANCE void*
|
||||
#define LPVOID void*
|
||||
|
||||
#define LONG_PTR __int64
|
||||
#define LPARAM LONG_PTR
|
||||
#define WPARAM unsigned __int64
|
||||
|
@ -4,6 +4,22 @@
|
||||
#pragma once
|
||||
#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
|
||||
* 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 DestroyWindow(HWND window);
|
||||
|
||||
BOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg);
|
||||
#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
|
||||
#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
|
||||
#if UNICODE
|
||||
#define CreateWindow CreateWindowW
|
||||
#define PeekMessage PeekMessageW
|
||||
#else
|
||||
#define CreateWindow CreateWindowA
|
||||
#define PeekMessage PeekMessageA
|
||||
#endif
|
2
run.sh
2
run.sh
@ -1,3 +1,3 @@
|
||||
# Run dxdiag from build directory
|
||||
cd build
|
||||
./dxdiag
|
||||
./tests/sample
|
@ -25,37 +25,33 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
LPDIRECT3DDEVICE9 pDevice = NULL;
|
||||
D3DPRESENT_PARAMETERS pp;
|
||||
|
||||
|
||||
//wait 5 seconds (Linux):
|
||||
sleep(5);
|
||||
|
||||
/*ZeroMemory(&pp, sizeof(pp));
|
||||
//ZeroMemory(&pp, sizeof(pp));
|
||||
pp.Windowed = TRUE;
|
||||
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
|
||||
MSG msg;
|
||||
ZeroMemory(&msg, sizeof(msg));
|
||||
//ZeroMemory(&msg, sizeof(msg));
|
||||
while (msg.message != WM_QUIT) {
|
||||
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
else {
|
||||
//TranslateMessage(&msg);
|
||||
//DispatchMessage(&msg);
|
||||
} else {
|
||||
// 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->EndScene();
|
||||
pDevice->Present(NULL, NULL, NULL, NULL);
|
||||
pDevice->Present(NULL, NULL, NULL, NULL);*/
|
||||
}
|
||||
}
|
||||
|
||||
sleep(5);
|
||||
// Clean up
|
||||
pDevice->Release();
|
||||
pD3D->Release();
|
||||
//pDevice->Release(); //causes a segfault
|
||||
//pD3D->Release();
|
||||
DestroyWindow(hWnd);
|
||||
return msg.wParam;*/
|
||||
//return msg.wParam;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user