aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-04-02 17:39:54 +0200
committerDavid Robillard <d@drobilla.net>2020-04-02 17:40:56 +0200
commitffa9c8240e4d904da2154466e811302ae313034d (patch)
tree4f4618b267e91b0c575512087fa264cd923e8e3f /examples
parent6c870cb0d2cae098d7780d7aaaf1815887ef182e (diff)
downloadpugl-ffa9c8240e4d904da2154466e811302ae313034d.tar.gz
pugl-ffa9c8240e4d904da2154466e811302ae313034d.tar.bz2
pugl-ffa9c8240e4d904da2154466e811302ae313034d.zip
Strengthen warnings
Diffstat (limited to 'examples')
-rw-r--r--examples/cube_view.h18
-rw-r--r--examples/pugl_embed_demo.c13
-rw-r--r--examples/pugl_gl3_demo.c16
-rw-r--r--examples/pugl_window_demo.c9
4 files changed, 34 insertions, 22 deletions
diff --git a/examples/cube_view.h b/examples/cube_view.h
index 82648ac..9fd2349 100644
--- a/examples/cube_view.h
+++ b/examples/cube_view.h
@@ -21,9 +21,9 @@
#include "pugl/gl.h"
static inline void
-reshapeCube(const int width, const int height)
+reshapeCube(const float width, const float height)
{
- const float aspect = (float)width / (float)height;
+ const float aspect = width / height;
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
@@ -31,7 +31,7 @@ reshapeCube(const int width, const int height)
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glViewport(0, 0, width, height);
+ glViewport(0, 0, (int)width, (int)height);
float projection[16];
perspective(projection, 1.8f, aspect, 1.0f, 100.0f);
@@ -40,16 +40,16 @@ reshapeCube(const int width, const int height)
static inline void
displayCube(PuglView* const view,
- const double distance,
- const double xAngle,
- const double yAngle,
+ const float distance,
+ const float xAngle,
+ const float yAngle,
const bool entered)
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- glTranslatef(0.0f, 0.0f, (float)distance * -1.0f);
- glRotatef((float)xAngle, 0.0f, 1.0f, 0.0f);
- glRotatef((float)yAngle, 1.0f, 0.0f, 0.0f);
+ 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);
diff --git a/examples/pugl_embed_demo.c b/examples/pugl_embed_demo.c
index 6152648..3a7b051 100644
--- a/examples/pugl_embed_demo.c
+++ b/examples/pugl_embed_demo.c
@@ -87,7 +87,11 @@ onDisplay(PuglView* view)
app->yAngle = fmod(app->yAngle + dTime * 100.0, 360.0);
}
- displayCube(view, app->dist, app->xAngle, app->yAngle, app->mouseEntered);
+ displayCube(view,
+ app->dist,
+ (float)app->xAngle,
+ (float)app->yAngle,
+ app->mouseEntered);
app->lastDrawTime = thisTime;
}
@@ -164,7 +168,9 @@ onParentEvent(PuglView* view, const PuglEvent* event)
switch (event->type) {
case PUGL_CONFIGURE:
- reshapeCube((int)event->configure.width, (int)event->configure.height);
+ reshapeCube((float)event->configure.width,
+ (float)event->configure.height);
+
puglSetFrame(app->child, getChildFrame(parentFrame));
break;
case PUGL_UPDATE:
@@ -214,7 +220,8 @@ onEvent(PuglView* view, const PuglEvent* event)
switch (event->type) {
case PUGL_CONFIGURE:
- reshapeCube((int)event->configure.width, (int)event->configure.height);
+ reshapeCube((float)event->configure.width,
+ (float)event->configure.height);
break;
case PUGL_UPDATE:
if (app->continuous) {
diff --git a/examples/pugl_gl3_demo.c b/examples/pugl_gl3_demo.c
index 3a9503c..c49ed3d 100644
--- a/examples/pugl_gl3_demo.c
+++ b/examples/pugl_gl3_demo.c
@@ -138,14 +138,14 @@ onExpose(PuglView* view)
const float offset[2] = {normal * 128.0f, normal * 128.0f};
// Move rect around in an arbitrary way that looks cool
- rect->pos[0] =
- (float)(width - rect->size[0] + offset[0]) *
- (sinf((float)time * rect->size[0] / 64.0f + normal) + 1.0f) /
- 2.0f;
- rect->pos[1] =
- (float)(height - rect->size[1] + offset[1]) *
- (cosf((float)time * rect->size[1] / 64.0f + normal) + 1.0f) /
- 2.0f;
+ rect->pos[0] = (width - rect->size[0] + offset[0]) *
+ (sinf((float)time * rect->size[0] / 64.0f + normal) +
+ 1.0f) /
+ 2.0f;
+ rect->pos[1] = (height - rect->size[1] + offset[1]) *
+ (cosf((float)time * rect->size[1] / 64.0f + normal) +
+ 1.0f) /
+ 2.0f;
}
glBufferSubData(GL_ARRAY_BUFFER,
diff --git a/examples/pugl_window_demo.c b/examples/pugl_window_demo.c
index 6af9e5a..183119c 100644
--- a/examples/pugl_window_demo.c
+++ b/examples/pugl_window_demo.c
@@ -63,7 +63,11 @@ onDisplay(PuglView* view)
cube->yAngle = fmod(cube->yAngle + dTime * 100.0, 360.0);
}
- displayCube(view, cube->dist, cube->xAngle, cube->yAngle, cube->entered);
+ displayCube(view,
+ cube->dist,
+ (float)cube->xAngle,
+ (float)cube->yAngle,
+ cube->entered);
cube->lastDrawTime = thisTime;
}
@@ -126,7 +130,8 @@ onEvent(PuglView* view, const PuglEvent* event)
switch (event->type) {
case PUGL_CONFIGURE:
- reshapeCube((int)event->configure.width, (int)event->configure.height);
+ reshapeCube((float)event->configure.width,
+ (float)event->configure.height);
break;
case PUGL_UPDATE:
if (app->continuous) {