Vida Marcell Posted September 17, 2022 Posted September 17, 2022 I'm trying to make a Directx 9 context in UAK based on this tutorial: http://www.directxtutorial.com/Lesson.aspx?lessonid=9-4-1 And so far so good, but then this happens: (this is the only syntax problem) here is my code: #include "UltraEngine.h" #include <d3d9.h> using namespace UltraEngine; // include the Direct3D Library file #pragma comment (lib, "d3d9.lib") // global declarations LPDIRECT3D9 d3d; LPDIRECT3DDEVICE9 d3ddev; // function prototypes void initD3D(HWND hWnd); void render_frame(void); void cleanD3D(void); // Callback function for resizing the viewport bool ResizeViewport(const Event& ev, shared_ptr<Object> extra) { // If the window resize event is captured auto window = ev.source->As<Window>(); // Get the new size of the applications window iVec2 sz = window->ClientSize(); return true; } int main(int argc, const char* argv[]) { HWND hWnd; // Get the available displays auto displays = GetDisplays(); // Create a window auto window = CreateWindow("OpenGL Example", 0, 0, 800, 600, displays[0], WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_CENTER); // Create user interface auto ui = CreateInterface(window); // Get the size of the user-interface iVec2 sz = ui->root->ClientSize(); // Initialize an OpenGL context (get a hdc) HWND hwnd = (HWND)(window->GetHandle()); HDC hdc = GetDC(hwnd); // set up and initialize Direct3D initD3D(hWnd); // Render loop (applications run loop) while (true) { // Check for events const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WINDOWPAINT: if (ev.source == window) { // Get and set the current size of the viewport iVec2 sz = window->ClientSize(); if (sz.x < 1 or sz.y < 1) break; HWND hwnd = window->GetHandle(); auto hdc = GetDC(hwnd); SwapBuffers(hdc); ReleaseDC(hwnd, hdc); } break; case EVENT_WINDOWCLOSE: if (ev.source == window) { return 0; } break; } render_frame(); } // clean up DirectX and COM cleanD3D(); // this function initializes and prepares Direct3D for use void initD3D(HWND hWnd) { d3d = Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use d3dpp.Windowed = TRUE; // program windowed, not fullscreen d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames d3dpp.hDeviceWindow = hWnd; // set the window to be used by Direct3D // create a device class using this information and the info from the d3dpp stuct d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev); } // this is the function used to render a single frame void render_frame(void) { // clear the window to a deep blue d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0); d3ddev->BeginScene(); // begins the 3D scene // do 3D rendering on the back buffer here d3ddev->EndScene(); // ends the 3D scene d3ddev->Present(NULL, NULL, NULL, NULL); // displays the created frame on the screen } // this is the function that cleans up Direct3D and COM void cleanD3D(void) { d3ddev->Release(); // close and release the 3D device d3d->Release(); // close and release Direct3D } return 0; } Quote
Vida Marcell Posted September 17, 2022 Author Posted September 17, 2022 I cannot belive this, i managed to sucess it!! 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.