1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Support 'barycoords' vertex attribute in unbuffered drawer.

This commit is contained in:
Sergey Lipskiy 2020-12-23 19:41:25 +07:00
parent 61172283c1
commit 2233cf9f04
3 changed files with 24 additions and 5 deletions

View File

@ -8,14 +8,14 @@ namespace opengl {
const GLuint texcoord = 2U;
const GLuint numlights = 3U;
const GLuint modify = 4U;
const GLuint barycoords = 8U;
const GLuint barycoords = 5U;
}
// Rect attributes
namespace rectAttrib {
const GLuint position = 5U;
const GLuint texcoord0 = 6U;
const GLuint texcoord1 = 7U;
const GLuint position = 6U;
const GLuint texcoord0 = 7U;
const GLuint texcoord1 = 8U;
const GLuint barycoords = 9U;
}
}

View File

@ -15,10 +15,12 @@ UnbufferedDrawer::UnbufferedDrawer(const GLInfo & _glinfo, CachedVertexAttribArr
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::texcoord, false);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::numlights, false);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::modify, false);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, false);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, false);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, false);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, false);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::barycoords, false);
m_attribsData.fill(nullptr);
}
@ -69,12 +71,20 @@ void UnbufferedDrawer::drawTriangles(const graphics::Context::DrawTriangleParame
glVertexAttribPointer(triangleAttrib::modify, 4, GL_BYTE, GL_FALSE, sizeof(SPVertex), ptr);
}
{
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, true);
const void * ptr = &_params.vertices->bc0;
if (_updateAttribPointer(triangleAttrib::barycoords, ptr))
glVertexAttribPointer(triangleAttrib::barycoords, 3, GL_FLOAT, GL_FALSE, sizeof(SPVertex), ptr);
}
if (isHWLightingAllowed())
glVertexAttrib1f(triangleAttrib::numlights, GLfloat(_params.vertices[0].HWLight));
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, false);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, false);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, false);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::barycoords, false);
if (config.frameBufferEmulation.N64DepthCompare != Config::dcCompatible) {
if (_params.elements == nullptr) {
@ -133,10 +143,18 @@ void UnbufferedDrawer::drawRects(const graphics::Context::DrawRectParameters & _
} else
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord1, false);
{
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::barycoords, true);
const void * ptr = &_params.vertices->bc0;
if (_updateAttribPointer(rectAttrib::barycoords, ptr))
glVertexAttribPointer(rectAttrib::barycoords, 2, GL_FLOAT, GL_FALSE, sizeof(RectVertex), ptr);
}
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::position, false);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::color, false);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::texcoord, false);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::modify, false);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, false);
glDrawArrays(GLenum(_params.mode), 0, _params.verticesCount);
}
@ -159,6 +177,7 @@ void UnbufferedDrawer::drawLine(f32 _width, SPVertex * _vertices)
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::texcoord, false);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::modify, false);
m_cachedAttribArray->enableVertexAttribArray(triangleAttrib::barycoords, false);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::position, false);
m_cachedAttribArray->enableVertexAttribArray(rectAttrib::texcoord0, false);

View File

@ -40,10 +40,10 @@ struct SPVertex
f32 r, g, b, a;
f32 flat_r, flat_g, flat_b, flat_a;
f32 s, t;
f32 bc0, bc1, bc2;
u32 modify;
u8 HWLight;
u8 clip;
f32 bc0, bc1, bc2;
s16 flag;
};