Jump to content

CreateMenu()


Alienhead
 Share

Go to solution Solved by Josh,

Recommended Posts

  • 2 weeks later...

Menus might not work correctly with a 3D interface because all their submenus are created as separate windows. For an interface like you are showing here, or like the level editor has, I recommend using the first setup example here:
https://www.ultraengine.com/learn/CreateInterface

The menu widget is meant more for applications than games.

You can then create a borderless child window for the viewport, parented to your main window, using WINDOW_CHILD for the window style. This is how any WIndows program that shows the WIn32 GUI with a 3D rendering viewport works.

The last step is you need to detect window size events, and resize the viewport window whenever the main window is resized using Window:SetShape(). This is best done in an event callback so the viewport window will resize as you are dragging the window edges.

This will give you menus that appear on top of the 3D window, a more responsive interface, faster window resizing, and better text rendering.

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

What language are you developing this program in? I can probably put together an example quickly that shows the recommended setup.

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

  • Solution

For the reasons listed, I am changing it so CreateMenu will return NULL if the interface it is on was not created directly on a window.

If you would like help with the recommend UI setup please tell me the programming language you are using.

A note of this has been added in the documentation.

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

--Get the displays
local displays = GetDisplays()

--Create window
local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1], WINDOW_TITLEBAR | WINDOW_CENTER)

--Create user interface
local ui = CreateInterface(window)

--Create widget
local sz = ui.background:ClientSize()
local button = CreateButton("Button", sz.x / 2 - 75, sz.y / 2 - 15, 150, 30, ui.background)

sz = window:ClientSize()
local viewport = CreateWindow("Viewport", 50, 50, sz.x - 100, sz.y - 100, window, WINDOW_CHILD)

local framebuffer = CreateFramebuffer(viewport)
local world = CreateWorld()
local camera = CreateCamera(world)
camera:SetClearColor(0,0,1)

while (true) do
    local ev = WaitEvent()
    if (ev.id == EVENT_WINDOWCLOSE and ev.source == window) then
        return 0
    elseif ev.id == EVENT_WINDOWPAINT then
        world:Render(framebuffer)
    end
end

 

  • Thanks 1

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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...