Home > cpp, touchdesigner > Cinder to touchdesigner # 2

Cinder to touchdesigner # 2

note: I will migrate this blog to my webpage very soon thus having a proper display of the source code.

Next step on having a kind of template for porting OFW/Cinder patches into TD. So, I have the next class called ‘Lines’:


#pragma once
#include “TOP_CPlusPlusBase.h”

class Lines
{
public:
Lines();
~Lines();

virtual void draw(int _x1, int _y1, int _x2, int _y2);

int x1,x2,y1,y2;

};

the body of the class:

#include “Lines.h”

Lines::Lines(){
x1 = x2 = y2 = y1 = 0;
}

Lines::~Lines(){

}

void Lines::draw(int _x1, int _y1, int _x2, int _y2){

x1 = _x1;
y1 = _y1;
x2 = _x2;
y2 = _y2;

::glVertex2i(x1,y1);
::glVertex2i(x2,y2);
}

then i declare a vector on the Parent class:

std::vector mLines;

body:

for(unsigned int i=0;i<amount;i++){
//starting all the lines as 0 value
mLines.push_back(Lines());
}

and the calling the drawing method within the execution loop:

::glBegin(GL_LINES);
::glLineWidth(1.0f);

for(unsigned int i=0; i < amount; i++;
int _y1 = rand()% outputFormat->height;
int _x2 = rand()% outputFormat->width;
int _y2 = rand()% outputFormat->height;

mLines[i].draw(_x1, _y1, _x2, _y2);
}
::glEnd();

::glBegin(GL_LINE_LOOP);
::glVertex2i(0,0);
::glVertex2i(outputFormat -> width, outputFormat->height);
::glEnd();

next step might be to implement containers with pointers and shared pointers.

Advertisements
Categories: cpp, touchdesigner
  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: