C++ / OpenFrameworks
Posted: 06 April 2013 03:56 PM
Member
RankRankRank
Total Posts:  62
Joined  2012-09-11

Hi! I intend for this thread to be a central place for everyone who is (like me) struggling to get the hang of this C++/ OF thing.

So this is the place to ask questions and share tips and advice about setting up and working with Open Frameworks, your IDE or C++ in general, or just a place to vent some anger and frustration >_<.

So first off, I want to share some links with y’all:
http://www.cplusplus.com/ You’ve probably been here, the authority on C++.
http://www.programminghelp.org/c++/ These are very good tutorials, unlike many other Youtube tutorials this guys voice isnt a total drag to listen to and his tutorials don’t actually stop after ‘loops and variables’, it starts off pretty easy but a lot of aspects of the language are covered. It’s better to go to youtube and view them in 720p.

glhf!

Profile
 
 
Posted: 07 April 2013 01:46 PM   [ # 1 ]
Member
RankRankRank
Total Posts:  62
Joined  2012-09-11

I got this site with many examples for all levels, courtesy of Jasper who couldnt log in

https://sites.google.com/site/ofauckland/examples

Profile
 
 
Posted: 08 April 2013 06:37 PM   [ # 2 ]
Newbie
Rank
Total Posts:  20
Joined  2010-02-17

After working with OpenFrameworks for quite a while I recently switched to Cinder, which has a little steeper learning curve but is set up more consistent and future -proof. (I am looking forward to the version that will be released in the coming week)

It uses the std and boost libraries a lot and is compatible with c++11 (which makes stuff a lot easier I think).

But, back to resources: Stackoverflow is a great forum and of course the OF and Cinder forums.

Call me old-fashioned but the best way is still to read a book. Especially if you want to understand about pointers, references and copying which is really important to understand if you want optimize your program. I read this book http://amzn.com/0672329417 which has some nice basics and also covers some of the std library (vectors & strings).

Remember that OpenFrameworks is just a collection of convience functions/objects on top of c++. So to use it to the max you should really read a bit into c++ as well.

Talking about IDE: I love Xcode and like Visual Studio 2012. In Xcode the settings are a bit more clear. The most important settings are the compiler used, the sdk which is used, the header search paths (telling the compiler where needed files can be found) and linker setting (which combines all the little pieces of code into a program). But if you use the tools distributed with openframeworks and cinder to create a project you are usually just fine.

Profile
 
 
Posted: 09 April 2013 09:29 PM   [ # 3 ]
Newbie
Rank
Total Posts:  17
Joined  2012-09-11

Ok, let me be the first to post a problem.

Today I struggled with a video I want to use withing open frameworks.
It is a mov file, since the video player of OF is said to be Quicktime (and mov can handle transparency too).
The video is of an explosion and the background is transparent, because I want to play it on top of another image.
However, whenever I load and play it in open frameworks (ofVideoPlayer) the background is NOT transparent.
Instead it renders a black background.
I couldn’t find any functions for the player to adjust this ( http://www.openframeworks.cc/documentation/video/ofVideoPlayer.html )

I am totally sure my .mov actually has transparency, as I checked that by loading it in After Effects.
And yes, I have enabled alpha blending (ofEnableAlphaBlending(); ) which works perfectly with partially transparent PNG images.
In all despair I exported the movie as a sequence of 100 PNG images, and in my application I loaded all of them in an image array and play all of them one by one to get the effect I wanted.

This is of course extremely n00b and tedious, so if someone knows how to display the transparency from the original mov file within OF I would appreciate it a lot.

Profile
 
 
Posted: 09 April 2013 09:59 PM   [ # 4 ]
Newbie
Rank
Total Posts:  20
Joined  2010-02-17

Have you tried setting the pixel format to OF_PIXELS_RGBA before loading the movie (by default this is set to OF_PIXELS_RGB).

Are you on Windows? I know that OF 0072 only supports alpha on Mac, not sure about version 0073… The Mac version uses QTKit if I am not mistaken, otherwise you can force it to use that of course.

Profile
 
 
Posted: 09 April 2013 10:34 PM   [ # 5 ]
Newbie
Rank
Total Posts:  17
Joined  2012-09-11

thanks for the reply!

I didn’t try that before.
Just now I tried both the general ofPixelFormat(OF_PIXELS_RGBA); and myPlayer.setPixelFormat(OF_PIXELS_RGBA); in setup() before loading the video, but they don’t make a difference.

I am on Windows 7 and OF 7.4

I don’t know about QTKit or how I can force my OF to use it.

On a side note, never would I have guessed on my own I can enter “OF_PIXELS_RGBA” in the setPixelFormat function.

The documentation on that function just says:

setPixelFormat(...)
bool ofVideoPlayer::setPixelFormat(ofPixelFormat pixelFormat)

And there are many functions in the documentation described like that, with just the parameters it takes as input but no further explanation.
How are we, as beginners, supposed to find out the usage?

Profile
 
 
Posted: 09 April 2013 11:08 PM   [ # 6 ]
Newbie
Rank
Total Posts:  20
Joined  2010-02-17
Emiel - 09 April 2013 10:34 PM

thanks for the reply!
I am on Windows 7 and OF 7.4

I don’t know about QTKit or how I can force my OF to use it.

I am not in reach of a Windows machine right now, but my guess is that QTKit is not supported the same on Windows as on Mac..

Emiel - 09 April 2013 10:34 PM

thanks for the reply!
On a side note, never would I have guessed on my own I can enter “OF_PIXELS_RGBA” in the setPixelFormat function.

The documentation on that function just says:

setPixelFormat(...)
bool ofVideoPlayer::setPixelFormat(ofPixelFormat pixelFormat)

And there are many functions in the documentation described like that, with just the parameters it takes as input but no further explanation.
How are we, as beginners, supposed to find out the usage?

That is the tricky part. Not all functions are commented correctly and this is clearly one of those things for which you need a little bit more knowledge about how things work under the hood. In this case an image is not just an image but a series of pixels which consist of bytes and those bytes can be RGB, RGBA, ARGB, YUV and many many more.. But you were thinking in the right direction with turning on the alpha blending. The problem here is that the alpha layer from your movie doesn’t get read at all, so it won’t get rendered (or not, depends how you look at it)

Profile
 
 
Posted: 09 April 2013 11:25 PM   [ # 7 ]
Newbie
Rank
Total Posts:  17
Joined  2012-09-11

Thanks for the explanation.
We also have a mac user in our project group so we can give that a try.
I can also still resort to the png sequence, hehe

If certain key features like this video alpha by default only work on Mac, I don’t feel like working in OF in the future…

Profile