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

changing to imgui sdl #9

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open

changing to imgui sdl #9

wants to merge 34 commits into from

Conversation

sumofat
Copy link

@sumofat sumofat commented Dec 8, 2021

Switch examples to the odin's native vendor libraries

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
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?

Copy link

@AaronGlazer AaronGlazer May 1, 2022

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?

@@ -249,7 +249,7 @@ setup_imgui_shaders :: proc() -> u32 {

ok: i32;
gl.GetProgramiv(program_h, gl.LINK_STATUS, &ok);
if ok != gl.TRUE {
if ok != 1/*i32(gl.TRUE)*/ {
Copy link
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

gl.ShaderSource(h, 1, &data, nil);
gl.CompileShader(h);
ok: i32;
gl.GetShaderiv(h, gl.COMPILE_STATUS, &ok);
if ok != gl.TRUE {
if ok != 1/*gl.TRUE*/ {
Copy link
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

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
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?

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
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
Copy link
Author

sumofat commented Jan 26, 2022

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
Copy link
Author

sumofat commented Apr 25, 2022

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
Copy link
Author

sumofat commented May 1, 2022

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

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;

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
Copy link
Author

sumofat commented May 6, 2022

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
// if is_key_down(e, .Escape) {
// qe := sdl.Event{};
// qe.type = .Quit;
// sdl.push_event(&qe);
}
Copy link

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