tags:

views:

293

answers:

3

Hi,

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?

+3  A: 

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.

TokenMacGuy
A: 

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.

Mike Lowen
+2  A: 

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

rotoglup
I'd always look at openframeworks when converting processing code to c++. It is quite similar.
razong