bool OpenGLES2Texture::updateImageBuffer()
{
    /* Update dimension and format */
    const bool ReCreateTexture = (GLDimension_ != GLBasePipeline::getGlTexDimension(Type_));
    
    updateFormatAndDimension();
    
    if (ReCreateTexture)
        createHWTexture();
    
    /* Clear the image data */
    glBindTexture(GLDimension_, getTexID());
    
    /* Update format and texture image */
    updateTextureAttributes();
    updateTextureImage();
    
    /* Update render target (create/delete) */
    deleteFramebuffer();
    
    if (isRenderTarget_)
    {
        createFramebuffer(
            getTexID(), ImageBuffer_->getSize(), GLDimension_, ImageBuffer_->getFormat(),
            Type_, CubeMapFace_, ArrayLayer_,
            DepthBufferSource_ ? static_cast<OpenGLES2Texture*>(DepthBufferSource_)->DepthBufferID_ : 0
        );
    }
    
    return true;
}
bool OpenGLTexture::updateImageBuffer()
{
    /* Update dimension and format */
    const bool ReCreateTexture = (GLDimension_ != GLBasePipeline::getGlTexDimension(Type_));
    
    updateFormatAndDimension();
    
    if (ReCreateTexture)
        createHWTexture();
    
    /* Bind texture */
    glBindTexture(GLDimension_, getTexID());
    
    /* Update hardware texture settings */
    updateTextureAttributes();
    updateTextureImage();
    
    /* Update render target (create/delete) */
    if (GlbRenderSys->RenderQuery_[RenderSystem::RENDERQUERY_RENDERTARGET])
        updateRenderTarget();
    
    /* Unbind texture */
    glBindTexture(GLDimension_, 0);
    
    return true;
}
Example #3
0
void Target_keyDown(unsigned int charCode, unsigned int keyCode) {
	if (charCode == '[') {
		cycleTextures(-1);
		
	} else if (charCode == ']') {
		cycleTextures(1);
		
	} else if (charCode == '{') {
		cycleAutoBlendModes(-1);
		
	} else if (charCode == '}') {
		cycleAutoBlendModes(1);
		
	} else if (charCode == ',') {
		cycleMinFilters(-1);
		
	} else if (charCode == '.') {
		cycleMinFilters(1);
		
	} else if (charCode == '<') {
		cycleMagFilters(-1);
		
	} else if (charCode == '>') {
		cycleMagFilters(1);
		
	} else if (keyCode == KEYBOARD_LEFT_ARROW) {
		cycleWrapS(-1);
		
	} else if (keyCode == KEYBOARD_RIGHT_ARROW) {
		cycleWrapS(1);
		
	} else if (keyCode == KEYBOARD_DOWN_ARROW) {
		cycleWrapT(-1);
		
	} else if (keyCode == KEYBOARD_UP_ARROW) {
		cycleWrapT(1);
		
	} else if (keyCode == KEYBOARD_M) {
		toggleAutoMipmap();
		
	} else if (keyCode == KEYBOARD_A) {
		toggleAnisotropy();
		
	} else if (keyCode == KEYBOARD_E) {
		toggleExtendedTexCoords();
		
	} else if (keyCode == KEYBOARD_B) {
		toggleBackgroundColor();
		
	} else if (keyCode == KEYBOARD_Z) {
		toggleZoomLevel();
		
	} else if (keyCode == KEYBOARD_S) {
		updateTextureImage();
	}
}
Example #4
0
void Target_mouseDown(unsigned int buttonNumber, float x, float y) {
	if (iPhoneMode) {
		if (x < viewportHeight / 6) {
			if (y > viewportHeight - viewportHeight / 6 * 1) {
				cycleTextures(1);
				
			} else if (y > viewportHeight - viewportHeight / 6 * 2) {
				cycleAutoBlendModes(1);
				
			} else if (y > viewportHeight - viewportHeight / 6 * 3) {
				cycleMinFilters(1);
				
			} else if (y > viewportHeight - viewportHeight / 6 * 4) {
				cycleMagFilters(1);
				
			} else if (y > viewportHeight - viewportHeight / 6 * 5) {
				cycleWrapS(1);
				
			} else {
				cycleWrapT(1);
			}
			
		} else if (x > viewportWidth - viewportHeight / 6) {
			if (y > viewportHeight - viewportHeight / 6 * 1) {
				toggleAutoMipmap();
				
			} else if (y > viewportHeight - viewportHeight / 6 * 2) {
				toggleAnisotropy();
				
			} else if (y > viewportHeight - viewportHeight / 6 * 3) {
				toggleExtendedTexCoords();
				
			} else if (y > viewportHeight - viewportHeight / 6 * 4) {
				toggleBackgroundColor();
				
			} else if (y > viewportHeight - viewportHeight / 6 * 5) {
				toggleZoomLevel();
				
			} else {
				updateTextureImage();
			}
		}
	}
}
Example #5
0
    void renderOpenGL()
    {
        OpenGLHelpers::clear (Colours::darkgrey.withAlpha (1.0f));

        updateTextureImage();  // this will update our dynamically-changing texture image.
        drawBackground2DStuff(); // draws some 2D content to demonstrate the OpenGLGraphicsContext class

        // Having used the juce 2D renderer, it will have messed-up a whole load of GL state, so
        // we'll put back any important settings before doing our normal GL 3D drawing..
        glEnable (GL_DEPTH_TEST);
        glDepthFunc (GL_LESS);
        glEnable (GL_BLEND);
        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glEnable (GL_TEXTURE_2D);

       #if JUCE_USE_OPENGL_FIXED_FUNCTION
        OpenGLHelpers::prepareFor2D (getContextWidth(), getContextHeight());
        OpenGLHelpers::setPerspective (45.0, getContextWidth() / (double) getContextHeight(), 0.1, 100.0);

        glTranslatef (0.0f, 0.0f, -5.0f);
        draggableOrientation.applyToOpenGLMatrix();

        // logoImage and dynamicTextureImage are actually OpenGL images, so we can use this utility function to
        // extract the frame buffer which is their backing store, and use it directly.
        OpenGLFrameBuffer* tex1 = OpenGLImageType::getFrameBufferFrom (logoImage);
        OpenGLFrameBuffer* tex2 = OpenGLImageType::getFrameBufferFrom (dynamicTextureImage);

        if (tex1 != nullptr && tex2 != nullptr)
        {
            // This draws the sides of our spinning cube.
            // I've used some of the juce helper functions, but you can also just use normal GL calls here too.
            tex1->draw3D (-1.0f,  1.0f,  1.0f, -1.0f, -1.0f,  1.0f,  1.0f, -1.0f,  1.0f,  1.0f,  1.0f,  1.0f, Colours::white);
            tex1->draw3D (-1.0f,  1.0f, -1.0f,  1.0f,  1.0f, -1.0f,  1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, Colours::white);
            tex1->draw3D (-1.0f, -1.0f, -1.0f,  1.0f, -1.0f, -1.0f,  1.0f, -1.0f,  1.0f, -1.0f, -1.0f,  1.0f, Colours::white);
            tex2->draw3D (-1.0f,  1.0f, -1.0f, -1.0f,  1.0f,  1.0f,  1.0f,  1.0f,  1.0f,  1.0f,  1.0f, -1.0f, Colours::white);
            tex2->draw3D ( 1.0f,  1.0f, -1.0f,  1.0f,  1.0f,  1.0f,  1.0f, -1.0f,  1.0f,  1.0f, -1.0f, -1.0f, Colours::white);
            tex2->draw3D (-1.0f,  1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f, -1.0f,  1.0f, -1.0f,  1.0f,  1.0f, Colours::white);
        }
       #endif
    }