// Functions to create a couple of images to use as textures.. static Image createLogoImage() { Image image (Image::ARGB, 256, 256, true, OpenGLImageType()); if (image.isValid()) { Graphics g (image); g.fillAll (Colours::lightgrey.withAlpha (0.8f)); g.drawImageWithin (ImageFileFormat::loadFrom (BinaryData::juce_png, BinaryData::juce_pngSize), 0, 0, image.getWidth(), image.getHeight(), RectanglePlacement::stretchToFit); drawRandomStars (g, image.getWidth(), image.getHeight()); } return image; }
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; }
// when the component creates a new internal context, this is called, and // we'll use the opportunity to create some images to use as textures. void newOpenGLContextCreated() { logoImage = createLogoImage(); dynamicTextureImage = Image (Image::ARGB, 128, 128, true, OpenGLImageType()); }