imgui-bindings 0.0.1 → 0.0.2.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a082a4e2a2123c2b36ed60baa84f1baa37950b939ddd35dfaf502952b885e7fd
4
- data.tar.gz: 1ee2ad564ded03c54f72a949eaebf75d8ac51b3473c4ee5741225f147e38cfb6
3
+ metadata.gz: d7b45550f223f0cedd9d8f543e6d25bcc4988ab0bc59df341c527d0e0907f9a5
4
+ data.tar.gz: 4e48bb054f108f73e12777761a9d0b6eada3782ba76e437aaa9d848b69736294
5
5
  SHA512:
6
- metadata.gz: eba0adbca28f18809557c90d61be40444f0d21e61a0bbb9c0817bfa07c21aaf43c2e8b23861e2f420d148bada23f522cffb11a2c37540a3e51e56e010a452b03
7
- data.tar.gz: 8eff191cbdcba86263e7c96cd213da34a1aea4cf980233a54d1a3df9d68b4c14397869b47cb769c0349c10298afbe2c57a70e23bf061208ff909b004c16c8107
6
+ metadata.gz: 238d51745983ded557d6d6e84effcbf70c18f7684e398e456cb168f85bde9ed10f16118b0dee60eb5b32773310edb2915681620221caf360f62e12dd9c298327
7
+ data.tar.gz: 1798e2c878227420b20cafa91ec98e4d272bdce78b7c4be2cc08f9b52b46fe9d73c60c508af88ed99a137f6e054f6af97f70640eb8ff48c6c0a4bea82ee9c333
data/ChangeLog CHANGED
@@ -1,3 +1,15 @@
1
+ 2022-01-08 vaiorabbit <http://twitter.com/vaiorabbit>
2
+
3
+ * imgui_impl_raylib.rb: Added. Use this with Ruby raylib-bindings ( https://github.com/vaiorabbit/raylib-bindings )
4
+
5
+ 2022-01-07 vaiorabbit <http://twitter.com/vaiorabbit>
6
+
7
+ * Use opengl-bindings2
8
+
9
+ 2022-01-01 vaiorabbit <http://twitter.com/vaiorabbit>
10
+
11
+ * imgui-bindings.gemspec: Added
12
+
1
13
  2021-12-31 vaiorabbit <http://twitter.com/vaiorabbit>
2
14
 
3
15
  * Added setup_dll.rb etc. for automatic library loading
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  # Yet another ImGui wrapper for Ruby #
4
4
 
5
5
  * Created : 2019-01-05
6
- * Last modified : 2021-12-31
6
+ * Last modified : 2022-01-08
7
7
 
8
8
  <img src="https://raw.githubusercontent.com/vaiorabbit/ruby-imgui/master/doc/jpfont_test.png" width="250">
9
9
 
@@ -18,8 +18,9 @@
18
18
  * ~~ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]~~
19
19
  * ~~ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x64-mingw32]~~
20
20
  * [macOS]
21
+ * ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [arm64-darwin20]
21
22
  * ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]
22
- * ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [arm64-darwin20]
23
+ * ~~ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [arm64-darwin20]~~
23
24
  * ~~ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin20]~~
24
25
  * ~~ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin19]~~
25
26
  * ~~ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]~~
@@ -68,7 +69,7 @@
68
69
  All ruby codes here are available under the terms of the zlib/libpng License ( http://opensource.org/licenses/Zlib ).
69
70
 
70
71
  Ruby-Imgui : Yet another ImGui wrapper for Ruby
71
- Copyright (c) 2019-2021 vaiorabbit <http://twitter.com/vaiorabbit>
72
+ Copyright (c) 2019-2022 vaiorabbit <http://twitter.com/vaiorabbit>
72
73
 
73
74
  This software is provided 'as-is', without any express or implied
74
75
  warranty. In no event will the authors be held liable for any damages
@@ -27,7 +27,7 @@ module ImGui
27
27
  userfunc.call(window, button, action, mods)
28
28
  end
29
29
 
30
- if action == GLFW_PRESS && button >= 0 && button < @@g_MouseJustPressed.size
30
+ if action == GLFW::PRESS && button >= 0 && button < @@g_MouseJustPressed.size
31
31
  @@g_MouseJustPressed[button] = true
32
32
  end
33
33
  end
@@ -50,14 +50,14 @@ module ImGui
50
50
  end
51
51
 
52
52
  io = ImGuiIO.new(ImGui::GetIO())
53
- io[:KeysDown][key] = true if action == GLFW_PRESS
54
- io[:KeysDown][key] = false if action == GLFW_RELEASE
53
+ io[:KeysDown][key] = true if action == GLFW::PRESS
54
+ io[:KeysDown][key] = false if action == GLFW::RELEASE
55
55
 
56
56
  # Modifiers are not reliable across systems
57
- io[:KeyCtrl] = io[:KeysDown][GLFW_KEY_LEFT_CONTROL] || io[:KeysDown][GLFW_KEY_RIGHT_CONTROL]
58
- io[:KeyShift] = io[:KeysDown][GLFW_KEY_LEFT_SHIFT] || io[:KeysDown][GLFW_KEY_RIGHT_SHIFT]
59
- io[:KeyAlt] = io[:KeysDown][GLFW_KEY_LEFT_ALT] || io[:KeysDown][GLFW_KEY_RIGHT_ALT]
60
- io[:KeySuper] = io[:KeysDown][GLFW_KEY_LEFT_SUPER] || io[:KeysDown][GLFW_KEY_RIGHT_SUPER]
57
+ io[:KeyCtrl] = io[:KeysDown][GLFW::KEY_LEFT_CONTROL] || io[:KeysDown][GLFW::KEY_RIGHT_CONTROL]
58
+ io[:KeyShift] = io[:KeysDown][GLFW::KEY_LEFT_SHIFT] || io[:KeysDown][GLFW::KEY_RIGHT_SHIFT]
59
+ io[:KeyAlt] = io[:KeysDown][GLFW::KEY_LEFT_ALT] || io[:KeysDown][GLFW::KEY_RIGHT_ALT]
60
+ io[:KeySuper] = io[:KeysDown][GLFW::KEY_LEFT_SUPER] || io[:KeysDown][GLFW::KEY_RIGHT_SUPER]
61
61
  end
62
62
 
63
63
  @@ImGui_ImplGlfw_CursorEnterCallback = GLFW::create_callback(:GLFWcursorenterfun) do |window, entered|
@@ -84,11 +84,11 @@ module ImGui
84
84
  io = ImGuiIO.new(ImGui::GetIO())
85
85
  io[:MouseDown].size.times do |i|
86
86
  # If a mouse press event came, always pass it as "mouse held this frame", so we don't miss click-release events that are shorter than 1 frame.
87
- io[:MouseDown][i] = (@@g_MouseJustPressed[i] || glfwGetMouseButton(@@g_Window, i) != 0)
87
+ io[:MouseDown][i] = (@@g_MouseJustPressed[i] || GLFW.GetMouseButton(@@g_Window, i) != 0)
88
88
  @@g_MouseJustPressed[i] = false
89
89
  end
90
90
 
91
- focused = glfwGetWindowAttrib(@@g_Window, GLFW_FOCUSED) != 0
91
+ focused = GLFW.GetWindowAttrib(@@g_Window, GLFW::FOCUSED) != 0
92
92
  mouse_window = (@@g_MouseWindow == @@g_Window || focused) ? @@g_Window : nil
93
93
 
94
94
  # Update mouse position
@@ -97,12 +97,12 @@ module ImGui
97
97
  io[:MousePos][:y] = -Float::MAX
98
98
  if io[:WantSetMousePos]
99
99
  if focused
100
- glfwSetCursorPos(@@g_Window, mouse_pos_backup[:x].to_f, mouse_pos_backup[:y].to_f)
100
+ GLFW.SetCursorPos(@@g_Window, mouse_pos_backup[:x].to_f, mouse_pos_backup[:y].to_f)
101
101
  end
102
102
  elsif @@g_MouseWindow != nil
103
103
  mouse_x = ' ' * 8
104
104
  mouse_y = ' ' * 8
105
- glfwGetCursorPos(@@g_Window, mouse_x, mouse_y)
105
+ GLFW.GetCursorPos(@@g_Window, mouse_x, mouse_y)
106
106
  io[:MousePos][:x] = mouse_x.unpack1('d')
107
107
  io[:MousePos][:y] = mouse_y.unpack1('d')
108
108
  end
@@ -110,17 +110,17 @@ module ImGui
110
110
 
111
111
  def self.ImplGlfw_UpdateMouseCursor()
112
112
  io = ImGuiIO.new(ImGui::GetIO())
113
- return if ((io[:ConfigFlags] & ImGuiConfigFlags_NoMouseCursorChange) || glfwGetInputMode(@@g_Window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED)
113
+ return if ((io[:ConfigFlags] & ImGuiConfigFlags_NoMouseCursorChange) || GLFW.GetInputMode(@@g_Window, GLFW::CURSOR) == GLFW::CURSOR_DISABLED)
114
114
 
115
115
  imgui_cursor = ImGui::GetMouseCursor()
116
116
  if imgui_cursor == ImGuiMouseCursor_None || io[:MouseDrawCursor]
117
117
  # Hide OS mouse cursor if imgui is drawing it or if it wants no cursor
118
- glfwSetInputMode(@@g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN)
118
+ GLFW.SetInputMode(@@g_Window, GLFW::CURSOR, GLFW::CURSOR_HIDDEN)
119
119
  else
120
120
  # Show OS mouse cursor
121
121
  # FIXME-PLATFORM: Unfocused windows seems to fail changing the mouse cursor with GLFW 3.2, but 3.3 works here.
122
- glfwSetCursor(@@g_Window, @@g_MouseCursors[imgui_cursor] ? @@g_MouseCursors[imgui_cursor] : @@g_MouseCursors[ImGuiMouseCursor_Arrow])
123
- glfwSetInputMode(@@g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL)
122
+ GLFW.SetCursor(@@g_Window, @@g_MouseCursors[imgui_cursor] ? @@g_MouseCursors[imgui_cursor] : @@g_MouseCursors[ImGuiMouseCursor_Arrow])
123
+ GLFW.SetInputMode(@@g_Window, GLFW::CURSOR, GLFW::CURSOR_NORMAL)
124
124
  end
125
125
  end
126
126
 
@@ -130,7 +130,7 @@ module ImGui
130
130
 
131
131
  def self.ImplGlfw_Shutdown()
132
132
  ImGuiMouseCursor_COUNT.times do |cursor_n|
133
- glfwDestroyCursor(@@g_MouseCursors[cursor_n])
133
+ GLFW.DestroyCursor(@@g_MouseCursors[cursor_n])
134
134
  @@g_MouseCursors[cursor_n] = nil
135
135
  end
136
136
  end
@@ -146,8 +146,8 @@ module ImGui
146
146
  h = ' ' * 4
147
147
  display_w = ' ' * 4
148
148
  display_h = ' ' * 4
149
- glfwGetWindowSize(@@g_Window, w, h)
150
- glfwGetFramebufferSize(@@g_Window, display_w, display_h)
149
+ GLFW.GetWindowSize(@@g_Window, w, h)
150
+ GLFW.GetFramebufferSize(@@g_Window, display_w, display_h)
151
151
 
152
152
  w = w.unpack1('L')
153
153
  h = h.unpack1('L')
@@ -160,7 +160,7 @@ module ImGui
160
160
  end
161
161
 
162
162
  # Setup time step
163
- current_time = glfwGetTime()
163
+ current_time = GLFW.GetTime()
164
164
  io[:DeltaTime] = @@g_Time > 0.0 ? (current_time - @@g_Time).to_f : (1.0/60.0)
165
165
  @@g_Time = current_time
166
166
 
@@ -181,28 +181,28 @@ module ImGui
181
181
  io[:BackendPlatformName] = @@g_BackendPlatformName
182
182
 
183
183
  # Keyboard mapping. ImGui will use those indices to peek into the io.KeysDown[] array.
184
- io[:KeyMap][ImGuiKey_Tab] = GLFW_KEY_TAB
185
- io[:KeyMap][ImGuiKey_LeftArrow] = GLFW_KEY_LEFT
186
- io[:KeyMap][ImGuiKey_RightArrow] = GLFW_KEY_RIGHT
187
- io[:KeyMap][ImGuiKey_UpArrow] = GLFW_KEY_UP
188
- io[:KeyMap][ImGuiKey_DownArrow] = GLFW_KEY_DOWN
189
- io[:KeyMap][ImGuiKey_PageUp] = GLFW_KEY_PAGE_UP
190
- io[:KeyMap][ImGuiKey_PageDown] = GLFW_KEY_PAGE_DOWN
191
- io[:KeyMap][ImGuiKey_Home] = GLFW_KEY_HOME
192
- io[:KeyMap][ImGuiKey_End] = GLFW_KEY_END
193
- io[:KeyMap][ImGuiKey_Insert] = GLFW_KEY_INSERT
194
- io[:KeyMap][ImGuiKey_Delete] = GLFW_KEY_DELETE
195
- io[:KeyMap][ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE
196
- io[:KeyMap][ImGuiKey_Space] = GLFW_KEY_SPACE
197
- io[:KeyMap][ImGuiKey_Enter] = GLFW_KEY_ENTER
198
- io[:KeyMap][ImGuiKey_Escape] = GLFW_KEY_ESCAPE
199
- io[:KeyMap][ImGuiKey_KeyPadEnter] = GLFW_KEY_KP_ENTER
200
- io[:KeyMap][ImGuiKey_A] = GLFW_KEY_A
201
- io[:KeyMap][ImGuiKey_C] = GLFW_KEY_C
202
- io[:KeyMap][ImGuiKey_V] = GLFW_KEY_V
203
- io[:KeyMap][ImGuiKey_X] = GLFW_KEY_X
204
- io[:KeyMap][ImGuiKey_Y] = GLFW_KEY_Y
205
- io[:KeyMap][ImGuiKey_Z] = GLFW_KEY_Z
184
+ io[:KeyMap][ImGuiKey_Tab] = GLFW::KEY_TAB
185
+ io[:KeyMap][ImGuiKey_LeftArrow] = GLFW::KEY_LEFT
186
+ io[:KeyMap][ImGuiKey_RightArrow] = GLFW::KEY_RIGHT
187
+ io[:KeyMap][ImGuiKey_UpArrow] = GLFW::KEY_UP
188
+ io[:KeyMap][ImGuiKey_DownArrow] = GLFW::KEY_DOWN
189
+ io[:KeyMap][ImGuiKey_PageUp] = GLFW::KEY_PAGE_UP
190
+ io[:KeyMap][ImGuiKey_PageDown] = GLFW::KEY_PAGE_DOWN
191
+ io[:KeyMap][ImGuiKey_Home] = GLFW::KEY_HOME
192
+ io[:KeyMap][ImGuiKey_End] = GLFW::KEY_END
193
+ io[:KeyMap][ImGuiKey_Insert] = GLFW::KEY_INSERT
194
+ io[:KeyMap][ImGuiKey_Delete] = GLFW::KEY_DELETE
195
+ io[:KeyMap][ImGuiKey_Backspace] = GLFW::KEY_BACKSPACE
196
+ io[:KeyMap][ImGuiKey_Space] = GLFW::KEY_SPACE
197
+ io[:KeyMap][ImGuiKey_Enter] = GLFW::KEY_ENTER
198
+ io[:KeyMap][ImGuiKey_Escape] = GLFW::KEY_ESCAPE
199
+ io[:KeyMap][ImGuiKey_KeyPadEnter] = GLFW::KEY_KP_ENTER
200
+ io[:KeyMap][ImGuiKey_A] = GLFW::KEY_A
201
+ io[:KeyMap][ImGuiKey_C] = GLFW::KEY_C
202
+ io[:KeyMap][ImGuiKey_V] = GLFW::KEY_V
203
+ io[:KeyMap][ImGuiKey_X] = GLFW::KEY_X
204
+ io[:KeyMap][ImGuiKey_Y] = GLFW::KEY_Y
205
+ io[:KeyMap][ImGuiKey_Z] = GLFW::KEY_Z
206
206
 
207
207
  # [TODO] Support ClipboardText & IME on Windows
208
208
  # io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
@@ -212,14 +212,14 @@ module ImGui
212
212
  # io.ImeWindowHandle = (void*)glfwGetWin32Window(g_Window);
213
213
  # #endif
214
214
 
215
- @@g_MouseCursors[ImGuiMouseCursor_Arrow] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR)
216
- @@g_MouseCursors[ImGuiMouseCursor_TextInput] = glfwCreateStandardCursor(GLFW_IBEAM_CURSOR)
217
- @@g_MouseCursors[ImGuiMouseCursor_ResizeAll] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR) # FIXME: GLFW doesn't have this.
218
- @@g_MouseCursors[ImGuiMouseCursor_ResizeNS] = glfwCreateStandardCursor(GLFW_VRESIZE_CURSOR)
219
- @@g_MouseCursors[ImGuiMouseCursor_ResizeEW] = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR)
220
- @@g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR) # FIXME: GLFW doesn't have this.
221
- @@g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = glfwCreateStandardCursor(GLFW_ARROW_CURSOR) # FIXME: GLFW doesn't have this.
222
- @@g_MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR)
215
+ @@g_MouseCursors[ImGuiMouseCursor_Arrow] = GLFW.CreateStandardCursor(GLFW::ARROW_CURSOR)
216
+ @@g_MouseCursors[ImGuiMouseCursor_TextInput] = GLFW.CreateStandardCursor(GLFW::IBEAM_CURSOR)
217
+ @@g_MouseCursors[ImGuiMouseCursor_ResizeAll] = GLFW.CreateStandardCursor(GLFW::ARROW_CURSOR) # FIXME: GLFW doesn't have this.
218
+ @@g_MouseCursors[ImGuiMouseCursor_ResizeNS] = GLFW.CreateStandardCursor(GLFW::VRESIZE_CURSOR)
219
+ @@g_MouseCursors[ImGuiMouseCursor_ResizeEW] = GLFW.CreateStandardCursor(GLFW::HRESIZE_CURSOR)
220
+ @@g_MouseCursors[ImGuiMouseCursor_ResizeNESW] = GLFW.CreateStandardCursor(GLFW::ARROW_CURSOR) # FIXME: GLFW doesn't have this.
221
+ @@g_MouseCursors[ImGuiMouseCursor_ResizeNWSE] = GLFW.CreateStandardCursor(GLFW::ARROW_CURSOR) # FIXME: GLFW doesn't have this.
222
+ @@g_MouseCursors[ImGuiMouseCursor_Hand] = GLFW.CreateStandardCursor(GLFW::HAND_CURSOR)
223
223
 
224
224
  # Chain GLFW callbacks: our callbacks will call the user's previously installed callbacks, if any.
225
225
  @@g_PrevUserCallbackMousebutton = nil
@@ -227,11 +227,11 @@ module ImGui
227
227
  @@g_PrevUserCallbackKey = nil
228
228
  @@g_PrevUserCallbackChar = nil
229
229
  if install_callbacks
230
- @@g_PrevUserCallbackCursorEnter = glfwSetCursorEnterCallback(window, @@ImGui_ImplGlfw_CursorEnterCallback)
231
- @@g_PrevUserCallbackMousebutton = glfwSetMouseButtonCallback(window, @@ImplGlfw_MouseButtonCallback)
232
- @@g_PrevUserCallbackScroll = glfwSetScrollCallback(window, @@ImplGlfw_ScrollCallback)
233
- @@g_PrevUserCallbackKey = glfwSetKeyCallback(window, @@ImplGlfw_KeyCallback)
234
- @@g_PrevUserCallbackChar = glfwSetCharCallback(window, @@ImplGlfw_CharCallback)
230
+ @@g_PrevUserCallbackCursorEnter = GLFW.SetCursorEnterCallback(window, @@ImGui_ImplGlfw_CursorEnterCallback)
231
+ @@g_PrevUserCallbackMousebutton = GLFW.SetMouseButtonCallback(window, @@ImplGlfw_MouseButtonCallback)
232
+ @@g_PrevUserCallbackScroll = GLFW.SetScrollCallback(window, @@ImplGlfw_ScrollCallback)
233
+ @@g_PrevUserCallbackKey = GLFW.SetKeyCallback(window, @@ImplGlfw_KeyCallback)
234
+ @@g_PrevUserCallbackChar = GLFW.SetCharCallback(window, @@ImplGlfw_CharCallback)
235
235
  end
236
236
 
237
237
  return true
@@ -1,6 +1,5 @@
1
1
  require 'ffi'
2
2
  require 'opengl'
3
- include OpenGL
4
3
 
5
4
  require_relative 'imgui'
6
5
 
@@ -34,18 +33,18 @@ module ImGui
34
33
 
35
34
  # Backup GL state
36
35
  last_texture = ' ' * 4
37
- glGetIntegerv(GL_TEXTURE_BINDING_2D, last_texture)
36
+ GL.GetIntegerv(GL::TEXTURE_BINDING_2D, last_texture)
38
37
  last_polygon_mode = ' ' * 8
39
- glGetIntegerv(GL_POLYGON_MODE, last_polygon_mode)
38
+ GL.GetIntegerv(GL::POLYGON_MODE, last_polygon_mode)
40
39
  last_viewport = ' ' * 16
41
- glGetIntegerv(GL_VIEWPORT, last_viewport)
40
+ GL.GetIntegerv(GL::VIEWPORT, last_viewport)
42
41
  last_scissor_box = ' ' * 16
43
- glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box)
44
- glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT)
42
+ GL.GetIntegerv(GL::SCISSOR_BOX, last_scissor_box)
43
+ GL.PushAttrib(GL::ENABLE_BIT | GL::COLOR_BUFFER_BIT | GL::TRANSFORM_BIT)
45
44
  last_shade_model = ' ' * 4
46
- glGetIntegerv(GL_SHADE_MODEL, last_shade_model)
45
+ GL.GetIntegerv(GL::SHADE_MODEL, last_shade_model)
47
46
  last_tex_env_mode = ' ' * 4
48
- glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, last_tex_env_mode)
47
+ GL.GetTexEnviv(GL::TEXTURE_ENV, GL::TEXTURE_ENV_MODE, last_tex_env_mode)
49
48
 
50
49
  # Setup desired GL state
51
50
  ImplOpenGL2_SetupRenderState(draw_data, fb_width, fb_height)
@@ -59,9 +58,9 @@ module ImGui
59
58
  cmd_list = ImDrawList.new((draw_data[:CmdLists].pointer + 8 * n).read_pointer) # 8 == const ImDrawList*
60
59
  vtx_buffer = ImDrawVert.new(cmd_list[:VtxBuffer][:Data]) # const ImDrawVert*
61
60
  idx_buffer = cmd_list[:IdxBuffer][:Data] # const ImDrawIdx*
62
- glVertexPointer(2, GL_FLOAT, ImDrawVert.size, Fiddle::Pointer.new((cmd_list[:VtxBuffer][:Data] + vtx_buffer.offset_of(:pos))) )
63
- glTexCoordPointer(2, GL_FLOAT, ImDrawVert.size, Fiddle::Pointer.new((cmd_list[:VtxBuffer][:Data] + vtx_buffer.offset_of(:uv))) )
64
- glColorPointer(4, GL_UNSIGNED_BYTE, ImDrawVert.size, Fiddle::Pointer.new((cmd_list[:VtxBuffer][:Data] + vtx_buffer.offset_of(:col))) )
61
+ GL.VertexPointer(2, GL::FLOAT, ImDrawVert.size, Fiddle::Pointer.new((cmd_list[:VtxBuffer][:Data] + vtx_buffer.offset_of(:pos))) )
62
+ GL.TexCoordPointer(2, GL::FLOAT, ImDrawVert.size, Fiddle::Pointer.new((cmd_list[:VtxBuffer][:Data] + vtx_buffer.offset_of(:uv))) )
63
+ GL.ColorPointer(4, GL::UNSIGNED_BYTE, ImDrawVert.size, Fiddle::Pointer.new((cmd_list[:VtxBuffer][:Data] + vtx_buffer.offset_of(:col))) )
65
64
 
66
65
  cmd_list[:CmdBuffer][:Size].times do |cmd_i|
67
66
  pcmd = ImDrawCmd.new(cmd_list[:CmdBuffer][:Data] + ImDrawCmd.size * cmd_i) # const ImDrawCmd*
@@ -85,11 +84,11 @@ module ImGui
85
84
 
86
85
  if (clip_rect[:x] < fb_width && clip_rect[:y] < fb_height && clip_rect[:z] >= 0.0 && clip_rect[:w] >= 0.0)
87
86
  # Apply scissor/clipping rectangle
88
- glScissor(clip_rect[:x].to_i, (fb_height - clip_rect[:w]).to_i, (clip_rect[:z] - clip_rect[:x]).to_i, (clip_rect[:w] - clip_rect[:y]).to_i)
87
+ GL.Scissor(clip_rect[:x].to_i, (fb_height - clip_rect[:w]).to_i, (clip_rect[:z] - clip_rect[:x]).to_i, (clip_rect[:w] - clip_rect[:y]).to_i)
89
88
 
90
89
  # Bind texture, Draw
91
- glBindTexture(GL_TEXTURE_2D, pcmd[:TextureId].address)
92
- glDrawElements(GL_TRIANGLES, pcmd[:ElemCount], GL_UNSIGNED_SHORT, Fiddle::Pointer.new(idx_buffer.address))
90
+ GL.BindTexture(GL::TEXTURE_2D, pcmd[:TextureId].address)
91
+ GL.DrawElements(GL::TRIANGLES, pcmd[:ElemCount], GL::UNSIGNED_SHORT, Fiddle::Pointer.new(idx_buffer.address))
93
92
  end
94
93
 
95
94
  end
@@ -98,69 +97,69 @@ module ImGui
98
97
  end
99
98
 
100
99
  # Restore modified GL state
101
- glDisableClientState(GL_COLOR_ARRAY)
102
- glDisableClientState(GL_TEXTURE_COORD_ARRAY)
103
- glDisableClientState(GL_VERTEX_ARRAY)
104
- glBindTexture(GL_TEXTURE_2D, last_texture.unpack1('L'))
105
- glMatrixMode(GL_MODELVIEW)
106
- glPopMatrix()
107
- glMatrixMode(GL_PROJECTION)
108
- glPopMatrix()
109
- glPopAttrib()
100
+ GL.DisableClientState(GL::COLOR_ARRAY)
101
+ GL.DisableClientState(GL::TEXTURE_COORD_ARRAY)
102
+ GL.DisableClientState(GL::VERTEX_ARRAY)
103
+ GL.BindTexture(GL::TEXTURE_2D, last_texture.unpack1('L'))
104
+ GL.MatrixMode(GL::MODELVIEW)
105
+ GL.PopMatrix()
106
+ GL.MatrixMode(GL::PROJECTION)
107
+ GL.PopMatrix()
108
+ GL.PopAttrib()
110
109
  last_polygon_mode = last_polygon_mode.unpack('L2')
111
- glPolygonMode(GL_FRONT, last_polygon_mode[0])
112
- glPolygonMode(GL_BACK, last_polygon_mode[1])
110
+ GL.PolygonMode(GL::FRONT, last_polygon_mode[0])
111
+ GL.PolygonMode(GL::BACK, last_polygon_mode[1])
113
112
  last_viewport = last_viewport.unpack('L4')
114
- glViewport(last_viewport[0], last_viewport[1], last_viewport[2], last_viewport[3])
113
+ GL.Viewport(last_viewport[0], last_viewport[1], last_viewport[2], last_viewport[3])
115
114
  last_scissor_box = last_scissor_box.unpack('L4')
116
- glScissor(last_scissor_box[0], last_scissor_box[1], last_scissor_box[2], last_scissor_box[3])
117
- glShadeModel(last_shade_model.unpack1('L'))
118
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, last_tex_env_mode.unpack1('L'))
115
+ GL.Scissor(last_scissor_box[0], last_scissor_box[1], last_scissor_box[2], last_scissor_box[3])
116
+ GL.ShadeModel(last_shade_model.unpack1('L'))
117
+ GL.TexEnvi(GL::TEXTURE_ENV, GL::TEXTURE_ENV_MODE, last_tex_env_mode.unpack1('L'))
119
118
  end
120
119
 
121
120
  # private
122
121
 
123
122
  def self.ImplOpenGL2_SetupRenderState(draw_data, fb_width, fb_height)
124
123
  # Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, vertex/texcoord/color pointers, polygon fill.
125
- glEnable(GL_BLEND)
126
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
127
- # glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA) # In order to composite our output buffer we need to preserve alpha
128
- glDisable(GL_CULL_FACE)
129
- glDisable(GL_STENCIL_TEST)
130
- glDisable(GL_DEPTH_TEST)
131
- glDisable(GL_LIGHTING)
132
- glDisable(GL_COLOR_MATERIAL)
133
- glEnable(GL_SCISSOR_TEST)
134
- glEnableClientState(GL_VERTEX_ARRAY)
135
- glEnableClientState(GL_TEXTURE_COORD_ARRAY)
136
- glEnableClientState(GL_COLOR_ARRAY)
137
- glDisableClientState(GL_NORMAL_ARRAY)
138
- glEnable(GL_TEXTURE_2D)
139
- glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
140
- glShadeModel(GL_SMOOTH)
141
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
124
+ GL.Enable(GL::BLEND)
125
+ GL.BlendFunc(GL::SRC_ALPHA, GL::ONE_MINUS_SRC_ALPHA)
126
+ # GL.BlendFuncSeparate(GL::SRC_ALPHA, GL::ONE_MINUS_SRC_ALPHA, GL::ONE, GL::ONE_MINUS_SRC_ALPHA) # In order to composite our output buffer we need to preserve alpha
127
+ GL.Disable(GL::CULL_FACE)
128
+ GL.Disable(GL::STENCIL_TEST)
129
+ GL.Disable(GL::DEPTH_TEST)
130
+ GL.Disable(GL::LIGHTING)
131
+ GL.Disable(GL::COLOR_MATERIAL)
132
+ GL.Enable(GL::SCISSOR_TEST)
133
+ GL.EnableClientState(GL::VERTEX_ARRAY)
134
+ GL.EnableClientState(GL::TEXTURE_COORD_ARRAY)
135
+ GL.EnableClientState(GL::COLOR_ARRAY)
136
+ GL.DisableClientState(GL::NORMAL_ARRAY)
137
+ GL.Enable(GL::TEXTURE_2D)
138
+ GL.PolygonMode(GL::FRONT_AND_BACK, GL::FILL)
139
+ GL.ShadeModel(GL::SMOOTH)
140
+ GL.TexEnvi(GL::TEXTURE_ENV, GL::TEXTURE_ENV_MODE, GL::MODULATE)
142
141
 
143
142
  # If you are using this code with non-legacy OpenGL header/contexts (which you should not, prefer using imgui_impl_opengl3.cpp!!),
144
143
  # you may need to backup/reset/restore other state, e.g. for current shader using the commented lines below.
145
144
  # (DO NOT MODIFY THIS FILE! Add the code in your calling function)
146
145
  # GLint last_program;
147
- # glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
146
+ # glGetIntegerv(GL::CURRENT_PROGRAM, &last_program);
148
147
  # glUseProgram(0);
149
148
  # ImGui_ImplOpenGL2_RenderDrawData(...);
150
149
  # glUseProgram(last_program)
151
150
  # There are potentially many more states you could need to clear/setup that we can't access from default headers.
152
- # e.g. glBindBuffer(GL_ARRAY_BUFFER, 0), glDisable(GL_TEXTURE_CUBE_MAP).
151
+ # e.g. glBindBuffer(GL::ARRAY_BUFFER, 0), glDisable(GL::TEXTURE_CUBE_MAP).
153
152
 
154
153
  # Setup viewport, orthographic projection matrix
155
154
  # Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
156
- glViewport(0, 0, fb_width, fb_height)
157
- glMatrixMode(GL_PROJECTION)
158
- glPushMatrix()
159
- glLoadIdentity()
160
- glOrtho(draw_data[:DisplayPos][:x], draw_data[:DisplayPos][:x] + draw_data[:DisplaySize][:x], draw_data[:DisplayPos][:y] + draw_data[:DisplaySize][:y], draw_data[:DisplayPos][:y], -1.0, +1.0)
161
- glMatrixMode(GL_MODELVIEW)
162
- glPushMatrix()
163
- glLoadIdentity()
155
+ GL.Viewport(0, 0, fb_width, fb_height)
156
+ GL.MatrixMode(GL::PROJECTION)
157
+ GL.PushMatrix()
158
+ GL.LoadIdentity()
159
+ GL.Ortho(draw_data[:DisplayPos][:x], draw_data[:DisplayPos][:x] + draw_data[:DisplaySize][:x], draw_data[:DisplayPos][:y] + draw_data[:DisplaySize][:y], draw_data[:DisplayPos][:y], -1.0, +1.0)
160
+ GL.MatrixMode(GL::MODELVIEW)
161
+ GL.PushMatrix()
162
+ GL.LoadIdentity()
164
163
  end
165
164
 
166
165
  def self.ImplOpenGL2_CreateFontsTexture()
@@ -174,28 +173,28 @@ module ImGui
174
173
  # Upload texture to graphics system
175
174
  last_texture = ' ' * 4
176
175
  @@g_FontTexture = ' ' * 4
177
- glGetIntegerv(GL_TEXTURE_BINDING_2D, last_texture)
178
- glGenTextures(1, @@g_FontTexture)
179
- glBindTexture(GL_TEXTURE_2D, @@g_FontTexture.unpack1('L'))
180
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
181
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
182
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0)
176
+ GL.GetIntegerv(GL::TEXTURE_BINDING_2D, last_texture)
177
+ GL.GenTextures(1, @@g_FontTexture)
178
+ GL.BindTexture(GL::TEXTURE_2D, @@g_FontTexture.unpack1('L'))
179
+ GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_MIN_FILTER, GL::LINEAR)
180
+ GL.TexParameteri(GL::TEXTURE_2D, GL::TEXTURE_MAG_FILTER, GL::LINEAR)
181
+ GL.PixelStorei(GL::UNPACK_ROW_LENGTH, 0)
183
182
  # Ruby/FFI <-> Fiddle pointer exchange
184
183
  pixels_ptr = Fiddle::Pointer.new(pixels.read_pointer.address)
185
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width.read_uint, height.read_uint, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels_ptr)
184
+ GL.TexImage2D(GL::TEXTURE_2D, 0, GL::RGBA, width.read_uint, height.read_uint, 0, GL::RGBA, GL::UNSIGNED_BYTE, pixels_ptr)
186
185
 
187
186
  # Store our identifier
188
187
  io[:Fonts][:TexID] = @@g_FontTexture.unpack1('L')
189
188
 
190
189
  # Restore state
191
- glBindTexture(GL_TEXTURE_2D, last_texture.unpack1('L'))
190
+ GL.BindTexture(GL::TEXTURE_2D, last_texture.unpack1('L'))
192
191
 
193
192
  return true
194
193
  end
195
194
 
196
195
  def self.ImplOpenGL2_DestroyFontsTexture()
197
196
  if @@g_FontTexture != 0
198
- glDeleteTextures(1, @@g_FontTexture)
197
+ GL.DeleteTextures(1, @@g_FontTexture)
199
198
  io = ImGuiIO.new(ImGui::GetIO())
200
199
  io[:Fonts][:TexID] = 0
201
200
  @@g_FontTexture = 0