- refactored all 2D drawing to use its own vertex buffer which does not need to be mapped permanently.

This commit is contained in:
Christoph Oelckers 2016-08-08 12:13:09 +02:00
commit def3ad7533
10 changed files with 630 additions and 392 deletions

View file

@ -64,6 +64,7 @@
#include "gl/utility/gl_clock.h"
#include "gl/utility/gl_templates.h"
#include "gl/gl_functions.h"
#include "gl/renderer/gl_2ddrawer.h"
IMPLEMENT_CLASS(OpenGLFrameBuffer)
EXTERN_CVAR (Float, vid_brightness)
@ -386,7 +387,8 @@ bool OpenGLFrameBuffer::Begin2D(bool)
void OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms)
{
if (GLRenderer != NULL) GLRenderer->DrawTexture(img, parms);
if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr)
GLRenderer->m2DDrawer->AddTexture(img, parms);
}
//==========================================================================
@ -396,8 +398,8 @@ void OpenGLFrameBuffer::DrawTextureParms(FTexture *img, DrawParms &parms)
//==========================================================================
void OpenGLFrameBuffer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, uint32 color)
{
if (GLRenderer != NULL)
GLRenderer->DrawLine(x1, y1, x2, y2, palcolor, color);
if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr)
GLRenderer->m2DDrawer->AddLine(x1, y1, x2, y2, palcolor, color);
}
//==========================================================================
@ -407,8 +409,8 @@ void OpenGLFrameBuffer::DrawLine(int x1, int y1, int x2, int y2, int palcolor, u
//==========================================================================
void OpenGLFrameBuffer::DrawPixel(int x1, int y1, int palcolor, uint32 color)
{
if (GLRenderer != NULL)
GLRenderer->DrawPixel(x1, y1, palcolor, color);
if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr)
GLRenderer->m2DDrawer->AddPixel(x1, y1, palcolor, color);
}
//==========================================================================
@ -425,8 +427,8 @@ void OpenGLFrameBuffer::Dim(PalEntry)
void OpenGLFrameBuffer::Dim(PalEntry color, float damount, int x1, int y1, int w, int h)
{
if (GLRenderer != NULL)
GLRenderer->Dim(color, damount, x1, y1, w, h);
if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr)
GLRenderer->m2DDrawer->AddDim(color, damount, x1, y1, w, h);
}
//==========================================================================
@ -437,8 +439,8 @@ void OpenGLFrameBuffer::Dim(PalEntry color, float damount, int x1, int y1, int w
void OpenGLFrameBuffer::FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin)
{
if (GLRenderer != NULL)
GLRenderer->FlatFill(left, top, right, bottom, src, local_origin);
if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr)
GLRenderer->m2DDrawer->AddFlatFill(left, top, right, bottom, src, local_origin);
}
//==========================================================================
@ -448,8 +450,8 @@ void OpenGLFrameBuffer::FlatFill (int left, int top, int right, int bottom, FTex
//==========================================================================
void OpenGLFrameBuffer::Clear(int left, int top, int right, int bottom, int palcolor, uint32 color)
{
if (GLRenderer != NULL)
GLRenderer->Clear(left, top, right, bottom, palcolor, color);
if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr)
GLRenderer->m2DDrawer->AddClear(left, top, right, bottom, palcolor, color);
}
//==========================================================================
@ -464,10 +466,9 @@ void OpenGLFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, int
double originx, double originy, double scalex, double scaley,
DAngle rotation, FDynamicColormap *colormap, int lightlevel)
{
if (GLRenderer != NULL)
if (GLRenderer != nullptr && GLRenderer->m2DDrawer != nullptr && npoints >= 3)
{
GLRenderer->FillSimplePoly(texture, points, npoints, originx, originy, scalex, scaley,
rotation, colormap, lightlevel);
GLRenderer->m2DDrawer->AddPoly(texture, points, npoints, originx, originy, scalex, scaley, rotation, colormap, lightlevel);
}
}