Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

changing to imgui sdl - #9

Open
sumofat wants to merge 34 commits into
ThisDevDane:masterfrom
sumofat:vendor
Open

changing to imgui sdl#9
sumofat wants to merge 34 commits into
ThisDevDane:masterfrom
sumofat:vendor

Conversation

@sumofat

@sumofat sumofat commented Dec 8, 2021

Copy link
Copy Markdown

Switch examples to the odin's native vendor libraries

Comment thread impl/sdl/sdl.odin Outdated
sdl.get_window_size(window, &w, &h);
if sdl.get_window_flags(window) & u32(sdl.Window_Flags.Minimized) != 0 {
sdl.GetWindowSize(window, &w, &h);
if sdl.GetWindowFlags(window) & u32(sdl.WindowFlags.MINIMIZED) == 0 {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I suck at bit operations but changing the condition from != to == should be wrong?

@AaronGlazer AaronGlazer May 1, 2022

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "appears to work" but I think it's actually because WindowFlags.MINIMIZED == 6 when the mask should be 1 << 6.

WindowFlag is the enum, WindowFlags (with an s) is the bit_set of WindowFlag. If GetWindowFlags returned WindowFlags you would expect .MINIMIZED in sdl.GetWindowFlags(window) to work here. So maybe for the time being it can just be casted?

Comment thread impl/opengl/opengl.odin Outdated
ok: i32;
gl.GetProgramiv(program_h, gl.LINK_STATUS, &ok);
if ok != gl.TRUE {
if ok != 1/*i32(gl.TRUE)*/ {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove the comments

Comment thread impl/opengl/opengl.odin Outdated
ok: i32;
gl.GetShaderiv(h, gl.COMPILE_STATUS, &ok);
if ok != gl.TRUE {
if ok != 1/*gl.TRUE*/ {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove the comments

Comment thread impl/opengl/opengl.odin Outdated
gl.VertexAttribPointer(u32(state.attrib_vtx_pos), 2, gl.FLOAT, gl.FALSE, size_of(imgui.Draw_Vert), rawptr(offset_of(imgui.Draw_Vert, pos)));
gl.VertexAttribPointer(u32(state.attrib_vtx_uv), 2, gl.FLOAT, gl.FALSE, size_of(imgui.Draw_Vert), rawptr(offset_of(imgui.Draw_Vert, uv)));
gl.VertexAttribPointer(u32(state.attrib_vtx_color), 4, gl.UNSIGNED_BYTE, gl.TRUE, size_of(imgui.Draw_Vert), rawptr(offset_of(imgui.Draw_Vert, col)));
gl.VertexAttribPointer(u32(state.attrib_vtx_pos), 2, gl.FLOAT, gl.FALSE, size_of(imgui.Draw_Vert), uintptr(rawptr(offset_of(imgui.Draw_Vert, pos))));

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember if offset_of doesn't already just output a uintptr or maybe can be directly cast to one?

Comment thread impl/sdl/sdl.odin
io.key_map[imgui.Key.Space] = i32(sdl.Scancode.SPACE);
io.key_map[imgui.Key.Enter] = i32(sdl.Scancode.RETURN);
io.key_map[imgui.Key.Escape] = i32(sdl.Scancode.ESCAPE);
io.key_map[imgui.Key.KeyPadEnter] = i32(sdl.Scancode.KP_ENTER);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the enums in this file, the package and enum name could be elided.

@sumofat

sumofat commented Jan 26, 2022

Copy link
Copy Markdown
Author

I just now notice that you guys have been reviewing this. Somehow missed it.
I will implement your guys suggestions in due time. Thanks!

@sumofat

sumofat commented Apr 25, 2022

Copy link
Copy Markdown
Author

Just I revistd this to get my osx working with odin-imgui and I fixed a bunch of errors. I also noticed on OSX there is a huge issue where it simply wont work out of the box because shaders require a version but you might chose a different version when starting up the context.

I had to setup shader error logging to finally figure what was causing my opengl to error out on osx.

So... I think that needs to be addressed honestly. Perhaps Ill just note it somewhere.

@sumofat
sumofat marked this pull request as ready for review May 1, 2022 03:10
@sumofat

sumofat commented May 1, 2022

Copy link
Copy Markdown
Author

@ThisDrunkDane @Ldash4 @hstormo @sduman Please review these changes that I have implemented!!

Comment thread impl/sdl/sdl.odin Outdated
Comment on lines +116 to +118
io.mouse_down[0] = state.mouse_down[0] || (buttons & u32(sdl.BUTTON_LEFT)) != 0;
io.mouse_down[1] = state.mouse_down[1] || (buttons & u32(sdl.BUTTON_RIGHT)) != 0;
io.mouse_down[2] = state.mouse_down[2] || (buttons & u32(sdl.BUTTON_MIDDLE)) != 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In testing I found this to be incorrect, this needs to be changed to BUTTON_LMASK, BUTTON_RMASK and BUTTON_MMASK.

@sumofat

sumofat commented May 6, 2022

Copy link
Copy Markdown
Author

Bump

NoahR02 and others added 4 commits May 7, 2022 22:03
Adds example for using multiple fonts in imgui.
Adds helper function for loading in a font with opengl.
# Conflicts:
#	foreign.odin
#	impl/opengl/opengl.odin
// qe := sdl.Event{};
// qe.type = .Quit;
// sdl.push_event(&qe);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line needs to be commented out too, otherwise it introduces syntax errors.

(while I also not sure that this "commenting out" actually should be included in the PR, perhaps these are some forgotten "debug" changes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants