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

69 lines
2.0 KiB
C++
Raw Normal View History

/**
* 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>
#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
);
// 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));
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);
// Enter the message loop
MSG msg;
2023-09-20 21:52:09 -03:00
//ZeroMemory(&msg, sizeof(msg));
while (msg.message != WM_QUIT) {
2023-10-08 01:51:42 -03:00
if (PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE)) {
2023-09-20 21:52:09 -03:00
//TranslateMessage(&msg);
//DispatchMessage(&msg);
} else {
// 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);
pDevice->BeginScene();
pDevice->EndScene();
2023-09-20 21:52:09 -03:00
pDevice->Present(NULL, NULL, NULL, NULL);*/
}
}
2023-09-20 21:52:09 -03:00
sleep(5);
// Clean up
2023-09-20 21:52:09 -03:00
//pDevice->Release(); //causes a segfault
//pD3D->Release();
DestroyWindow(hWnd);
2023-09-20 21:52:09 -03:00
//return msg.wParam;
return 0;
}
2023-07-29 21:03:57 -03:00
//Linux's main or MinGW's main:
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-29 21:03:57 -03:00
return odx.getReturnCode(); // 0 if WinMain is not passed.
}