grabScreen crash

#1

I’m trying to use the .grabScreen to save the screen view into an image file for export. Using Openframeworks on Visual Studio 17.

I get a crash when the dimensions of the grab are 1675 x 950, which seem pretty small to me - what would be causing this? Is there any way to avoid it?

S

#2

alternatively, is there a way to draw to an fbo using a 3d camera? (for later porting to pixels/ofImage export)

I am attempting the following, but the fbo seems to come out empty. Am I doing something wrong? (tD_GraphCam is an easyCam object)

              ofFbo grabGraph;
                grabGraph.allocate(V_width, V_height);
                grabGraph.begin();
                
                    tD_GraphCam.begin();
                    tD_GraphCam.setFarClip(20000);
                    tD_GraphCam.setNearClip(0);
                    ofSetColor(255, 0, 0);
                    ofFill();
                    ofDrawCircle(0,0,500);
                    tD_GraphCam.end();
                
                grabGraph.end();
                
				ofRectangle outputsize(0, 0, V_width, V_height);
				ofBeginSaveScreenAsPDF(saveTiffResult.filePath, false, false, outputsize);
				ofSetColor(255);
				ofPushMatrix();
				ofEnableSmoothing();
				ofEnableAntiAliasing();
                grabGraph.draw(0,0);
				ofDisableSmoothing();
				ofDisableAntiAliasing();
				ofPopMatrix();
				ofEndSaveScreenAsPDF();
#3

pdf rendering doesn’t allow textures since textures are an opengl concept that the pdf renderer doesn’t know anything about you need to download the texture to pixels first to be able to draw it.

The crash could be cause you are using a different format to download than the one the texture is in, usually one that is bigger, like the texture is rgb but you are downloading as rgba.

Also sometimes textures with weird sizes might have a padding to make the size something that the graphics card supports, so downloading it would try to download a bigger size. I’ve never seen this in opengl but perhaps try allocating a bigger texture with a more standard size even if you then only use 1675x950

#4

Aaaah, interesting on the format front. Might be it…

On the Fbo pdf export issue I’ve just done:

                ofPixels pixels;
                ofImage img;
                grabGraph.readToPixels(pixels);
                img.setFromPixels(pixels);

and then draw img in the pdf draw - this solves it.
Hopefully this approach will fix my crash anyway, have replaced the grab screen functions all the way through now…

S