|  | @@ -49,11 +49,34 @@ void tnsGet2DTextureSubImage(tnsTexture* t, int xoffset, int yoffset, uint32_t w
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      glBindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer);
 | 
	
		
			
				|  |  |      glViewport(0, 0, t->Width, t->Height);
 | 
	
		
			
				|  |  | -    glReadPixels(0, 0, width, height, format, type, pixels);
 | 
	
		
			
				|  |  | +    glReadPixels(xoffset, yoffset, width, height, format, type, pixels);
 | 
	
		
			
				|  |  | +    glBindFramebuffer(GL_FRAMEBUFFER, 0);
 | 
	
		
			
				|  |  | +    glDeleteFramebuffers(1, &offscreen_framebuffer);
 | 
	
		
			
				|  |  |  #else
 | 
	
		
			
				|  |  |      glGetTextureSubImage(texture,0,xoffset,yoffset,0,width,height,1,format,type,bufSize,pixels);
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | +void tnsClearTextureImage(tnsTexture* t, int tex_format, int tex_bits_type){
 | 
	
		
			
				|  |  | +    int texture=t->GLTexHandle;
 | 
	
		
			
				|  |  | +#ifdef LA_USE_GLES
 | 
	
		
			
				|  |  | +    int offscreen_framebuffer;
 | 
	
		
			
				|  |  | +    glGenFramebuffers(1, &offscreen_framebuffer);
 | 
	
		
			
				|  |  | +    glBindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer);
 | 
	
		
			
				|  |  | +    glBindTexture(GL_TEXTURE_2D, texture);
 | 
	
		
			
				|  |  | +    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
 | 
	
		
			
				|  |  | +    GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
 | 
	
		
			
				|  |  | +    if(status != GL_FRAMEBUFFER_COMPLETE) {
 | 
	
		
			
				|  |  | +        logPrint("Failed to make complete framebuffer object in la_glGetTextureSubImage()", status);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    glBindFramebuffer(GL_FRAMEBUFFER, offscreen_framebuffer);
 | 
	
		
			
				|  |  | +    glViewport(0, 0, t->Width, t->Height);
 | 
	
		
			
				|  |  | +    glClearColor(0,0,0,0); glClear(GL_COLOR_BUFFER_BIT);
 | 
	
		
			
				|  |  | +    glBindFramebuffer(GL_FRAMEBUFFER, 0);
 | 
	
		
			
				|  |  | +    glDeleteFramebuffers(1, &offscreen_framebuffer);
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +    glClearTexImage(t->GLTexHandle,0,tex_format,tex_bits_type,0);
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  //  1  2
 |