mirror of
https://github.com/leozide/leocad
synced 2025-01-29 20:34:50 +01:00
Fixed rotate overlay drawing.
This commit is contained in:
parent
f001916a05
commit
6b86d13042
4 changed files with 129 additions and 117 deletions
|
@ -146,10 +146,11 @@ void lcContext::CreateShaderPrograms()
|
||||||
// LC_PROGRAM_TEXTURE
|
// LC_PROGRAM_TEXTURE
|
||||||
"#version 110\n"
|
"#version 110\n"
|
||||||
"varying vec2 PixelTexCoord;\n"
|
"varying vec2 PixelTexCoord;\n"
|
||||||
|
"uniform vec4 Color;\n"
|
||||||
"uniform sampler2D Texture;\n"
|
"uniform sampler2D Texture;\n"
|
||||||
"void main()\n"
|
"void main()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" gl_FragColor = texture2D(Texture, PixelTexCoord);\n"
|
" gl_FragColor = texture2D(Texture, PixelTexCoord) * Color;\n"
|
||||||
"}\n",
|
"}\n",
|
||||||
// LC_PROGRAM_VERTEX_COLOR
|
// LC_PROGRAM_VERTEX_COLOR
|
||||||
"#version 110\n"
|
"#version 110\n"
|
||||||
|
|
|
@ -121,14 +121,17 @@ bool TexFont::Load()
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
unsigned char ExpandedData[sizeof(TextureData) * 8];
|
unsigned char ExpandedData[sizeof(TextureData) * 8 * 2];
|
||||||
for (unsigned int TexelIdx = 0; TexelIdx < sizeof(TextureData) * 8; TexelIdx++)
|
for (unsigned int TexelIdx = 0; TexelIdx < sizeof(TextureData) * 8; TexelIdx++)
|
||||||
ExpandedData[TexelIdx] = TextureData[TexelIdx / 8] & (1 << (TexelIdx % 8)) ? 255 : 0;
|
{
|
||||||
|
unsigned char Texel = TextureData[TexelIdx / 8] & (1 << (TexelIdx % 8)) ? 255 : 0;
|
||||||
|
ExpandedData[TexelIdx * 2] = ExpandedData[TexelIdx * 2 + 1] = Texel;
|
||||||
|
}
|
||||||
|
|
||||||
mTextureWidth = 128;
|
mTextureWidth = 128;
|
||||||
mTextureHeight = 128;
|
mTextureHeight = 128;
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, mTextureWidth, mTextureHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, ExpandedData);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, mTextureWidth, mTextureHeight, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, ExpandedData);
|
||||||
|
|
||||||
const unsigned char* Ptr = GlyphData;
|
const unsigned char* Ptr = GlyphData;
|
||||||
|
|
||||||
|
|
|
@ -821,7 +821,8 @@ void View::DrawRotateOverlay()
|
||||||
Verts[0] = lcVector3(0.0f, 0.0f, 0.0f);
|
Verts[0] = lcVector3(0.0f, 0.0f, 0.0f);
|
||||||
int NumVerts = 1;
|
int NumVerts = 1;
|
||||||
|
|
||||||
glVertexPointer(3, GL_FLOAT, 0, Verts);
|
mContext->SetVertexBufferPointer(Verts);
|
||||||
|
mContext->SetVertexFormat(0, 3, 0, 0);
|
||||||
|
|
||||||
float StartAngle;
|
float StartAngle;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -840,7 +841,7 @@ void View::DrawRotateOverlay()
|
||||||
|
|
||||||
if (NumVerts == 33)
|
if (NumVerts == 33)
|
||||||
{
|
{
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, NumVerts);
|
mContext->DrawPrimitives(GL_TRIANGLE_FAN, 0, NumVerts);
|
||||||
Verts[1] = Verts[32];
|
Verts[1] = Verts[32];
|
||||||
NumVerts = 2;
|
NumVerts = 2;
|
||||||
}
|
}
|
||||||
|
@ -854,7 +855,7 @@ void View::DrawRotateOverlay()
|
||||||
} while (Angle >= 0.0f);
|
} while (Angle >= 0.0f);
|
||||||
|
|
||||||
if (NumVerts > 2)
|
if (NumVerts > 2)
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, NumVerts);
|
mContext->DrawPrimitives(GL_TRIANGLE_FAN, 0, NumVerts);
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
@ -882,8 +883,10 @@ void View::DrawRotateOverlay()
|
||||||
mContext->SetColor(0.1f, 0.1f, 0.1f, 1.0f);
|
mContext->SetColor(0.1f, 0.1f, 0.1f, 1.0f);
|
||||||
mContext->SetWorldMatrix(lcMatrix44Identity());
|
mContext->SetWorldMatrix(lcMatrix44Identity());
|
||||||
|
|
||||||
glVertexPointer(3, GL_FLOAT, 0, Verts);
|
mContext->SetVertexBufferPointer(Verts);
|
||||||
glDrawArrays(GL_LINE_LOOP, 0, 32);
|
mContext->SetVertexFormat(0, 3, 0, 0);
|
||||||
|
|
||||||
|
mContext->DrawPrimitives(GL_LINE_LOOP, 0, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
lcVector3 ViewDir = mCamera->mTargetPosition - mCamera->mPosition;
|
lcVector3 ViewDir = mCamera->mTargetPosition - mCamera->mPosition;
|
||||||
|
@ -953,8 +956,10 @@ void View::DrawRotateOverlay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glVertexPointer(3, GL_FLOAT, 0, Verts);
|
mContext->SetVertexBufferPointer(Verts);
|
||||||
glDrawArrays(GL_LINES, 0, NumVerts);
|
mContext->SetVertexFormat(0, 3, 0, 0);
|
||||||
|
|
||||||
|
mContext->DrawPrimitives(GL_LINES, 0, NumVerts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw tangent vector.
|
// Draw tangent vector.
|
||||||
|
@ -1009,13 +1014,16 @@ void View::DrawRotateOverlay()
|
||||||
Verts[4] = lcVector3(0.0f, StartY, EndZ);
|
Verts[4] = lcVector3(0.0f, StartY, EndZ);
|
||||||
Verts[5] = lcVector3(0.0f, StartY - OverlayScale * OverlayRotateArrowCapSize, EndZ + TipZ);
|
Verts[5] = lcVector3(0.0f, StartY - OverlayScale * OverlayRotateArrowCapSize, EndZ + TipZ);
|
||||||
|
|
||||||
glVertexPointer(3, GL_FLOAT, 0, Verts);
|
mContext->SetVertexBufferPointer(Verts);
|
||||||
glDrawArrays(GL_LINES, 0, 6);
|
mContext->SetVertexFormat(0, 3, 0, 0);
|
||||||
|
|
||||||
|
mContext->DrawPrimitives(GL_LINES, 0, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw text.
|
// Draw text.
|
||||||
lcVector3 ScreenPos = ProjectPoint(OverlayCenter);
|
lcVector3 ScreenPos = ProjectPoint(OverlayCenter);
|
||||||
|
|
||||||
|
mContext->SetProgram(LC_PROGRAM_TEXTURE);
|
||||||
mContext->SetWorldMatrix(lcMatrix44Identity());
|
mContext->SetWorldMatrix(lcMatrix44Identity());
|
||||||
mContext->SetViewMatrix(lcMatrix44Translation(lcVector3(0.375, 0.375, 0.0)));
|
mContext->SetViewMatrix(lcMatrix44Translation(lcVector3(0.375, 0.375, 0.0)));
|
||||||
mContext->SetProjectionMatrix(lcMatrix44Ortho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f));
|
mContext->SetProjectionMatrix(lcMatrix44Ortho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f));
|
||||||
|
|
Loading…
Add table
Reference in a new issue