2023-07-21 00:35:39 -03:00
|
|
|
/**
|
|
|
|
* Windows API codes were commented to focus
|
|
|
|
* on what's important: OpenDX.
|
|
|
|
*
|
|
|
|
* Code that doesn't work is also commented.
|
|
|
|
*/
|
2023-07-29 21:03:57 -03:00
|
|
|
#include <opendx.h>
|
|
|
|
#include <winuser.h>
|
2023-07-21 00:35:39 -03:00
|
|
|
#include <d3d9.h>
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
|
|
|
|
// Create the window
|
2023-07-29 21:03:57 -03:00
|
|
|
HWND hWnd = CreateWindow(
|
|
|
|
"DX9 Window", "DX9 Window",
|
|
|
|
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
|
|
|
0, 0, 640, 480, NULL, NULL, hInstance, NULL
|
|
|
|
);
|
2023-07-21 00:35:39 -03:00
|
|
|
|
|
|
|
// Create the Direct3D device
|
|
|
|
LPDIRECT3D9 pD3D = Direct3DCreate9(D3D_SDK_VERSION);
|
|
|
|
LPDIRECT3DDEVICE9 pDevice = NULL;
|
|
|
|
D3DPRESENT_PARAMETERS pp;
|
2023-07-29 21:03:57 -03:00
|
|
|
|
2023-09-20 21:52:09 -03:00
|
|
|
//ZeroMemory(&pp, sizeof(pp));
|
2023-07-21 00:35:39 -03:00
|
|
|
pp.Windowed = TRUE;
|
|
|
|
pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
2023-09-20 21:52:09 -03:00
|
|
|
//pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &pp, &pDevice);
|
2023-07-21 00:35:39 -03:00
|
|
|
|
|
|
|
// Enter the message loop
|
|
|
|
MSG msg;
|
2023-09-20 21:52:09 -03:00
|
|
|
//ZeroMemory(&msg, sizeof(msg));
|
2023-07-21 00:35:39 -03:00
|
|
|
while (msg.message != WM_QUIT) {
|
|
|
|
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
2023-09-20 21:52:09 -03:00
|
|
|
//TranslateMessage(&msg);
|
|
|
|
//DispatchMessage(&msg);
|
|
|
|
} else {
|
2023-07-21 00:35:39 -03:00
|
|
|
// Render the scene
|
2023-09-20 21:52:09 -03:00
|
|
|
/*pDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);
|
2023-07-21 00:35:39 -03:00
|
|
|
pDevice->BeginScene();
|
|
|
|
pDevice->EndScene();
|
2023-09-20 21:52:09 -03:00
|
|
|
pDevice->Present(NULL, NULL, NULL, NULL);*/
|
2023-07-21 00:35:39 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-20 21:52:09 -03:00
|
|
|
sleep(5);
|
2023-07-21 00:35:39 -03:00
|
|
|
// Clean up
|
2023-09-20 21:52:09 -03:00
|
|
|
//pDevice->Release(); //causes a segfault
|
|
|
|
//pD3D->Release();
|
2023-07-21 00:35:39 -03:00
|
|
|
DestroyWindow(hWnd);
|
2023-09-20 21:52:09 -03:00
|
|
|
//return msg.wParam;
|
2023-07-21 00:35:39 -03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-07-29 21:03:57 -03:00
|
|
|
//Linux's main or MinGW's main:
|
2023-07-21 00:35:39 -03:00
|
|
|
int main(int argc, char* argv[]) {
|
2023-07-29 21:03:57 -03:00
|
|
|
//OpenDX transforms argc and argv to WinMain params
|
|
|
|
//then calls WinMain. You can also initialize OpenDX
|
|
|
|
//without params and insert your code right here if
|
|
|
|
//you are using MinGW.
|
|
|
|
OpenDX odx(argc, argv,WinMain); //or OpenDX odx();
|
2023-07-21 00:35:39 -03:00
|
|
|
|
2023-07-29 21:03:57 -03:00
|
|
|
return odx.getReturnCode(); // 0 if WinMain is not passed.
|
2023-07-21 00:35:39 -03:00
|
|
|
}
|