1 Screenshot
2 Source code
/*
* ColorModel.cpp
* Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED.
*/
//2017/02/10 Updated.
#include <viz++/opengl/OpenGLMainView.h>
#include <viz++/opengl/OpenGLGC.h>
namespace VIZ {
class MainView :public OpenGLMainView {
private:
SmartPtr<OpenGLGC> gc;
public:
void display()
{
if (gc) {
gc -> clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gc -> clearColor(1.0, 1.0, 1.0, 1.0);
//int num = 256;
int num = 32;
for (int r = -num; r<num; r++) {
for(int g = -num; g<num; g++) {
for(int b = -num; b<num; b++) {
GLfloat fr = (GLfloat)r/(GLfloat)num;
GLfloat fg = (GLfloat)g/(GLfloat)num;
GLfloat fb = (GLfloat)b/(GLfloat)num;
gc -> color(fr, fg, fb);
GLfloat x = (fb + fr)/2.0;
GLfloat y = (fg + fr)/2.0;
gc -> smoothLine(x, -y, x + 0.02f, -y - 0.02f, 0.02f);
}
}
}
}
}
public:
//2015/07/22
void idle()
{
Sleep(100);
}
public:
void initialize()
{
gc = new OpenGLGC();
}
public:
MainView(OpenGLApplet& applet, int width, int height, const char* name)
:OpenGLMainView(applet, width, height, name)
{
}
~MainView()
{
}
};
}
//
int main(int argc, char** argv)
{
try {
ModuleFileName module;
const char* name = module.getAppName();
OpenGLApplet applet(argc, argv, OpenGLApplet::WAIT_EVENTS);
MainView view(applet, 300, 300, name);
view.realize();
applet.run();
} catch (Exception& ex) {
caught(ex);
}
return 0;
}
Last modified: 10 Feb 2017
Copyright (c) 2017 Antillia.com ALL RIGHTS RESERVED.