Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

Convert path to image?

$
0
0

Thanks arturo.
Yes this is for using as a point sprite.

Sorry, consider me as a noob concerning openGL thing :wink:
What do you mean by "setting the target of the fbo to GL_TEXTURE_2D when allocating it" ?
I think i found a way to set it (see below) but i don't have any clue in what it is useful !

This is what i have for now, but the saved image is messed up : the circle seems ok, but with a noisy background.

Edit : ok seems noisy background was because i didn't set a background color. So i added ofBackground(0, 0, 0, 0) with alpha set to 0 to avoid the square shape.

// Generate sprite
ofPath path;
path.arc(0, 0, radius, radius, 0, 360);
ofFbo fbo;
ofFbo::Settings settings;
settings.width = radius * 2;
settings.height = radius * 2;
settings.textureTarget = GL_TEXTURE_2D;
fbo.allocate(settings);
fbo.begin();
ofBackground(0, 0, 0, 0);
path.draw(radius, radius);
fbo.end();
ofPixels sprite;
sprite.allocate(radius * 2, radius * 2, 4);
fbo.readToPixels(sprite);
ofSaveImage(sprite, "sprite.png");

What is the point of GL_TEXTURE_2D by the way ?


Viewing all articles
Browse latest Browse all 40524

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>