Home > cinder, code > Clean!

Clean!

Look how clean cinder is, love it!

#include “cinder/app/AppBasic.h”
#include “cinder/ArcBall.h”
#include “cinder/gl/gl.h”

using namespace ci;
using namespace ci::app;
using namespace std;

const int amount = 10;

class ArcBallBiApp : public AppBasic {
public:
virtual void setup();
virtual void resize(ResizeEvent event);
virtual void mouseDown(MouseEvent event);
virtual void mouseDrag(MouseEvent event);
virtual void update();
virtual void draw();

protected:
float w,h;
float wArea,hArea;

Arcball mArcBall;
float mRad;
};

void ArcBallBiApp::setup(){
w=static_cast (getWindowWidth());
h=static_cast (getWindowHeight());
wArea=w/amount;
hArea=h/amount;

mRad=100.0f;

gl::enableAlphaBlending(true);
glBlendFunc( GL_SRC_ALPHA, GL_ONE );

}

void ArcBallBiApp::resize(ResizeEvent event){
mArcBall.setWindowSize(getWindowSize());
mArcBall.setCenter(getWindowCenter());
mArcBall.setRadius(150.0f);
}

void ArcBallBiApp::mouseDown(MouseEvent event){
mArcBall.mouseDown(event.getPos());
}

void ArcBallBiApp::mouseDrag(MouseEvent event){
mArcBall.mouseDrag(event.getPos());
}

void ArcBallBiApp::update(){

}

void ArcBallBiApp::draw(){
gl::clear( Color( 0, 0, 0 ) );

for(int i=0;i<amount;i++){
for(int j=0;j<amount;j++){
float xPos =(wArea*i)+wArea;
float yPos =(wArea*j)+hArea;
glColor4f(0.5f,0.9f,1.0f,0.5f);
gl::pushMatrices();

gl::translate(Vec3f(xPos-(wArea*0.5f),
yPos-(hArea*0.5f),0.0f));
Quatf quat=mArcBall.getQuat();
gl::rotate(quat);
gl::drawCube(Vec3f::zero(),Vec3f(50.0f,50.0f,50.0f));
gl::popMatrices();
}
}

}

CINDER_APP_BASIC( ArcBallBiApp, RendererGl )

Advertisements
Categories: cinder, code
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: