Robert_d1968 Posted March 17, 2021 Author Share Posted March 17, 2021 I do not know enough about C++ to help you with that problem, as of yet. Robert 1 Quote Link to comment Share on other sites More sharing options...
SlipperyBrick Posted March 17, 2021 Share Posted March 17, 2021 The OpenGL example code doesn't work out of the box in the documentation. You'll probably get this kind of result ... I'd recommend adjusting to this ... #include "UltraEngine.h" #include <GL/GL.h> #pragma comment (lib, "opengl32.lib") using namespace UltraEngine; bool ResizeViewport(const Event& ev, shared_ptr<Object> extra) { if (ev.id == EVENT_WINDOWSIZE) { auto window = ev.source->As<Window>(); iVec2 sz = window->ClientSize(); auto subwindow = extra->As<Window>(); subwindow->SetShape(200, 8, sz.x - 200 - 8, sz.y - 16); } return true; } int main(int argc, const char* argv[]) { //Get the available displays auto displays = ListDisplays(); //Create a window auto window = CreateWindow("OpenGL Example", 0, 0, 800, 600, displays[0], WINDOW_TITLEBAR | WINDOW_RESIZABLE); //Create user interface auto ui = CreateInterface(window); iVec2 sz = ui->root->ClientSize(); auto treeview = CreateTreeView(8, 8, 200 - 16, sz.y - 16, ui->root); treeview->SetLayout(1, 0, 1, 1); treeview->root->AddNode("Object 1"); treeview->root->AddNode("Object 2"); treeview->root->AddNode("Object 3"); //Create viewport window auto subwindow = CreateWindow("", 200, 8, sz.x - 200 - 8, sz.y - 16, window, WINDOW_EMBEDDED); //Adjust the viewport size when main window resized ListenEvent(EVENT_WINDOWSIZE, window, ResizeViewport, subwindow); //Initialize OpenGL context HWND hwnd = (HWND)(subwindow->GetHandle()); HDC hdc = GetDC(hwnd); PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, // Flags PFD_TYPE_RGBA, // The kind of framebuffer. RGBA or palette. 32, // Colordepth of the framebuffer. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, // Number of bits for the depthbuffer 8, // Number of bits for the stencilbuffer 0, // Number of Aux buffers in the framebuffer. PFD_MAIN_PLANE, 0, 0, 0, 0 }; int format = ChoosePixelFormat(hdc, &pfd); if (SetPixelFormat(hdc, format, &pfd) == 0) RuntimeError("SetPixelFormat() failed."); HGLRC glcontext = wglCreateContext(hdc); if (glcontext == NULL) RuntimeError("wglCreateContext() failed."); wglMakeCurrent(hdc, glcontext); while (true) { //Check for events const Event ev = WaitEvent(); switch (ev.id) { case EVENT_WINDOWPAINT: if (ev.source == subwindow) { iVec2 sz = subwindow->ClientSize(); glViewport(0, 0, sz.x, sz.y); glClearColor(0.0f, 0.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SwapBuffers(hdc); } break; case EVENT_WINDOWCLOSE: if (ev.source == window) return 0; break; } } return 0; } The issues I found in the code example were GetHandle returns a void * so a cast to HWND was required to get the window handle. Also the format parameter for SetPixelFormat was hard-coded to a value of 1. According to MS documentation it is best practice to get the available match of pixel format for the device context by calling ChoosePixelFormat. And the enum in the code example for the creation of subwindow was WINDOW_CHILD, this isn't included in the current build of UAK (maybe in beta, I have no idea ?) so I used WINDOW_EMBEDDED instead. I also changed what window calls ClientSize in the render loop, subwindow now calls ClientSize instead of window which results in the correct size being handed to the viewport. 2 Quote Link to comment Share on other sites More sharing options...
SlipperyBrick Posted March 17, 2021 Share Posted March 17, 2021 Can't wait to dive into this more when I have more time, its very promising (way cooler than IMGUI or any other GUI library I've come across). Although for the sake of cleanliness it would be great to have redundant includes and dependencies removed from the source. I've been trying to link and include UAK in my own project (as opposed to using the launcher to generate a project for me) and it is a nightmare having to go through and remove the excess stuff that isn't used, I've spent a good few hours perusing around various header files removing includes myself. This may be just me and everyone else is ok with this but I like to setup my projects myself as I have complete control over my build configurations, what includes and dependencies I use, as well as general control over my project structure. 1 Quote Link to comment Share on other sites More sharing options...
Josh Posted March 17, 2021 Share Posted March 17, 2021 I will have an update out later today. 2 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SlipperyBrick Posted March 17, 2021 Share Posted March 17, 2021 I gotta say though man, fantastic work! Such a clean API. Your definitely right about the resizing too, this ****s rapid! My window is resizing before I even click it, that's how quick it is, lightening speed! ? And the DPI scaling mwah! I'll for sure be using this as a frontend solution for my University major project and any other desktop applications I create. I've already been recommending it to my fellow programmer pals. 2 Quote Link to comment Share on other sites More sharing options...
Josh Posted March 17, 2021 Share Posted March 17, 2021 I am adding some additional information here . See "Adding to an Existing Project": https://www.ultraengine.com/learn/CPP/Introduction I guess this won't work with LE4 unless a 32-bit build is created, which I was not planning but maybe we can add that. 1 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
SlipperyBrick Posted March 17, 2021 Share Posted March 17, 2021 (edited) Where can I buy UAK? I want to get my mate a copy but can't find it on Steam (I purchased when backing it on kickstarter) EDIT: Just noticed the store button, I'm an idiot ? Edited March 17, 2021 by SlipperyBrick I'm an idiot Quote Link to comment Share on other sites More sharing options...
Josh Posted March 17, 2021 Share Posted March 17, 2021 1 hour ago, SlipperyBrick said: Where can I buy UAK? I want to get my mate a copy but can't find it on Steam (I purchased when backing it on kickstarter) EDIT: Just noticed the store button, I'm an idiot ? Steam keys were sent out to backers. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Robert_d1968 Posted March 20, 2021 Author Share Posted March 20, 2021 Is it possible to load my 4.6 map into the Ultra Engine Application? Thanks for any help that you can provide, Robert Quote Link to comment Share on other sites More sharing options...
Josh Posted March 20, 2021 Share Posted March 20, 2021 The Ultra Engine beta does load Leadwerks map files, but Ultra App Kit does not have any 3D capabilities. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Robert_d1968 Posted March 20, 2021 Author Share Posted March 20, 2021 (edited) I also tried out the OpenGL on two computers both computers were Alienware's None would display a thing in the box for the Display to be drawn in.. On my alienware it has the gforce 880M video card, it works great with lead werks. But I see, that Windows 10 seems to have problems with AMD graphics drivers and I did notice alot of AMD stuff in that program. Robert Edited March 20, 2021 by Robert_d1968 a misspelled word to correct Quote Link to comment Share on other sites More sharing options...
Robert_d1968 Posted March 20, 2021 Author Share Posted March 20, 2021 I also tried the second one, same thing for both versions. No graphics at all being drawn anywhere on the screen. Robert Quote Link to comment Share on other sites More sharing options...
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.