static void read (OpenGLFrameBuffer& frameBuffer, Image::BitmapData& bitmapData, int x, int y)
        {
            frameBuffer.readPixels ((PixelARGB*) bitmapData.data,
                                    Rectangle<int> (x, frameBuffer.getHeight() - (y + bitmapData.height), bitmapData.width, bitmapData.height));

            verticalRowFlip ((PixelARGB*) bitmapData.data, bitmapData.width, bitmapData.height);
        }
Example #2
0
void FGLRenderer::ClearBorders()
{
	OpenGLFrameBuffer *glscreen = static_cast<OpenGLFrameBuffer*>(screen);

	// Letterbox time! Draw black top and bottom borders.
	int width = glscreen->GetWidth();
	int height = glscreen->GetHeight();
	int trueHeight = glscreen->GetTrueHeight();

	int borderHeight = (trueHeight - height) / 2;

	glViewport(0, 0, width, trueHeight);
	gl_RenderState.mProjectionMatrix.loadIdentity();
	gl_RenderState.mProjectionMatrix.ortho(0.0f, width * 1.0f, 0.0f, trueHeight, -1.0f, 1.0f);
	gl_RenderState.SetColor(0.f ,0.f ,0.f ,1.f);
	gl_RenderState.Set2DMode(true);
	gl_RenderState.EnableTexture(false);
	gl_RenderState.Apply();
	gl_RenderState.ApplyMatrices(); 

	FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
	ptr->Set(0, borderHeight, 0, 0, 0); ptr++;
	ptr->Set(0, 0, 0, 0, 0); ptr++;
	ptr->Set(width, 0, 0, 0, 0); ptr++;
	ptr->Set(width, borderHeight, 0, 0, 0); ptr++;
	GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
	ptr->Set(0, trueHeight, 0, 0, 0); ptr++;
	ptr->Set(0, trueHeight - borderHeight, 0, 0, 0); ptr++;
	ptr->Set(width, trueHeight - borderHeight, 0, 0, 0); ptr++;
	ptr->Set(width, trueHeight, 0, 0, 0); ptr++;
	GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
	gl_RenderState.EnableTexture(true);

	glViewport(0, (trueHeight - height) / 2, width, height); 
}
Image MaxOpenGlComponent::makeScreenshot(t_object* x, double width, double height)
{
    Image img;

    if(!m_context->isActive())
        return img;
	
    setBounds(-width, -height, width, height);
    img = Image(OpenGLImageType().create(Image::ARGB, roundToInt(width * m_scale), roundToInt(height * m_scale), true));
    OpenGLFrameBuffer* buffer = OpenGLImageType::getFrameBufferFrom(img);
   
    buffer->makeCurrentAndClear();

    (object_getmethod(x, gensym("jucebox_paint")))(x, width * m_scale, height * m_scale);
	
    buffer->releaseAsRenderingTarget();
    return img;
}
Example #4
0
void FGLRenderer::ClearBorders()
{
	OpenGLFrameBuffer *glscreen = static_cast<OpenGLFrameBuffer*>(screen);

	// Letterbox time! Draw black top and bottom borders.
	int width = glscreen->GetWidth();
	int height = glscreen->GetHeight();
	int trueHeight = glscreen->GetTrueHeight();

	int borderHeight = (trueHeight - height) / 2;

	gl.Viewport(0, 0, width, trueHeight);
	gl.MatrixMode(GL_PROJECTION);
	gl.LoadIdentity();
	gl.Ortho(0.0, width * 1.0, 0.0, trueHeight, -1.0, 1.0);
	gl.MatrixMode(GL_MODELVIEW);
	gl.Color3f(0.f, 0.f, 0.f);
	gl_RenderState.Set2DMode(true);
	gl_RenderState.EnableTexture(false);
	gl_RenderState.Apply(true);

	gl.Begin(GL_QUADS);
	// upper quad
	gl.Vertex2i(0, borderHeight);
	gl.Vertex2i(0, 0);
	gl.Vertex2i(width, 0);
	gl.Vertex2i(width, borderHeight);

	// lower quad
	gl.Vertex2i(0, trueHeight);
	gl.Vertex2i(0, trueHeight - borderHeight);
	gl.Vertex2i(width, trueHeight - borderHeight);
	gl.Vertex2i(width, trueHeight);
	gl.End();

	gl_RenderState.EnableTexture(true);

	gl.Viewport(0, (trueHeight - height) / 2, width, height); 
}