summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorfalkTX <falktx@gmail.com>2013-12-24 08:14:06 +0000
committerfalkTX <falktx@gmail.com>2013-12-24 08:14:06 +0000
commitccdee172e8f543eb41fbd9f10e275baa933cc424 (patch)
tree3090497bb9d327dea8bdad7277c6a40f09d58d0f /examples
parent49b2d5e95c464954aabb2ddd2afb0867e5e4c47d (diff)
Make the color example more useful
Now paints a full bg size and 2/3 size squares Can serve as reference to pixel data later
Diffstat (limited to 'examples')
-rw-r--r--examples/color.cpp49
-rw-r--r--examples/image.cpp6
2 files changed, 42 insertions, 13 deletions
diff --git a/examples/color.cpp b/examples/color.cpp
index cd35f6f1..fbeaa0f1 100644
--- a/examples/color.cpp
+++ b/examples/color.cpp
@@ -43,6 +43,7 @@ public:
{
}
+private:
void idleCallback() override
{
switch (cur)
@@ -96,27 +97,51 @@ public:
repaint();
}
-private:
void onDisplay() override
{
+ int x = 0;
+ int y = 0;
+ int width = getWidth();
+ int height = getHeight();
+
+ // paint bg color (in full size)
glColor3b(r, g, b);
- // full size
- const int width = getWidth();
- const int height = getHeight();
+ glBegin(GL_QUADS);
+ glTexCoord2i(x, y);
+ glVertex2i(x, y);
+
+ glTexCoord2i(x+width, y);
+ glVertex2i(x+width, y);
+
+ glTexCoord2i(x+width, y+height);
+ glVertex2i(x+width, y+height);
+
+ glTexCoord2i(x, y+height);
+ glVertex2i(x, y+height);
+ glEnd();
+
+ // centered 2/3 size
+ x = width/6;
+ y = height/6;
+ width = width*2/3;
+ height = height*2/3;
+
+ // paint invert color (in 2/3 size)
+ glColor3b(100-r, 100-g, 100-b);
glBegin(GL_QUADS);
- glTexCoord2i(0, height);
- glVertex2i(0, height);
+ glTexCoord2i(x, y);
+ glVertex2i(x, y);
- glTexCoord2i(width, height);
- glVertex2i(width, height);
+ glTexCoord2i(x+width, y);
+ glVertex2i(x+width, y);
- glTexCoord2i(width, 0);
- glVertex2i(width, 0);
+ glTexCoord2i(x+width, y+height);
+ glVertex2i(x+width, y+height);
- glTexCoord2i(0, 0);
- glVertex2i(0, 0);
+ glTexCoord2i(x, y+height);
+ glVertex2i(x, y+height);
glEnd();
}
diff --git a/examples/image.cpp b/examples/image.cpp
index 37d49f07..0fecc388 100644
--- a/examples/image.cpp
+++ b/examples/image.cpp
@@ -39,12 +39,16 @@ public:
ExampleImageWidget(Window& win)
: Widget(win)
{
+ // TODO: load image
}
-protected:
+private:
void onDisplay() override
{
+ fImage.draw();
}
+
+ Image fImage;
};
// ------------------------------------------------------