main.cpp
Go to the documentation of this file.
1 // MIT License
2 
3 // Copyright (c) 2019 Erin Catto
4 
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #define _CRT_SECURE_NO_WARNINGS
24 #define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 1
25 
26 #include "imgui/imgui.h"
27 #include "imgui_impl_glfw.h"
28 #include "imgui_impl_opengl3.h"
29 #include "draw.h"
30 #include "settings.h"
31 #include "test.h"
32 
33 #include <algorithm>
34 #include <stdio.h>
35 #include <thread>
36 #include <chrono>
37 
38 #if defined(_WIN32)
39 #include <crtdbg.h>
40 #endif
41 
44 static Test* s_test = nullptr;
46 static bool s_rightMouseDown = false;
48 
49 void glfwErrorCallback(int error, const char* description)
50 {
51  fprintf(stderr, "GLFW error occured. Code: %d. Description: %s\n", error, description);
52 }
53 
54 static inline bool CompareTests(const TestEntry& a, const TestEntry& b)
55 {
56  int result = strcmp(a.category, b.category);
57  if (result == 0)
58  {
59  result = strcmp(a.name, b.name);
60  }
61 
62  return result < 0;
63 }
64 
65 static void SortTests()
66 {
68 }
69 
70 static void CreateUI(GLFWwindow* window, const char* glslVersion = NULL)
71 {
74 
75  bool success;
76  success = ImGui_ImplGlfw_InitForOpenGL(window, false);
77  if (success == false)
78  {
79  printf("ImGui_ImplGlfw_InitForOpenGL failed\n");
80  assert(false);
81  }
82 
83  success = ImGui_ImplOpenGL3_Init(glslVersion);
84  if (success == false)
85  {
86  printf("ImGui_ImplOpenGL3_Init failed\n");
87  assert(false);
88  }
89 
90  // Search for font file
91  const char* fontPath1 = "data/droid_sans.ttf";
92  const char* fontPath2 = "../data/droid_sans.ttf";
93  const char* fontPath = nullptr;
94  FILE* file1 = fopen(fontPath1, "rb");
95  FILE* file2 = fopen(fontPath2, "rb");
96  if (file1)
97  {
98  fontPath = fontPath1;
99  fclose(file1);
100  }
101 
102  if (file2)
103  {
104  fontPath = fontPath2;
105  fclose(file2);
106  }
107 
108  if (fontPath)
109  {
110  ImGui::GetIO().Fonts->AddFontFromFileTTF(fontPath, 13.0f);
111  }
112 }
113 
114 static void ResizeWindowCallback(GLFWwindow*, int width, int height)
115 {
116  g_camera.m_width = width;
117  g_camera.m_height = height;
118  s_settings.m_windowWidth = width;
119  s_settings.m_windowHeight = height;
120 }
121 
122 static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
123 {
124  ImGui_ImplGlfw_KeyCallback(window, key, scancode, action, mods);
125  if (ImGui::GetIO().WantCaptureKeyboard)
126  {
127  return;
128  }
129 
130  if (action == GLFW_PRESS)
131  {
132  switch (key)
133  {
134  case GLFW_KEY_ESCAPE:
135  // Quit
137  break;
138 
139  case GLFW_KEY_LEFT:
140  // Pan left
141  if (mods == GLFW_MOD_CONTROL)
142  {
143  b2Vec2 newOrigin(2.0f, 0.0f);
144  s_test->ShiftOrigin(newOrigin);
145  }
146  else
147  {
148  g_camera.m_center.x -= 0.5f;
149  }
150  break;
151 
152  case GLFW_KEY_RIGHT:
153  // Pan right
154  if (mods == GLFW_MOD_CONTROL)
155  {
156  b2Vec2 newOrigin(-2.0f, 0.0f);
157  s_test->ShiftOrigin(newOrigin);
158  }
159  else
160  {
161  g_camera.m_center.x += 0.5f;
162  }
163  break;
164 
165  case GLFW_KEY_DOWN:
166  // Pan down
167  if (mods == GLFW_MOD_CONTROL)
168  {
169  b2Vec2 newOrigin(0.0f, 2.0f);
170  s_test->ShiftOrigin(newOrigin);
171  }
172  else
173  {
174  g_camera.m_center.y -= 0.5f;
175  }
176  break;
177 
178  case GLFW_KEY_UP:
179  // Pan up
180  if (mods == GLFW_MOD_CONTROL)
181  {
182  b2Vec2 newOrigin(0.0f, -2.0f);
183  s_test->ShiftOrigin(newOrigin);
184  }
185  else
186  {
187  g_camera.m_center.y += 0.5f;
188  }
189  break;
190 
191  case GLFW_KEY_HOME:
192  // Reset view
193  g_camera.m_zoom = 1.0f;
194  g_camera.m_center.Set(0.0f, 20.0f);
195  break;
196 
197  case GLFW_KEY_Z:
198  // Zoom out
199  g_camera.m_zoom = b2Min(1.1f * g_camera.m_zoom, 20.0f);
200  break;
201 
202  case GLFW_KEY_X:
203  // Zoom in
204  g_camera.m_zoom = b2Max(0.9f * g_camera.m_zoom, 0.02f);
205  break;
206 
207  case GLFW_KEY_R:
208  // Reset test
209  delete s_test;
211  break;
212 
213  case GLFW_KEY_SPACE:
214  // Launch a bomb.
215  if (s_test)
216  {
217  s_test->LaunchBomb();
218  }
219  break;
220 
221  case GLFW_KEY_O:
222  s_settings.m_singleStep = true;
223  break;
224 
225  case GLFW_KEY_P:
227  break;
228 
230  // Switch to previous test
231  --s_testSelection;
232  if (s_testSelection < 0)
233  {
235  }
236  break;
237 
239  // Switch to next test
240  ++s_testSelection;
242  {
243  s_testSelection = 0;
244  }
245  break;
246 
247  case GLFW_KEY_TAB:
249 
250  default:
251  if (s_test)
252  {
253  s_test->Keyboard(key);
254  }
255  }
256  }
257  else if (action == GLFW_RELEASE)
258  {
259  s_test->KeyboardUp(key);
260  }
261  // else GLFW_REPEAT
262 }
263 
264 static void CharCallback(GLFWwindow* window, unsigned int c)
265 {
266  ImGui_ImplGlfw_CharCallback(window, c);
267 }
268 
269 static void MouseButtonCallback(GLFWwindow* window, int32 button, int32 action, int32 mods)
270 {
271  ImGui_ImplGlfw_MouseButtonCallback(window, button, action, mods);
272 
273  double xd, yd;
274  glfwGetCursorPos(g_mainWindow, &xd, &yd);
275  b2Vec2 ps((float)xd, (float)yd);
276 
277  // Use the mouse to move things around.
278  if (button == GLFW_MOUSE_BUTTON_1)
279  {
280  //<##>
281  //ps.Set(0, 0);
283  if (action == GLFW_PRESS)
284  {
285  if (mods == GLFW_MOD_SHIFT)
286  {
287  s_test->ShiftMouseDown(pw);
288  }
289  else
290  {
291  s_test->MouseDown(pw);
292  }
293  }
294 
295  if (action == GLFW_RELEASE)
296  {
297  s_test->MouseUp(pw);
298  }
299  }
300  else if (button == GLFW_MOUSE_BUTTON_2)
301  {
302  if (action == GLFW_PRESS)
303  {
305  s_rightMouseDown = true;
306  }
307 
308  if (action == GLFW_RELEASE)
309  {
310  s_rightMouseDown = false;
311  }
312  }
313 }
314 
315 static void MouseMotionCallback(GLFWwindow*, double xd, double yd)
316 {
317  b2Vec2 ps((float)xd, (float)yd);
318 
320  s_test->MouseMove(pw);
321 
322  if (s_rightMouseDown)
323  {
324  b2Vec2 diff = pw - s_clickPointWS;
325  g_camera.m_center.x -= diff.x;
326  g_camera.m_center.y -= diff.y;
328  }
329 }
330 
331 static void ScrollCallback(GLFWwindow* window, double dx, double dy)
332 {
333  ImGui_ImplGlfw_ScrollCallback(window, dx, dy);
334  if (ImGui::GetIO().WantCaptureMouse)
335  {
336  return;
337  }
338 
339  if (dy > 0)
340  {
341  g_camera.m_zoom /= 1.1f;
342  }
343  else
344  {
345  g_camera.m_zoom *= 1.1f;
346  }
347 }
348 
349 static void RestartTest()
350 {
351  delete s_test;
353 }
354 
355 static void UpdateUI()
356 {
357  int menuWidth = 180;
358  if (g_debugDraw.m_showUI)
359  {
360  ImGui::SetNextWindowPos(ImVec2((float)g_camera.m_width - menuWidth - 10, 10));
361  ImGui::SetNextWindowSize(ImVec2((float)menuWidth, (float)g_camera.m_height - 20));
362 
364 
365  if (ImGui::BeginTabBar("ControlTabs", ImGuiTabBarFlags_None))
366  {
367  if (ImGui::BeginTabItem("Controls"))
368  {
369  ImGui::SliderInt("Vel Iters", &s_settings.m_velocityIterations, 0, 50);
370  ImGui::SliderInt("Pos Iters", &s_settings.m_positionIterations, 0, 50);
371  ImGui::SliderFloat("Hertz", &s_settings.m_hertz, 5.0f, 120.0f, "%.0f hz");
372 
374 
377  ImGui::Checkbox("Time of Impact", &s_settings.m_enableContinuous);
379 
381 
385  ImGui::Checkbox("Contact Points", &s_settings.m_drawContactPoints);
386  ImGui::Checkbox("Contact Normals", &s_settings.m_drawContactNormals);
387  ImGui::Checkbox("Contact Impulses", &s_settings.m_drawContactImpulse);
388  ImGui::Checkbox("Friction Impulses", &s_settings.m_drawFrictionImpulse);
389  ImGui::Checkbox("Center of Masses", &s_settings.m_drawCOMs);
390  ImGui::Checkbox("Statistics", &s_settings.m_drawStats);
392 
393  ImVec2 button_sz = ImVec2(-1, 0);
394  if (ImGui::Button("Pause (P)", button_sz))
395  {
397  }
398 
399  if (ImGui::Button("Single Step (O)", button_sz))
400  {
402  }
403 
404  if (ImGui::Button("Restart (R)", button_sz))
405  {
406  RestartTest();
407  }
408 
409  if (ImGui::Button("Quit", button_sz))
410  {
412  }
413 
415  }
416 
419 
421 
422  if (ImGui::BeginTabItem("Tests"))
423  {
424  int categoryIndex = 0;
425  const char* category = g_testEntries[categoryIndex].category;
426  int i = 0;
427  while (i < g_testCount)
428  {
429  bool categorySelected = strcmp(category, g_testEntries[s_settings.m_testIndex].category) == 0;
430  ImGuiTreeNodeFlags nodeSelectionFlags = categorySelected ? ImGuiTreeNodeFlags_Selected : 0;
431  bool nodeOpen = ImGui::TreeNodeEx(category, nodeFlags | nodeSelectionFlags);
432 
433  if (nodeOpen)
434  {
435  while (i < g_testCount && strcmp(category, g_testEntries[i].category) == 0)
436  {
437  ImGuiTreeNodeFlags selectionFlags = 0;
438  if (s_settings.m_testIndex == i)
439  {
440  selectionFlags = ImGuiTreeNodeFlags_Selected;
441  }
442  ImGui::TreeNodeEx((void*)(intptr_t)i, leafNodeFlags | selectionFlags, "%s", g_testEntries[i].name);
443  if (ImGui::IsItemClicked())
444  {
445  delete s_test;
448  s_testSelection = i;
449  }
450  ++i;
451  }
452  ImGui::TreePop();
453  }
454  else
455  {
456  while (i < g_testCount && strcmp(category, g_testEntries[i].category) == 0)
457  {
458  ++i;
459  }
460  }
461 
462  if (i < g_testCount)
463  {
464  category = g_testEntries[i].category;
465  categoryIndex = i;
466  }
467  }
469  }
471  }
472 
473  ImGui::End();
474 
475  s_test->UpdateUI();
476  }
477 }
478 
479 //
480 int main(int, char**)
481 {
482 #if defined(_WIN32)
483  // Enable memory-leak reports
484  _CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));
485 #endif
486 
487  char buffer[128];
488 
489  s_settings.Load();
490  SortTests();
491 
493 
496 
497  if (glfwInit() == 0)
498  {
499  fprintf(stderr, "Failed to initialize GLFW\n");
500  return -1;
501  }
502 
503 #if __APPLE__
504  const char* glslVersion = "#version 150";
505 #else
506  const char* glslVersion = NULL;
507 #endif
508 
513 
514  sprintf(buffer, "Box2D Testbed Version %d.%d.%d", b2_version.major, b2_version.minor, b2_version.revision);
515 
516  bool fullscreen = false;
517  if (fullscreen)
518  {
519  g_mainWindow = glfwCreateWindow(1920, 1080, buffer, glfwGetPrimaryMonitor(), NULL);
520  }
521  else
522  {
524  }
525 
526  if (g_mainWindow == NULL)
527  {
528  fprintf(stderr, "Failed to open GLFW g_mainWindow.\n");
529  glfwTerminate();
530  return -1;
531  }
532 
534 
535  // Load OpenGL functions using glad
536  int version = gladLoadGL(glfwGetProcAddress);
537  printf("GL %d.%d\n", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version));
538  printf("OpenGL %s, GLSL %s\n", glGetString(GL_VERSION), glGetString(GL_SHADING_LANGUAGE_VERSION));
539 
547 
549 
550  CreateUI(g_mainWindow, glslVersion);
551 
555 
556  // Control the frame rate. One draw per monitor refresh.
557  //glfwSwapInterval(1);
558 
559  glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
560 
561  std::chrono::duration<double> frameTime(0.0);
562  std::chrono::duration<double> sleepAdjust(0.0);
563 
565  {
566  std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now();
567 
569 
570  int bufferWidth, bufferHeight;
571  glfwGetFramebufferSize(g_mainWindow, &bufferWidth, &bufferHeight);
572  glViewport(0, 0, bufferWidth, bufferHeight);
573 
575 
578 
579  ImGui::NewFrame();
580 
581  if (g_debugDraw.m_showUI)
582  {
587  ImGui::End();
588 
590  sprintf(buffer, "%s : %s", entry.category, entry.name);
591  s_test->DrawTitle(buffer);
592  }
593 
595 
596  UpdateUI();
597 
598  // ImGui::ShowDemoWindow();
599 
600  if (g_debugDraw.m_showUI)
601  {
602  sprintf(buffer, "%.1f ms", 1000.0 * frameTime.count());
603  g_debugDraw.DrawString(5, g_camera.m_height - 20, buffer);
604  }
605 
606  ImGui::Render();
608 
610 
612  {
614  delete s_test;
616  g_camera.m_zoom = 1.0f;
617  g_camera.m_center.Set(0.0f, 20.0f);
618  }
619 
620  glfwPollEvents();
621 
622  // Throttle to cap at 60Hz. This adaptive using a sleep adjustment. This could be improved by
623  // using mm_pause or equivalent for the last millisecond.
624  std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now();
625  std::chrono::duration<double> target(1.0 / 60.0);
626  std::chrono::duration<double> timeUsed = t2 - t1;
627  std::chrono::duration<double> sleepTime = target - timeUsed + sleepAdjust;
628  if (sleepTime > std::chrono::duration<double>(0))
629  {
630  std::this_thread::sleep_for(sleepTime);
631  }
632 
633  std::chrono::steady_clock::time_point t3 = std::chrono::steady_clock::now();
634  frameTime = t3 - t1;
635 
636  // Compute the sleep adjustment using a low pass filter
637  sleepAdjust = 0.9 * sleepAdjust + 0.1 * (target - frameTime);
638  }
639 
640  delete s_test;
641  s_test = nullptr;
642 
646  glfwTerminate();
647 
648  s_settings.Save();
649 
650  return 0;
651 }
Settings::m_drawContactImpulse
bool m_drawContactImpulse
Definition: settings.h:72
GLFW_KEY_TAB
#define GLFW_KEY_TAB
Definition: glfw3.h:414
Settings::m_drawShapes
bool m_drawShapes
Definition: settings.h:67
Settings::m_drawStats
bool m_drawStats
Definition: settings.h:75
Settings::Load
void Load()
Definition: settings.cpp:84
ImGui::BeginTabBar
IMGUI_API bool BeginTabBar(const char *str_id, ImGuiTabBarFlags flags=0)
Definition: imgui_widgets.cpp:5825
CharCallback
static void CharCallback(GLFWwindow *window, unsigned int c)
Definition: main.cpp:264
CompareTests
static bool CompareTests(const TestEntry &a, const TestEntry &b)
Definition: main.cpp:54
ImGuiWindowFlags_NoScrollbar
@ ImGuiWindowFlags_NoScrollbar
Definition: imgui.h:689
ImGui_ImplGlfw_InitForOpenGL
bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow *window, bool install_callbacks)
Definition: imgui_impl_glfw.cpp:195
b2Vec2::y
float y
Definition: b2_math.h:128
Test::ShiftOrigin
void ShiftOrigin(const b2Vec2 &newOrigin)
Definition: test.cpp:450
glViewport
#define glViewport
Definition: gl.h:2098
g_debugDraw
DebugDraw g_debugDraw
Definition: draw.cpp:32
glfwMakeContextCurrent
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
Definition: context.c:611
GLFW_MOUSE_BUTTON_1
#define GLFW_MOUSE_BUTTON_1
Definition: glfw3.h:537
ImGuiIO::Fonts
ImFontAtlas * Fonts
Definition: imgui.h:1290
g_camera
Camera g_camera
Definition: draw.cpp:33
NULL
#define NULL
DebugDraw::m_showUI
bool m_showUI
Definition: draw.h:92
imgui_impl_opengl3.h
glfwTerminate
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
Definition: init.c:267
ImGui::EndTabBar
IMGUI_API void EndTabBar()
Definition: imgui_widgets.cpp:5887
settings.h
b2Vec2_zero
const B2_API b2Vec2 b2Vec2_zero
Useful constant.
ImGui::SetNextWindowPos
IMGUI_API void SetNextWindowPos(const ImVec2 &pos, ImGuiCond cond=0, const ImVec2 &pivot=ImVec2(0, 0))
Definition: imgui.cpp:6045
ImGui_ImplOpenGL3_RenderDrawData
void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData *draw_data)
Definition: imgui_impl_opengl3.cpp:139
glfwPollEvents
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
Definition: window.c:1072
ImFontAtlas::AddFontFromFileTTF
IMGUI_API ImFont * AddFontFromFileTTF(const char *filename, float size_pixels, const ImFontConfig *font_cfg=NULL, const ImWchar *glyph_ranges=NULL)
Definition: imgui_draw.cpp:1597
Settings::m_drawCOMs
bool m_drawCOMs
Definition: settings.h:74
ImGui::GetDrawData
IMGUI_API ImDrawData * GetDrawData()
Definition: imgui.cpp:2988
GLFW_PRESS
#define GLFW_PRESS
The key or mouse button was pressed.
Definition: glfw3.h:304
Camera::m_center
b2Vec2 m_center
Definition: draw.h:53
ImGui::Button
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
Definition: imgui_widgets.cpp:575
Settings::m_drawFrictionImpulse
bool m_drawFrictionImpulse
Definition: settings.h:73
Test::ShiftMouseDown
void ShiftMouseDown(const b2Vec2 &p)
Definition: test.cpp:202
s_rightMouseDown
static bool s_rightMouseDown
Definition: main.cpp:46
glGetString
#define glGetString
Definition: gl.h:1706
ImGui_ImplGlfw_Shutdown
void ImGui_ImplGlfw_Shutdown()
Definition: imgui_impl_glfw.cpp:205
b2_version
B2_API b2Version b2_version
Current version.
Definition: b2_settings.cpp:30
ImGui::SetNextWindowBgAlpha
IMGUI_API void SetNextWindowBgAlpha(float alpha)
Definition: imgui.cpp:6092
glfwSetCharCallback
GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow *window, GLFWcharfun cbfun)
Sets the Unicode character callback.
Definition: input.c:801
description
description
GLFW_KEY_UP
#define GLFW_KEY_UP
Definition: glfw3.h:421
Settings::m_enableSleep
bool m_enableSleep
Definition: settings.h:80
ImGui::Render
IMGUI_API void Render()
Definition: imgui.cpp:3780
TestEntry
Definition: test.h:145
GLFW_CONTEXT_VERSION_MINOR
#define GLFW_CONTEXT_VERSION_MINOR
Context client API minor version hint and attribute.
Definition: glfw3.h:927
GLFWwindow
struct GLFWwindow GLFWwindow
Opaque window object.
Definition: glfw3.h:1137
Test::Keyboard
virtual void Keyboard(int key)
Definition: test.h:90
b2Version::minor
int32 minor
incremental changes
Definition: b2_common.h:131
imgui.h
GLFW_KEY_SPACE
#define GLFW_KEY_SPACE
Definition: glfw3.h:360
simple-obstacle-avoidance.action
action
Definition: simple-obstacle-avoidance.py:35
GLFW_KEY_RIGHT
#define GLFW_KEY_RIGHT
Definition: glfw3.h:418
glfwSetCursorPosCallback
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow *window, GLFWcursorposfun cbfun)
Sets the cursor position callback.
Definition: input.c:832
ImGui_ImplOpenGL3_Shutdown
void ImGui_ImplOpenGL3_Shutdown()
Definition: imgui_impl_opengl3.cpp:125
ImGui_ImplOpenGL3_Init
bool ImGui_ImplOpenGL3_Init(const char *glsl_version)
Definition: imgui_impl_opengl3.cpp:105
b2Min
T b2Min(T a, T b)
Definition: b2_math.h:626
ImGuiWindowFlags_AlwaysAutoResize
@ ImGuiWindowFlags_AlwaysAutoResize
Definition: imgui.h:692
Settings::m_enableSubStepping
bool m_enableSubStepping
Definition: settings.h:79
Camera::m_height
int32 m_height
Definition: draw.h:56
imgui_impl_glfw.h
ImVec2
Definition: imgui.h:164
GLFW_OPENGL_FORWARD_COMPAT
#define GLFW_OPENGL_FORWARD_COMPAT
OpenGL forward-compatibility hint and attribute.
Definition: glfw3.h:945
ImGui::GetIO
IMGUI_API ImGuiIO & GetIO()
Definition: imgui.cpp:2975
sajson::error
error
Error code indicating why parse failed.
Definition: sajson.h:643
glClear
#define glClear
Definition: gl.h:1466
b2Vec2::Set
void Set(float x_, float y_)
Set this vector to some specified coordinates.
Definition: b2_math.h:53
Test::UpdateUI
virtual void UpdateUI()
Definition: test.h:89
s_testSelection
static int32 s_testSelection
Definition: main.cpp:43
Test::MouseDown
virtual void MouseDown(const b2Vec2 &p)
Definition: test.cpp:144
Settings::m_drawContactPoints
bool m_drawContactPoints
Definition: settings.h:70
glfwSetErrorCallback
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
Sets the error callback.
Definition: init.c:333
GLFW_KEY_LEFT_BRACKET
#define GLFW_KEY_LEFT_BRACKET
Definition: glfw3.h:404
glfwErrorCallback
void glfwErrorCallback(int error, const char *description)
Definition: main.cpp:49
Settings::m_testIndex
int m_testIndex
Definition: settings.h:61
RestartTest
static void RestartTest()
Definition: main.cpp:349
b2Vec2
A 2D column vector.
Definition: b2_math.h:41
MouseMotionCallback
static void MouseMotionCallback(GLFWwindow *, double xd, double yd)
Definition: main.cpp:315
ImGuiTreeNodeFlags
int ImGuiTreeNodeFlags
Definition: imgui.h:143
ImGui_ImplGlfw_KeyCallback
void ImGui_ImplGlfw_KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
Definition: imgui_impl_glfw.cpp:100
Settings::m_velocityIterations
int m_velocityIterations
Definition: settings.h:65
ImGuiTabBarFlags_None
@ ImGuiTabBarFlags_None
Definition: imgui.h:803
Settings::m_singleStep
bool m_singleStep
Definition: settings.h:82
CreateUI
static void CreateUI(GLFWwindow *window, const char *glslVersion=NULL)
Definition: main.cpp:70
ImGui::Separator
IMGUI_API void Separator()
Definition: imgui_widgets.cpp:1129
f
f
Test::MouseMove
virtual void MouseMove(const b2Vec2 &p)
Definition: test.cpp:228
Settings::m_drawContactNormals
bool m_drawContactNormals
Definition: settings.h:71
b2Max
T b2Max(T a, T b)
Definition: b2_math.h:637
Settings::m_positionIterations
int m_positionIterations
Definition: settings.h:66
glfwGetWindowSize
GLFWAPI void glfwGetWindowSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the client area of the specified window.
Definition: window.c:544
ImGui::End
IMGUI_API void End()
Definition: imgui.cpp:5371
glfwGetCursorPos
GLFWAPI void glfwGetCursorPos(GLFWwindow *window, double *xpos, double *ypos)
Retrieves the position of the cursor relative to the client area of the window.
Definition: input.c:637
glfwSwapBuffers
GLFWAPI void glfwSwapBuffers(GLFWwindow *window)
Swaps the front and back buffers of the specified window.
Definition: context.c:641
GLFW_OPENGL_PROFILE
#define GLFW_OPENGL_PROFILE
OpenGL profile hint and attribute.
Definition: glfw3.h:957
glfwGetPrimaryMonitor
GLFWAPI GLFWmonitor * glfwGetPrimaryMonitor(void)
Returns the primary monitor.
Definition: monitor.c:308
glfwSetWindowSizeCallback
GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow *window, GLFWwindowsizefun cbfun)
Sets the size callback for the specified window.
Definition: window.c:984
glfwSetScrollCallback
GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow *window, GLFWscrollfun cbfun)
Sets the scroll callback.
Definition: input.c:854
b2Clamp
T b2Clamp(T a, T low, T high)
Definition: b2_math.h:648
gladLoadGL
GLAD_API_CALL int gladLoadGL(GLADloadfunc load)
Definition: gl.c:942
ImGui::TreeNodeEx
IMGUI_API bool TreeNodeEx(const char *label, ImGuiTreeNodeFlags flags=0)
Definition: imgui_widgets.cpp:4644
Settings::m_windowWidth
int m_windowWidth
Definition: settings.h:62
ImGui_ImplGlfw_MouseButtonCallback
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow *window, int button, int action, int mods)
Definition: imgui_impl_glfw.cpp:81
Settings::m_drawJoints
bool m_drawJoints
Definition: settings.h:68
ImGui_ImplGlfw_NewFrame
void ImGui_ImplGlfw_NewFrame()
Definition: imgui_impl_glfw.cpp:270
GLFW_KEY_RIGHT_BRACKET
#define GLFW_KEY_RIGHT_BRACKET
Definition: glfw3.h:406
DebugDraw::DrawString
void DrawString(int x, int y, const char *string,...)
Definition: draw.cpp:772
GLFW_KEY_DOWN
#define GLFW_KEY_DOWN
Definition: glfw3.h:420
SortTests
static void SortTests()
Definition: main.cpp:65
Settings::Save
void Save()
Definition: settings.cpp:56
GLFW_KEY_HOME
#define GLFW_KEY_HOME
Definition: glfw3.h:424
GLFW_CONTEXT_VERSION_MAJOR
#define GLFW_CONTEXT_VERSION_MAJOR
Context client API major version hint and attribute.
Definition: glfw3.h:921
ImGui::SliderFloat
IMGUI_API bool SliderFloat(const char *label, float *v, float v_min, float v_max, const char *format="%.3f", float power=1.0f)
Definition: imgui_widgets.cpp:2394
ImGui::TreePop
IMGUI_API void TreePop()
Definition: imgui_widgets.cpp:4911
ImGui_ImplGlfw_CharCallback
void ImGui_ImplGlfw_CharCallback(GLFWwindow *window, unsigned int c)
Definition: imgui_impl_glfw.cpp:118
ImGui::BeginTabItem
IMGUI_API bool BeginTabItem(const char *label, bool *p_open=NULL, ImGuiTabItemFlags flags=0)
Definition: imgui_widgets.cpp:6221
GL_VERSION
#define GL_VERSION
Definition: gl.h:957
Settings::m_enableWarmStarting
bool m_enableWarmStarting
Definition: settings.h:77
b2Version::major
int32 major
significant changes
Definition: b2_common.h:130
Settings::m_hertz
float m_hertz
Definition: settings.h:64
glfwSetMouseButtonCallback
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow *window, GLFWmousebuttonfun cbfun)
Sets the mouse button callback.
Definition: input.c:821
GLFW_MOD_SHIFT
#define GLFW_MOD_SHIFT
If this bit is set one or more Shift keys were held down.
Definition: glfw3.h:499
ScrollCallback
static void ScrollCallback(GLFWwindow *window, double dx, double dy)
Definition: main.cpp:331
GLAD_VERSION_MAJOR
#define GLAD_VERSION_MAJOR(version)
Definition: gl.h:142
GLFW_MOUSE_BUTTON_2
#define GLFW_MOUSE_BUTTON_2
Definition: glfw3.h:538
glfwInit
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
Definition: init.c:222
glfwGetProcAddress
GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname)
Returns the address of the specified function for the current context.
Definition: context.c:741
GL_TRUE
#define GL_TRUE
Definition: gl.h:891
ImGui::Checkbox
IMGUI_API bool Checkbox(const char *label, bool *v)
Definition: imgui_widgets.cpp:876
GLFW_RELEASE
#define GLFW_RELEASE
The key or mouse button was released.
Definition: glfw3.h:297
GLAD_VERSION_MINOR
#define GLAD_VERSION_MINOR(version)
Definition: gl.h:143
ImGui_ImplGlfw_ScrollCallback
void ImGui_ImplGlfw_ScrollCallback(GLFWwindow *window, double xoffset, double yoffset)
Definition: imgui_impl_glfw.cpp:90
GLFW_KEY_R
#define GLFW_KEY_R
Definition: glfw3.h:395
GLFW_KEY_P
#define GLFW_KEY_P
Definition: glfw3.h:393
ImGui::CreateContext
IMGUI_API ImGuiContext * CreateContext(ImFontAtlas *shared_font_atlas=NULL)
Definition: imgui.cpp:2956
ImGuiTreeNodeFlags_Leaf
@ ImGuiTreeNodeFlags_Leaf
Definition: imgui.h:762
test.h
Test::DrawTitle
void DrawTitle(const char *string)
Definition: test.cpp:106
ImGui::SetNextWindowSize
IMGUI_API void SetNextWindowSize(const ImVec2 &size, ImGuiCond cond=0)
Definition: imgui.cpp:6054
b2Vec2::x
float x
Definition: b2_math.h:128
Test::LaunchBomb
void LaunchBomb()
Definition: test.cpp:238
GLFW_KEY_O
#define GLFW_KEY_O
Definition: glfw3.h:392
ImGuiTreeNodeFlags_NoTreePushOnOpen
@ ImGuiTreeNodeFlags_NoTreePushOnOpen
Definition: imgui.h:757
Settings::m_pause
bool m_pause
Definition: settings.h:81
Settings
Definition: settings.h:25
draw.h
g_testCount
int g_testCount
Definition: test.cpp:456
g_mainWindow
GLFWwindow * g_mainWindow
Definition: main.cpp:42
UpdateUI
static void UpdateUI()
Definition: main.cpp:355
glClearColor
#define glClearColor
Definition: gl.h:1476
TestEntry::category
const char * category
Definition: test.h:147
g_testEntries
TestEntry g_testEntries[MAX_TESTS]
Definition: test.cpp:455
Settings::m_drawProfile
bool m_drawProfile
Definition: settings.h:76
TestEntry::createFcn
TestCreateFcn * createFcn
Definition: test.h:149
ImGuiTreeNodeFlags_OpenOnDoubleClick
@ ImGuiTreeNodeFlags_OpenOnDoubleClick
Definition: imgui.h:760
ImGuiTreeNodeFlags_Selected
@ ImGuiTreeNodeFlags_Selected
Definition: imgui.h:754
ImGuiWindowFlags_NoMove
@ ImGuiWindowFlags_NoMove
Definition: imgui.h:688
GLFW_KEY_ESCAPE
#define GLFW_KEY_ESCAPE
Definition: glfw3.h:412
ImGui::NewFrame
IMGUI_API void NewFrame()
Definition: imgui.cpp:3287
ImGui::EndTabItem
IMGUI_API void EndTabItem()
Definition: imgui_widgets.cpp:6238
GLFW_MOD_CONTROL
#define GLFW_MOD_CONTROL
If this bit is set one or more Control keys were held down.
Definition: glfw3.h:504
ImGui::Begin
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
Definition: imgui.cpp:4736
main
int main(int, char **)
Definition: main.cpp:480
s_clickPointWS
static b2Vec2 s_clickPointWS
Definition: main.cpp:47
Settings::m_windowHeight
int m_windowHeight
Definition: settings.h:63
glfwSetKeyCallback
GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow *window, GLFWkeyfun cbfun)
Sets the key callback.
Definition: input.c:791
Settings::m_drawAABBs
bool m_drawAABBs
Definition: settings.h:69
DebugDraw::Destroy
void Destroy()
Definition: draw.cpp:623
GL_SHADING_LANGUAGE_VERSION
#define GL_SHADING_LANGUAGE_VERSION
Definition: gl.h:719
Settings::m_enableContinuous
bool m_enableContinuous
Definition: settings.h:78
int32
signed int int32
Definition: b2_types.h:28
glfwCreateWindow
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
Definition: window.c:151
TestEntry::name
const char * name
Definition: test.h:148
Test
Definition: test.h:80
ImGuiWindowFlags_NoCollapse
@ ImGuiWindowFlags_NoCollapse
Definition: imgui.h:691
Camera::m_zoom
float m_zoom
Definition: draw.h:54
GLFW_KEY_LEFT
#define GLFW_KEY_LEFT
Definition: glfw3.h:419
glfwWindowHint
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
Definition: window.c:291
Test::KeyboardUp
virtual void KeyboardUp(int key)
Definition: test.h:91
Camera::m_width
int32 m_width
Definition: draw.h:55
MouseButtonCallback
static void MouseButtonCallback(GLFWwindow *window, int32 button, int32 action, int32 mods)
Definition: main.cpp:269
Camera::ConvertScreenToWorld
b2Vec2 ConvertScreenToWorld(const b2Vec2 &screenPoint)
Definition: draw.cpp:36
ImGui_ImplOpenGL3_NewFrame
void ImGui_ImplOpenGL3_NewFrame()
Definition: imgui_impl_opengl3.cpp:130
s_settings
static Settings s_settings
Definition: main.cpp:45
GL_COLOR_BUFFER_BIT
#define GL_COLOR_BUFFER_BIT
Definition: gl.h:254
s_test
static Test * s_test
Definition: main.cpp:44
ImGuiWindowFlags_NoTitleBar
@ ImGuiWindowFlags_NoTitleBar
Definition: imgui.h:686
glfwWindowShouldClose
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.
Definition: window.c:477
Test::Step
virtual void Step(Settings &settings)
Definition: test.cpp:278
glfwGetFramebufferSize
GLFWAPI void glfwGetFramebufferSize(GLFWwindow *window, int *width, int *height)
Retrieves the size of the framebuffer of the specified window.
Definition: window.c:647
ImGuiWindowFlags_NoResize
@ ImGuiWindowFlags_NoResize
Definition: imgui.h:687
b2Version::revision
int32 revision
bug fixes
Definition: b2_common.h:132
GLFW_OPENGL_CORE_PROFILE
#define GLFW_OPENGL_CORE_PROFILE
Definition: glfw3.h:998
KeyCallback
static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods)
Definition: main.cpp:122
ResizeWindowCallback
static void ResizeWindowCallback(GLFWwindow *, int width, int height)
Definition: main.cpp:114
ImGui::SliderInt
IMGUI_API bool SliderInt(const char *label, int *v, int v_min, int v_max, const char *format="%d")
Definition: imgui_widgets.cpp:2424
GL_DEPTH_BUFFER_BIT
#define GL_DEPTH_BUFFER_BIT
Definition: gl.h:296
ImGui::IsItemClicked
IMGUI_API bool IsItemClicked(int mouse_button=0)
Definition: imgui.cpp:4166
GLFW_KEY_X
#define GLFW_KEY_X
Definition: glfw3.h:401
glfwSetWindowShouldClose
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow *window, int value)
Sets the close flag of the specified window.
Definition: window.c:486
ImGuiWindowFlags_NoInputs
@ ImGuiWindowFlags_NoInputs
Definition: imgui.h:708
ImGuiTreeNodeFlags_OpenOnArrow
@ ImGuiTreeNodeFlags_OpenOnArrow
Definition: imgui.h:761
GLFW_KEY_Z
#define GLFW_KEY_Z
Definition: glfw3.h:403
Test::MouseUp
virtual void MouseUp(const b2Vec2 &p)
Definition: test.cpp:214
IMGUI_CHECKVERSION
#define IMGUI_CHECKVERSION()
Definition: imgui.h:50
DebugDraw::Create
void Create()
Definition: draw.cpp:612


mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:08