File diff r24881:5db3ebe7cd4e → r24882:93b227b5ef29
src/video/opengl.cpp
Show inline comments
 
@@ -15,24 +15,25 @@
 
#	include <windows.h>
 
#endif
 

	
 
#if defined(__APPLE__)
 
#	include <OpenGL/gl3.h>
 
#else
 
#	include <GL/gl.h>
 
#endif
 
#include "../3rdparty/opengl/glext.h"
 

	
 
#include "opengl.h"
 
#include "../core/mem_func.hpp"
 
#include "../core/geometry_func.hpp"
 
#include "../gfx_func.h"
 
#include "../debug.h"
 

	
 
#include "../safeguards.h"
 

	
 

	
 
static PFNGLDEBUGMESSAGECONTROLPROC _glDebugMessageControl;
 
static PFNGLDEBUGMESSAGECALLBACKPROC _glDebugMessageCallback;
 

	
 
/* static */ OpenGLBackend *OpenGLBackend::instance = nullptr;
 

	
 
GetOGLProcAddressProc GetOGLProcAddress;
 
@@ -283,28 +284,31 @@ bool OpenGLBackend::Resize(int w, int h,
 

	
 
	/* Set new viewport. */
 
	_screen.height = h;
 
	_screen.width = w;
 
	_screen.pitch = w;
 
	_screen.dst_ptr = this->GetVideoBuffer();
 

	
 
	return true;
 
}
 

	
 
/**
 
 * Render video buffer to the screen.
 
 * @param update_rect Rectangle encompassing the dirty region of the video buffer.
 
 */
 
void OpenGLBackend::Paint()
 
void OpenGLBackend::Paint(Rect update_rect)
 
{
 
	assert(this->vid_buffer != nullptr);
 

	
 
	glClear(GL_COLOR_BUFFER_BIT);
 

	
 
	/* Update changed rect of the video buffer texture. */
 
	glBindTexture(GL_TEXTURE_2D, this->vid_texture);
 
	glPixelStorei(GL_UNPACK_ROW_LENGTH, _screen.pitch);
 
	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _screen.width, _screen.height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, this->vid_buffer);
 
	if (!IsEmptyRect(update_rect)) {
 
		glPixelStorei(GL_UNPACK_ROW_LENGTH, _screen.pitch);
 
		glTexSubImage2D(GL_TEXTURE_2D, 0, update_rect.left, update_rect.top, update_rect.right - update_rect.left, update_rect.bottom - update_rect.top, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (uint32 *)this->vid_buffer + update_rect.top * _screen.pitch + update_rect.left);
 
	}
 

	
 
	/* Blit video buffer to screen. */
 
	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
 
}