aboutsummaryrefslogtreecommitdiffstats
path: root/examples/cube_view.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-01-02 21:09:27 +0100
committerDavid Robillard <d@drobilla.net>2021-01-02 21:09:27 +0100
commit1c365945ed2ebd5b9f54eb0c8c5c1c6d97cad712 (patch)
tree4b77266a9ce3e2a11b59bbd2754869c6ee1d172b /examples/cube_view.h
parenta92a194b4fc64e0cfa4a88a59e261f236414d61c (diff)
downloadpugl-1c365945ed2ebd5b9f54eb0c8c5c1c6d97cad712.tar.gz
pugl-1c365945ed2ebd5b9f54eb0c8c5c1c6d97cad712.tar.bz2
pugl-1c365945ed2ebd5b9f54eb0c8c5c1c6d97cad712.zip
Simplify clang-format configuration and format all code
Diffstat (limited to 'examples/cube_view.h')
-rw-r--r--examples/cube_view.h148
1 files changed, 74 insertions, 74 deletions
diff --git a/examples/cube_view.h b/examples/cube_view.h
index 87bf3b5..e0c86eb 100644
--- a/examples/cube_view.h
+++ b/examples/cube_view.h
@@ -26,48 +26,48 @@
// clang-format off
static const float cubeStripVertices[] = {
- -1.0f, 1.0f, 1.0f, // Front top left
- 1.0f, 1.0f, 1.0f, // Front top right
- -1.0f, -1.0f, 1.0f, // Front bottom left
- 1.0f, -1.0f, 1.0f, // Front bottom right
- 1.0f, -1.0f, -1.0f, // Back bottom right
- 1.0f, 1.0f, 1.0f, // Front top right
- 1.0f, 1.0f, -1.0f, // Back top right
- -1.0f, 1.0f, 1.0f, // Front top left
- -1.0f, 1.0f, -1.0f, // Back top left
- -1.0f, -1.0f, 1.0f, // Front bottom left
- -1.0f, -1.0f, -1.0f, // Back bottom left
- 1.0f, -1.0f, -1.0f, // Back bottom right
- -1.0f, 1.0f, -1.0f, // Back top left
- 1.0f, 1.0f, -1.0f // Back top right
+ -1.0f, 1.0f, 1.0f, // Front top left
+ 1.0f, 1.0f, 1.0f, // Front top right
+ -1.0f, -1.0f, 1.0f, // Front bottom left
+ 1.0f, -1.0f, 1.0f, // Front bottom right
+ 1.0f, -1.0f, -1.0f, // Back bottom right
+ 1.0f, 1.0f, 1.0f, // Front top right
+ 1.0f, 1.0f, -1.0f, // Back top right
+ -1.0f, 1.0f, 1.0f, // Front top left
+ -1.0f, 1.0f, -1.0f, // Back top left
+ -1.0f, -1.0f, 1.0f, // Front bottom left
+ -1.0f, -1.0f, -1.0f, // Back bottom left
+ 1.0f, -1.0f, -1.0f, // Back bottom right
+ -1.0f, 1.0f, -1.0f, // Back top left
+ 1.0f, 1.0f, -1.0f // Back top right
};
static const float cubeFrontLineLoop[] = {
- -1.0f, 1.0f, 1.0f, // Front top left
- 1.0f, 1.0f, 1.0f, // Front top right
- 1.0f, -1.0f, 1.0f, // Front bottom right
- -1.0f, -1.0f, 1.0f, // Front bottom left
+ -1.0f, 1.0f, 1.0f, // Front top left
+ 1.0f, 1.0f, 1.0f, // Front top right
+ 1.0f, -1.0f, 1.0f, // Front bottom right
+ -1.0f, -1.0f, 1.0f, // Front bottom left
};
static const float cubeBackLineLoop[] = {
- -1.0f, 1.0f, -1.0f, // Back top left
- 1.0f, 1.0f, -1.0f, // Back top right
- 1.0f, -1.0f, -1.0f, // Back bottom right
- -1.0f, -1.0f, -1.0f, // Back bottom left
+ -1.0f, 1.0f, -1.0f, // Back top left
+ 1.0f, 1.0f, -1.0f, // Back top right
+ 1.0f, -1.0f, -1.0f, // Back bottom right
+ -1.0f, -1.0f, -1.0f, // Back bottom left
};
static const float cubeSideLines[] = {
- -1.0f, 1.0f, 1.0f, // Front top left
- -1.0f, 1.0f, -1.0f, // Back top left
+ -1.0f, 1.0f, 1.0f, // Front top left
+ -1.0f, 1.0f, -1.0f, // Back top left
- -1.0f, -1.0f, 1.0f, // Front bottom left
- -1.0f, -1.0f, -1.0f, // Back bottom left
+ -1.0f, -1.0f, 1.0f, // Front bottom left
+ -1.0f, -1.0f, -1.0f, // Back bottom left
- 1.0f, 1.0f, 1.0f, // Front top right
- 1.0f, 1.0f, -1.0f, // Back top right
+ 1.0f, 1.0f, 1.0f, // Front top right
+ 1.0f, 1.0f, -1.0f, // Back top right
- 1.0f, -1.0f, 1.0f, // Front bottom right
- 1.0f, -1.0f, -1.0f, // Back bottom right
+ 1.0f, -1.0f, 1.0f, // Front bottom right
+ 1.0f, -1.0f, -1.0f, // Back bottom right
};
// clang-format on
@@ -75,19 +75,19 @@ static const float cubeSideLines[] = {
static inline void
reshapeCube(const float width, const float height)
{
- const float aspect = width / height;
+ const float aspect = width / height;
- glEnable(GL_DEPTH_TEST);
- glDepthFunc(GL_LESS);
- glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_LESS);
+ glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glViewport(0, 0, (int)width, (int)height);
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glViewport(0, 0, (int)width, (int)height);
- float projection[16];
- perspective(projection, 1.8f, aspect, 1.0f, 100.0f);
- glLoadMatrixf(projection);
+ float projection[16];
+ perspective(projection, 1.8f, aspect, 1.0f, 100.0f);
+ glLoadMatrixf(projection);
}
static inline void
@@ -97,40 +97,40 @@ displayCube(PuglView* const view,
const float yAngle,
const bool entered)
{
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef(0.0f, 0.0f, distance * -1.0f);
- glRotatef(xAngle, 0.0f, 1.0f, 0.0f);
- glRotatef(yAngle, 1.0f, 0.0f, 0.0f);
-
- const float bg = entered ? 0.2f : 0.0f;
- glClearColor(bg, bg, bg, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- if (puglHasFocus(view)) {
- // Draw cube surfaces
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_COLOR_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, cubeStripVertices);
- glColorPointer(3, GL_FLOAT, 0, cubeStripVertices);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 14);
- glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
-
- glColor3f(0.0f, 0.0f, 0.0f);
- } else {
- glColor3f(1.0f, 1.0f, 1.0f);
- }
-
- // Draw cube wireframe
- glEnableClientState(GL_VERTEX_ARRAY);
- glVertexPointer(3, GL_FLOAT, 0, cubeFrontLineLoop);
- glDrawArrays(GL_LINE_LOOP, 0, 4);
- glVertexPointer(3, GL_FLOAT, 0, cubeBackLineLoop);
- glDrawArrays(GL_LINE_LOOP, 0, 4);
- glVertexPointer(3, GL_FLOAT, 0, cubeSideLines);
- glDrawArrays(GL_LINES, 0, 8);
- glDisableClientState(GL_VERTEX_ARRAY);
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ glTranslatef(0.0f, 0.0f, distance * -1.0f);
+ glRotatef(xAngle, 0.0f, 1.0f, 0.0f);
+ glRotatef(yAngle, 1.0f, 0.0f, 0.0f);
+
+ const float bg = entered ? 0.2f : 0.0f;
+ glClearColor(bg, bg, bg, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ if (puglHasFocus(view)) {
+ // Draw cube surfaces
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 0, cubeStripVertices);
+ glColorPointer(3, GL_FLOAT, 0, cubeStripVertices);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 14);
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+
+ glColor3f(0.0f, 0.0f, 0.0f);
+ } else {
+ glColor3f(1.0f, 1.0f, 1.0f);
+ }
+
+ // Draw cube wireframe
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glVertexPointer(3, GL_FLOAT, 0, cubeFrontLineLoop);
+ glDrawArrays(GL_LINE_LOOP, 0, 4);
+ glVertexPointer(3, GL_FLOAT, 0, cubeBackLineLoop);
+ glDrawArrays(GL_LINE_LOOP, 0, 4);
+ glVertexPointer(3, GL_FLOAT, 0, cubeSideLines);
+ glDrawArrays(GL_LINES, 0, 8);
+ glDisableClientState(GL_VERTEX_ARRAY);
}
#endif // EXAMPLES_CUBE_VIEW_H