Fix OpenGL core profile issue with glLineWidth by Rye Mutt

master
Ansariel 2020-10-18 01:11:13 +02:00
parent afdcfb4961
commit ac94268e5e
14 changed files with 90 additions and 55 deletions

View File

@ -1096,7 +1096,8 @@ LLRender::LLRender()
//mQuadCycle(0), // <FS:Ansariel> Remove QUADS rendering mode
mMode(LLRender::TRIANGLES),
mCurrTextureUnitIndex(0),
mMaxAnisotropy(0.f)
mMaxAnisotropy(0.f),
mLineWidth(1.f) // <FS> Line width OGL core profile fix by Rye Mutt
{
mTexUnits.reserve(LL_NUM_TEXTURE_LAYERS);
for (U32 i = 0; i < LL_NUM_TEXTURE_LAYERS; i++)
@ -1888,6 +1889,25 @@ void LLRender::setAmbientLightColor(const LLColor4& color)
}
}
// <FS> Line width OGL core profile fix by Rye Mutt
void LLRender::setLineWidth(F32 line_width)
{
if (LLRender::sGLCoreProfile)
{
line_width = 1.f;
}
if (mLineWidth != line_width || mDirty)
{
if (mMode == LLRender::LINES || mMode == LLRender::LINE_STRIP)
{
flush();
}
mLineWidth = line_width;
glLineWidth(line_width);
}
}
// </FS>
bool LLRender::verifyTexUnitActive(U32 unitToVerify)
{
if (mCurrTextureUnitIndex == unitToVerify)

View File

@ -456,6 +456,8 @@ public:
LLLightState* getLight(U32 index);
void setAmbientLightColor(const LLColor4& color);
void setLineWidth(F32 line_width); // <FS> Line width OGL core profile fix by Rye Mutt
LLTexUnit* getTexUnit(U32 index);
U32 getCurrentTexUnitIndex(void) const { return mCurrTextureUnitIndex; }
@ -499,6 +501,7 @@ private:
bool mCurrColorMask[4];
eCompareFunc mCurrAlphaFunc;
F32 mCurrAlphaFuncVal;
F32 mLineWidth; // <FS> Line width OGL core profile fix by Rye Mutt
LLPointer<LLVertexBuffer> mBuffer;
LLStrider<LLVector3> mVerticesp;

View File

@ -972,7 +972,7 @@ void gl_stippled_line_3d( const LLVector3& start, const LLVector3& end, const LL
gGL.color4f(color.mV[VRED], color.mV[VGREEN], color.mV[VBLUE], color.mV[VALPHA]);
gGL.flush();
glLineWidth(2.5f);
gGL.setLineWidth(2.5f); // <FS> Line width OGL core profile fix by Rye Mutt
if (!LLGLSLShader::sNoFixedFunction)
{
@ -2072,8 +2072,10 @@ void LLRender2D::setScaleFactor(const LLVector2 &scale_factor)
void LLRender2D::setLineWidth(F32 width)
{
gGL.flush();
glLineWidth(width * lerp(mGLScaleFactor.mV[VX], mGLScaleFactor.mV[VY], 0.5f));
// <FS> Line width OGL core profile fix by Rye Mutt
//gGL.flush();
//glLineWidth(width * lerp(mGLScaleFactor.mV[VX], mGLScaleFactor.mV[VY], 0.5f));
gGL.setLineWidth(width * lerp(mGLScaleFactor.mV[VX], mGLScaleFactor.mV[VY], 0.5f));
}
LLPointer<LLUIImage> LLRender2D::getUIImageByID(const LLUUID& image_id, S32 priority)

View File

@ -1518,7 +1518,7 @@ void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
LLColor4 avatar_color = LLNetMap::getAvatarColor(avatarp->getID());
gGL.diffuseColor4f(avatar_color.mV[VRED], avatar_color.mV[VGREEN], avatar_color.mV[VBLUE], avatar_color.mV[VALPHA]);
glLineWidth(2.0f);
gGL.setLineWidth(2.0f);
LLQuaternion rot = avatarp->getRotationRegion();
LLVector3 pos = avatarp->getPositionAgent();

View File

@ -716,7 +716,7 @@ void LLFace::renderOneWireframe(const LLColor4 &color, F32 fogCfx, bool wirefram
LLGLEnable offset(GL_POLYGON_OFFSET_LINE);
glPolygonOffset(3.f, 3.f);
glLineWidth(5.f);
gGL.setLineWidth(5.f); // <FS> Line width OGL core profile fix by Rye Mutt
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
renderFace(mDrawablep, this);
}

View File

@ -1095,8 +1095,10 @@ void LLFastTimerView::drawLineGraph()
//fatten highlighted timer
if (mHoverID == idp)
{
gGL.flush();
glLineWidth(3);
// <FS> Line width OGL core profile fix by Rye Mutt
//gGL.flush();
//glLineWidth(3);
gGL.setLineWidth(3.f);
}
llassert(idp->getIndex() < sTimerColors.size());
@ -1155,8 +1157,10 @@ void LLFastTimerView::drawLineGraph()
if (mHoverID == idp)
{
gGL.flush();
glLineWidth(1);
// <FS> Line width OGL core profile fix by Rye Mutt
//gGL.flush();
//glLineWidth(1);
gGL.setLineWidth(1.f);
}
if (idp->getTreeNode().mCollapsed)

View File

@ -950,8 +950,10 @@ void LLViewerObjectList::renderObjectBeacons()
S32 line_width = debug_beacon.mLineWidth;
if (line_width != last_line_width)
{
gGL.flush();
glLineWidth( (F32)line_width );
// <FS> Line width OGL core profile fix by Rye Mutt
//gGL.flush();
//glLineWidth( (F32)line_width );
gGL.setLineWidth((F32)line_width);
last_line_width = line_width;
}
@ -980,8 +982,10 @@ void LLViewerObjectList::renderObjectBeacons()
S32 line_width = debug_beacon.mLineWidth;
if (line_width != last_line_width)
{
gGL.flush();
glLineWidth( (F32)line_width );
// <FS> Line width OGL core profile fix by Rye Mutt
//gGL.flush();
//glLineWidth( (F32)line_width );
gGL.setLineWidth((F32)line_width);
last_line_width = line_width;
}
@ -994,8 +998,10 @@ void LLViewerObjectList::renderObjectBeacons()
gGL.end();
}
gGL.flush();
glLineWidth(1.f);
// <FS> Line width OGL core profile fix by Rye Mutt
//gGL.flush();
//glLineWidth(1.f);
gGL.setLineWidth(1.f);
for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter)
{
@ -1033,7 +1039,7 @@ void LLSky::renderSunMoonBeacons(const LLVector3& pos_agent, const LLVector3& di
{
pos_end.mV[i] = pos_agent.mV[i] + (50 * direction.mV[i]);
}
glLineWidth(LLPipeline::DebugBeaconLineWidth);
gGL.setLineWidth(LLPipeline::DebugBeaconLineWidth); // <FS> Line width OGL core profile fix by Rye Mutt
gGL.begin(LLRender::LINES);
color.mV[3] *= 0.5f;
gGL.color4fv(color.mV);
@ -1044,7 +1050,7 @@ void LLSky::renderSunMoonBeacons(const LLVector3& pos_agent, const LLVector3& di
gGL.end();
gGL.flush();
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
}

View File

@ -3306,11 +3306,11 @@ BOOL LLModelPreview::render()
gGL.diffuseColor4fv(PREVIEW_EDGE_COL.mV);
if (edges)
{
glLineWidth(PREVIEW_EDGE_WIDTH);
gGL.setLineWidth(PREVIEW_EDGE_WIDTH); // <FS> Line width OGL core profile fix by Rye Mutt
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts() - 1, buffer->getNumIndices(), 0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
}
}
gGL.popMatrix();
@ -3423,12 +3423,12 @@ BOOL LLModelPreview::render()
buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts() - 1, buffer->getNumIndices(), 0);
gGL.diffuseColor4fv(PREVIEW_PSYH_EDGE_COL.mV);
glLineWidth(PREVIEW_PSYH_EDGE_WIDTH);
gGL.setLineWidth(PREVIEW_PSYH_EDGE_WIDTH); // <FS> Line width OGL core profile fix by Rye Mutt
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts() - 1, buffer->getNumIndices(), 0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
}
}
}
@ -3438,7 +3438,7 @@ BOOL LLModelPreview::render()
// only do this if mDegenerate was set in the preceding mesh checks [Check this if the ordering ever breaks]
if (mHasDegenerate)
{
glLineWidth(PREVIEW_DEG_EDGE_WIDTH);
gGL.setLineWidth(PREVIEW_DEG_EDGE_WIDTH); // <FS> Line width OGL core profile fix by Rye Mutt
glPointSize(PREVIEW_DEG_POINT_SIZE);
gPipeline.enableLightsFullbright();
//show degenerate triangles
@ -3510,7 +3510,7 @@ BOOL LLModelPreview::render()
gGL.popMatrix();
}
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
glPointSize(1.f);
gPipeline.enableLightsPreview();
gGL.setSceneBlendType(LLRender::BT_ALPHA);
@ -3671,11 +3671,11 @@ BOOL LLModelPreview::render()
if (edges)
{
gGL.diffuseColor4fv(PREVIEW_EDGE_COL.mV);
glLineWidth(PREVIEW_EDGE_WIDTH);
gGL.setLineWidth(PREVIEW_EDGE_WIDTH); // <FS> Line width OGL core profile fix by Rye Mutt
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
}
}
}

View File

@ -6235,7 +6235,7 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud)
gGL.popMatrix();
gGL.popMatrix();
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
if (shader)

View File

@ -243,11 +243,11 @@ void LLSnapshotLivePreview::drawPreviewRect(S32 offset_x, S32 offset_y)
{
F32 line_width ;
glGetFloatv(GL_LINE_WIDTH, &line_width) ;
glLineWidth(2.0f * line_width) ;
gGL.setLineWidth(2.0f * line_width) ; // <FS> Line width OGL core profile fix by Rye Mutt
LLColor4 color(0.0f, 0.0f, 0.0f, 1.0f) ;
gl_rect_2d( mPreviewRect.mLeft + offset_x, mPreviewRect.mTop + offset_y,
mPreviewRect.mRight + offset_x, mPreviewRect.mBottom + offset_y, color, FALSE ) ;
glLineWidth(line_width) ;
gGL.setLineWidth(line_width) ; // <FS> Line width OGL core profile fix by Rye Mutt
//draw four alpha rectangles to cover areas outside of the snapshot image
if(!mKeepAspectRatio)

View File

@ -1738,12 +1738,12 @@ void renderOctree(LLSpatialGroup* group)
gGL.diffuseColor4f(1,0,0,group->mBuilt);
gGL.flush();
glLineWidth(5.f);
gGL.setLineWidth(5.f); // <FS> Line width OGL core profile fix by Rye Mutt
const LLVector4a* bounds = group->getObjectBounds();
drawBoxOutline(bounds[0], bounds[1]);
gGL.flush();
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
gGL.flush();
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
{
@ -1880,10 +1880,10 @@ void renderVisibility(LLSpatialGroup* group, LLCamera* camera)
pushBufferVerts(group, LLVertexBuffer::MAP_VERTEX, false);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glLineWidth(4.f);
gGL.setLineWidth(4.f); // <FS> Line width OGL core profile fix by Rye Mutt
gGL.diffuseColor4f(0.f, 0.5f, 0.f, 1.f);
pushBufferVerts(group, LLVertexBuffer::MAP_VERTEX, false);
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
bool selected = false;
@ -2257,12 +2257,12 @@ void renderBoundingBox(LLDrawable* drawable, BOOL set_color = TRUE)
if (vobj && vobj->onActiveList())
{
gGL.flush();
glLineWidth(llmax(4.f*sinf(gFrameTimeSeconds*2.f)+1.f, 1.f));
//glLineWidth(4.f*(sinf(gFrameTimeSeconds*2.f)*0.25f+0.75f));
gGL.setLineWidth(llmax(4.f*sinf(gFrameTimeSeconds*2.f)+1.f, 1.f)); // <FS> Line width OGL core profile fix by Rye Mutt
//gGL.setLineWidth(4.f*(sinf(gFrameTimeSeconds*2.f)*0.25f+0.75f)); // <FS> Line width OGL core profile fix by Rye Mutt
stop_glerror();
drawBoxOutline(pos,size);
gGL.flush();
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
}
else
{
@ -2462,10 +2462,10 @@ void render_hull(LLModel::PhysicsMesh& mesh, const LLColor4& color, const LLColo
LLGLEnable offset(GL_POLYGON_OFFSET_LINE);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glPolygonOffset(3.f, 3.f);
glLineWidth(3.f);
gGL.setLineWidth(3.f); // <FS> Line width OGL core profile fix by Rye Mutt
gGL.diffuseColor4fv(line_color.mV);
LLVertexBuffer::drawArrays(LLRender::TRIANGLES, mesh.mPositions, mesh.mNormals);
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
@ -3237,7 +3237,7 @@ public:
if (i == 1)
{
gGL.flush();
glLineWidth(3.f);
gGL.setLineWidth(3.f); // <FS> Line width OGL core profile fix by Rye Mutt
}
gGL.begin(LLRender::TRIANGLES);
@ -3256,7 +3256,7 @@ public:
if (i == 1)
{
gGL.flush();
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
}
}
}
@ -3860,11 +3860,11 @@ void LLSpatialPartition::renderPhysicsShapes()
gGL.flush();
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
glLineWidth(3.f);
gGL.setLineWidth(3.f); // <FS> Line width OGL core profile fix by Rye Mutt
LLOctreeRenderPhysicsShapes render_physics(camera);
render_physics.traverse(mOctree);
gGL.flush();
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
}
void LLSpatialPartition::renderDebug()

View File

@ -4369,7 +4369,7 @@ void renderMeshPhysicsTriangles(const LLColor4& color, const LLColor4& line_colo
LLGLEnable offset(GL_POLYGON_OFFSET_FILL);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glPolygonOffset(offset_factor, offset_units);
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
LLVertexBuffer::drawArrays(LLRender::TRIANGLES, decomp->mPhysicsShapeMesh.mPositions, decomp->mPhysicsShapeMesh.mNormals);
}
{
@ -4377,7 +4377,7 @@ void renderMeshPhysicsTriangles(const LLColor4& color, const LLColor4& line_colo
LLGLEnable offset(GL_POLYGON_OFFSET_LINE);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glPolygonOffset(offset_factor, offset_units);
glLineWidth(3.f);
gGL.setLineWidth(3.f); // <FS> Line width OGL core profile fix by Rye Mutt
LLVertexBuffer::drawArrays(LLRender::TRIANGLES, decomp->mPhysicsShapeMesh.mPositions, decomp->mPhysicsShapeMesh.mNormals);
}
}
@ -4405,12 +4405,12 @@ void renderMeshPhysicsTriangles(const LLColor4& color, const LLColor4& line_colo
LLVertexBuffer::drawArrays(LLRender::TRIANGLES, decomp->mPhysicsShapeMesh.mPositions, decomp->mPhysicsShapeMesh.mNormals);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
gGL.diffuseColor4fv(line_color.mV);
glLineWidth(3.f);
gGL.setLineWidth(3.f); // <FS> Line width OGL core profile fix by Rye Mutt
LLVertexBuffer::drawArrays(LLRender::TRIANGLES, decomp->mPhysicsShapeMesh.mPositions, decomp->mPhysicsShapeMesh.mNormals);
}
}
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
gGL.popMatrix();

View File

@ -5749,7 +5749,7 @@ U32 LLVOAvatar::renderImpostor(LLColor4U color, S32 diffuse_channel)
gGL.begin(LLRender::LINES);
gGL.color4f(1.f,1.f,1.f,1.f);
F32 thickness = llmax(F32(5.0f-5.0f*(gFrameTimeSeconds-mLastImpostorUpdateFrameTime)),1.0f);
glLineWidth(thickness);
gGL.setLineWidth(thickness); // <FS> Line width OGL core profile fix by Rye Mutt
gGL.vertex3fv((pos+left-up).mV);
gGL.vertex3fv((pos-left-up).mV);
gGL.vertex3fv((pos-left-up).mV);

View File

@ -5122,7 +5122,7 @@ void LLPipeline::renderDebug()
if ( pathfindingConsole->isRenderNavMesh() )
{
gGL.flush();
glLineWidth(2.0f);
gGL.setLineWidth(2.0f); // <FS> Line width OGL core profile fix by Rye Mutt
LLGLEnable cull(GL_CULL_FACE);
LLGLDisable blend(GL_BLEND);
@ -5153,7 +5153,7 @@ void LLPipeline::renderDebug()
gGL.flush();
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
glLineWidth(1.0f);
gGL.setLineWidth(1.0f); // <FS> Line width OGL core profile fix by Rye Mutt
gGL.flush();
}
//User designated path
@ -5290,11 +5290,11 @@ void LLPipeline::renderDebug()
gPathfindingProgram.uniform1f(sTint, 1.f);
gPathfindingProgram.uniform1f(sAlphaScale, 1.f);
glLineWidth(gSavedSettings.getF32("PathfindingLineWidth"));
gGL.setLineWidth(gSavedSettings.getF32("PathfindingLineWidth")); // <FS> Line width OGL core profile fix by Rye Mutt
LLGLDisable blendOut(GL_BLEND);
llPathingLibInstance->renderNavMeshShapesVBO( render_order[i] );
gGL.flush();
glLineWidth(1.f);
gGL.setLineWidth(1.f); // <FS> Line width OGL core profile fix by Rye Mutt
}
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
@ -5317,7 +5317,7 @@ void LLPipeline::renderDebug()
LLGLEnable blend(GL_BLEND);
LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_GREATER);
gGL.flush();
glLineWidth(2.0f);
gGL.setLineWidth(2.0f); // <FS> Line width OGL core profile fix by Rye Mutt
LLGLEnable cull(GL_CULL_FACE);
gPathfindingProgram.uniform1f(sTint, gSavedSettings.getF32("PathfindingXRayTint"));
@ -5351,7 +5351,7 @@ void LLPipeline::renderDebug()
}
gGL.flush();
glLineWidth(1.0f);
gGL.setLineWidth(1.0f); // <FS> Line width OGL core profile fix by Rye Mutt
}
glPolygonOffset(0.f, 0.f);
@ -5616,7 +5616,7 @@ void LLPipeline::renderDebug()
}
/*gGL.flush();
glLineWidth(16-i*2);
gGL.setLineWidth(16-i*2); // <FS> Line width OGL core profile fix by Rye Mutt
for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin();
iter != LLWorld::getInstance()->getRegionList().end(); ++iter)
{
@ -5634,7 +5634,7 @@ void LLPipeline::renderDebug()
}
}
gGL.flush();
glLineWidth(1.f);*/
gGL.setLineWidth(1.f);*/ // <FS> Line width OGL core profile fix by Rye Mutt
}
}