sivabudh
sivabudh

Reputation: 32635

How do you translate this code from Processing to C++?

I wrote this code in Processing (www.processing.org) and was wondering how would one implement it using C++?

int i = 0;

void setup()
{
size(1000,1000);
}

void draw()
{
//  frameRate(120);
  PImage slice = get();
  set(0,20,slice);  

  if( i % 2 == 0 )  fill(128); else fill(0);
  i++;
  rect(0,0,width,20);
}

As you can see this simply scrolls down rectangles of alternating colors as fast as possible. Can the C++ implementation be as short? OpenGL?

Upvotes: 0

Views: 2080

Answers (3)

SingleNegationElimination
SingleNegationElimination

Reputation: 156128

I'd probably use SDL for this. Your program will be a little longer, because you'll have to do some setup and tear-down on your own (plenty of good examples, though). You could do the same with OpenGL, but it would be quite a bit more work. If you go that route, NeHe Productions offers practically the gold standard in OpenGL tutorials.

Upvotes: 3

rotoglup
rotoglup

Reputation: 5238

You could also take a look at OpenFrameworks but I doubt that any C++ library will give you such a short implementation.

Upvotes: 3

Mike Lowen
Mike Lowen

Reputation: 847

Depends if you are counting all of the setup/teardown code as well, if you are then definitely not, even not counting it I would still doubt it.

Upvotes: 0

Related Questions