MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / display

Function display

cpp/5_Domain_Specific/fluidsGL/fluidsGL.cpp:127–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127void display(void)
128{
129 if (!ref_file) {
130 sdkStartTimer(&timer);
131 simulateFluids();
132 }
133
134 // render points from vertex buffer
135 glClear(GL_COLOR_BUFFER_BIT);
136 glColor4f(0, 1, 0, 0.5f);
137 glPointSize(1);
138 glEnable(GL_POINT_SMOOTH);
139 glEnable(GL_BLEND);
140 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
141 glEnableClientState(GL_VERTEX_ARRAY);
142 glDisable(GL_DEPTH_TEST);
143 glDisable(GL_CULL_FACE);
144 glBindBuffer(GL_ARRAY_BUFFER, vbo);
145 glVertexPointer(2, GL_FLOAT, 0, NULL);
146 glDrawArrays(GL_POINTS, 0, DS);
147 glBindBuffer(GL_ARRAY_BUFFER, 0);
148 glDisableClientState(GL_VERTEX_ARRAY);
149 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
150 glDisable(GL_TEXTURE_2D);
151
152 if (ref_file) {
153 return;
154 }
155
156 // Finish timing before swap buffers to avoid refresh sync
157 sdkStopTimer(&timer);
158 glutSwapBuffers();
159
160 fpsCount++;
161
162 if (fpsCount == fpsLimit) {
163 char fps[256];
164 float ifps = 1.f / (sdkGetAverageTimerValue(&timer) / 1000.f);
165 sprintf(fps, "Cuda/GL Stable Fluids (%d x %d): %3.1f fps", DIM, DIM, ifps);
166 glutSetWindowTitle(fps);
167 fpsCount = 0;
168 fpsLimit = (int)MAX(ifps, 1.f);
169 sdkResetTimer(&timer);
170 }
171
172 glutPostRedisplay();
173}
174
175void autoTest(char **argv)
176{

Callers 1

autoTestFunction · 0.70

Calls 5

sdkStartTimerFunction · 0.85
sdkStopTimerFunction · 0.85
sdkGetAverageTimerValueFunction · 0.85
sdkResetTimerFunction · 0.85
simulateFluidsFunction · 0.70

Tested by

no test coverage detected