MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / main

Function main

examples/SimpleOpenGL3/main.cpp:69–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69int main(int argc, char* argv[])
70{
71 {
72 b3CommandLineArgs myArgs(argc, argv);
73
74 SimpleOpenGLApp* app = new SimpleOpenGLApp("SimpleOpenGL3App", 1024, 768);
75
76 app->m_renderer->getActiveCamera()->setCameraDistance(13);
77 app->m_renderer->getActiveCamera()->setCameraPitch(0);
78 app->m_renderer->getActiveCamera()->setCameraTargetPosition(0, 0, 0);
79 sOldKeyboardCB = app->m_window->getKeyboardCallback();
80 app->m_window->setKeyboardCallback(MyKeyboardCallback2);
81 sOldMouseMoveCB = app->m_window->getMouseMoveCallback();
82 app->m_window->setMouseMoveCallback(MyMouseMoveCallback2);
83 sOldMouseButtonCB = app->m_window->getMouseButtonCallback();
84 app->m_window->setMouseButtonCallback(MyMouseButtonCallback2);
85 sOldWheelCB = app->m_window->getWheelCallback();
86 app->m_window->setWheelCallback(MyWheelCallback2);
87 sOldResizeCB = app->m_window->getResizeCallback();
88 app->m_window->setResizeCallback(MyResizeCallback2);
89
90 myArgs.GetCmdLineArgument("mp4_file", gVideoFileName);
91 if (gVideoFileName)
92 app->dumpFramesToVideo(gVideoFileName);
93
94 myArgs.GetCmdLineArgument("png_file", gPngFileName);
95 char fileName[1024];
96
97 int textureWidth = 128;
98 int textureHeight = 128;
99
100 unsigned char* image = new unsigned char[textureWidth * textureHeight * 4];
101
102 int textureHandle = app->m_renderer->registerTexture(image, textureWidth, textureHeight);
103
104 do
105 {
106 static int frameCount = 0;
107 frameCount++;
108 if (gPngFileName)
109 {
110 printf("gPngFileName=%s\n", gPngFileName);
111
112 sprintf(fileName, "%s%d.png", gPngFileName, frameCount++);
113 app->dumpNextFrameToPng(fileName);
114 }
115
116 //update the texels of the texture using a simple pattern, animated using frame index
117 for (int y = 0; y < textureHeight; ++y)
118 {
119 const int t = (y + frameCount) >> 4;
120 unsigned char* pi = image + y * textureWidth * 3;
121 for (int x = 0; x < textureWidth; ++x)
122 {
123 const int s = x >> 4;
124 const unsigned char b = 180;
125 unsigned char c = b + ((s + (t & 1)) & 1) * (255 - b);
126 pi[0] = pi[1] = pi[2] = pi[3] = c;

Callers

nothing calls this directly

Calls 15

setCameraPitchMethod · 0.80
setCameraDistanceMethod · 0.45
getActiveCameraMethod · 0.45
getKeyboardCallbackMethod · 0.45
setKeyboardCallbackMethod · 0.45
getMouseMoveCallbackMethod · 0.45
setMouseMoveCallbackMethod · 0.45
getWheelCallbackMethod · 0.45
setWheelCallbackMethod · 0.45

Tested by

no test coverage detected