I’ve been digging into Cinder quite a bit in the past few weeks. Getting comfortable with a framework comes with many moments of enlightenment. Consider this a growing list documenting such moments.
- Don’t forget to add a carriage return to the end of your
Resources.h
file. Without a hard return at the end of the file, that is, after the last resource definition, your code will not compile. Attempting to compile with Visual C++ you will see an error that looks something like this:fatal error RC1004: unexpected end of file found
- When rendering text using TextLayout, use setColor() before addLine().
- Surface::Iter does not iterate pixels in a predictable manner. Use the
getPos()
method on the iterator object to return aVec2i
and use it’s x and y properties to determine which pixel is currently being examined. Check out a recent article for more information on this. - Blending: Specifying a blend mode for a texture can be a bit tricky. Here are some combinations I’ve found that work well.
- Screen:
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
- Additive:
glBlendFunc(GL_ONE, GL_ONE);
- Multiply ( non-transparent image only ):
glBlendFunc(GL_ZERO, GL_SRC_COLOR);
Example Usage:
-
gl::enableAlphaBlending(); glBlendFunc(GL_ZERO, GL_SRC_COLOR); gl::draw( texture ); gl::disableAlphaBlending();
- Screen:
- When adding points to a Shape2d or Path2d you must set the first point using moveTo(). Your app will crash otherwise.
- You must set glLineWidth() before calling glBegin( GL_LINES )
Example Usage:glLineWidth( 10.0f ); glBegin( GL_LINES );