mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Removed immediate mode draw calls.
This commit is contained in:
parent
ed05c622db
commit
cd71a02c95
4 changed files with 123 additions and 144 deletions
|
@ -66,36 +66,30 @@ void AddDebugQuad(const lcVector3& pt1, const lcVector3& pt2, const lcVector3& p
|
||||||
|
|
||||||
void RenderDebugPrimitives()
|
void RenderDebugPrimitives()
|
||||||
{
|
{
|
||||||
glBegin(GL_LINES);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
for (int i = 0; i < NumDebugLines; i++)
|
for (int i = 0; i < NumDebugLines; i++)
|
||||||
{
|
{
|
||||||
|
glVertexPointer(3, GL_FLOAT, 0, &DebugLines[i].pt1);
|
||||||
glColor3fv((float*)&DebugLines[i].color);
|
glColor3fv((float*)&DebugLines[i].color);
|
||||||
glVertex3fv((float*)&DebugLines[i].pt1);
|
glDrawArrays(GL_LINES, 0, 2);
|
||||||
glVertex3fv((float*)&DebugLines[i].pt2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
|
|
||||||
for (int i = 0; i < NumDebugQuads; i++)
|
for (int i = 0; i < NumDebugQuads; i++)
|
||||||
{
|
{
|
||||||
|
glVertexPointer(3, GL_FLOAT, 0, &DebugQuads[i].pt1);
|
||||||
glColor4fv((float*)&DebugQuads[i].color);
|
glColor4fv((float*)&DebugQuads[i].color);
|
||||||
glVertex3fv((float*)&DebugQuads[i].pt1);
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
glVertex3fv((float*)&DebugQuads[i].pt2);
|
|
||||||
glVertex3fv((float*)&DebugQuads[i].pt3);
|
|
||||||
glVertex3fv((float*)&DebugQuads[i].pt4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
|
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // LC_DEBUG
|
#endif // LC_DEBUG
|
||||||
|
|
|
@ -2154,12 +2154,10 @@ void Project::RenderSceneObjects(View* view)
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
glEnable(GL_ALPHA_TEST);
|
glEnable(GL_ALPHA_TEST);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
m_pScreenFont->PrintText(pts[0][0], pts[0][1], 40.0f, "X");
|
m_pScreenFont->PrintText(pts[0][0], pts[0][1], 40.0f, "X");
|
||||||
m_pScreenFont->PrintText(pts[1][0], pts[1][1], 40.0f, "Y");
|
m_pScreenFont->PrintText(pts[1][0], pts[1][1], 40.0f, "Y");
|
||||||
m_pScreenFont->PrintText(pts[2][0], pts[2][1], 40.0f, "Z");
|
m_pScreenFont->PrintText(pts[2][0], pts[2][1], 40.0f, "Z");
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
@ -2310,20 +2308,23 @@ void Project::RenderOverlays(View* view)
|
||||||
// Translation arrows.
|
// Translation arrows.
|
||||||
if (m_nTracking == LC_TRACK_NONE || (m_OverlayMode >= LC_OVERLAY_NONE && m_OverlayMode <= LC_OVERLAY_MOVE_XYZ))
|
if (m_nTracking == LC_TRACK_NONE || (m_OverlayMode >= LC_OVERLAY_NONE && m_OverlayMode <= LC_OVERLAY_MOVE_XYZ))
|
||||||
{
|
{
|
||||||
glBegin(GL_LINES);
|
lcVector3 Verts[11];
|
||||||
glVertex3f(0.0f, 0.0f, 0.0f);
|
|
||||||
glVertex3f(OverlayMoveArrowSize, 0.0f, 0.0f);
|
Verts[0] = lcVector3(0.0f, 0.0f, 0.0f);
|
||||||
glEnd();
|
Verts[1] = lcVector3(OverlayMoveArrowSize, 0.0f, 0.0f);
|
||||||
|
|
||||||
glBegin(GL_TRIANGLE_FAN);
|
|
||||||
glVertex3f(OverlayMoveArrowSize, 0.0f, 0.0f);
|
|
||||||
for (int j = 0; j < 9; j++)
|
for (int j = 0; j < 9; j++)
|
||||||
{
|
{
|
||||||
float y = cosf(LC_2PI * j / 8) * OverlayMoveArrowCapRadius;
|
float y = cosf(LC_2PI * j / 8) * OverlayMoveArrowCapRadius;
|
||||||
float z = sinf(LC_2PI * j / 8) * OverlayMoveArrowCapRadius;
|
float z = sinf(LC_2PI * j / 8) * OverlayMoveArrowCapRadius;
|
||||||
glVertex3f(OverlayMoveArrowCapSize, y, z);
|
Verts[j + 2] = lcVector3(OverlayMoveArrowCapSize, y, z);
|
||||||
}
|
}
|
||||||
glEnd();
|
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(3, GL_FLOAT, 0, Verts);
|
||||||
|
glDrawArrays(GL_LINES, 0, 2);
|
||||||
|
glDrawArrays(GL_TRIANGLE_FAN, 1, 10);
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rotation arrows.
|
// Rotation arrows.
|
||||||
|
@ -2351,7 +2352,9 @@ void Project::RenderOverlays(View* view)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
lcVector3 Verts[18];
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(3, GL_FLOAT, 0, Verts);
|
||||||
|
|
||||||
for (int j = 0; j < 9; j++)
|
for (int j = 0; j < 9; j++)
|
||||||
{
|
{
|
||||||
|
@ -2360,13 +2363,11 @@ void Project::RenderOverlays(View* view)
|
||||||
float x = cosf(LC_2PI / 4 * j / 8);
|
float x = cosf(LC_2PI / 4 * j / 8);
|
||||||
float y = sinf(LC_2PI / 4 * j / 8);
|
float y = sinf(LC_2PI / 4 * j / 8);
|
||||||
|
|
||||||
glVertex3f(0.0f, OverlayRotateArrowCenter + x * Radius1, OverlayRotateArrowCenter + y * Radius1);
|
Verts[j * 2 + 0] = lcVector3(0.0f, OverlayRotateArrowCenter + x * Radius1, OverlayRotateArrowCenter + y * Radius1);
|
||||||
glVertex3f(0.0f, OverlayRotateArrowCenter + x * Radius2, OverlayRotateArrowCenter + y * Radius2);
|
Verts[j * 2 + 1] = lcVector3(0.0f, OverlayRotateArrowCenter + x * Radius2, OverlayRotateArrowCenter + y * Radius2);
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 18);
|
||||||
|
|
||||||
glBegin(GL_TRIANGLE_STRIP);
|
|
||||||
|
|
||||||
for (int j = 0; j < 9; j++)
|
for (int j = 0; j < 9; j++)
|
||||||
{
|
{
|
||||||
|
@ -2374,37 +2375,35 @@ void Project::RenderOverlays(View* view)
|
||||||
float x = cosf(LC_2PI / 4 * j / 8);
|
float x = cosf(LC_2PI / 4 * j / 8);
|
||||||
float y = sinf(LC_2PI / 4 * j / 8);
|
float y = sinf(LC_2PI / 4 * j / 8);
|
||||||
|
|
||||||
glVertex3f(-OverlayMoveArrowBodyRadius, OverlayRotateArrowCenter + x * Radius, OverlayRotateArrowCenter + y * Radius);
|
Verts[j * 2 + 0] = lcVector3(-OverlayMoveArrowBodyRadius, OverlayRotateArrowCenter + x * Radius, OverlayRotateArrowCenter + y * Radius);
|
||||||
glVertex3f( OverlayMoveArrowBodyRadius, OverlayRotateArrowCenter + x * Radius, OverlayRotateArrowCenter + y * Radius);
|
Verts[j * 2 + 1] = lcVector3( OverlayMoveArrowBodyRadius, OverlayRotateArrowCenter + x * Radius, OverlayRotateArrowCenter + y * Radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 18);
|
||||||
|
|
||||||
glBegin(GL_TRIANGLE_FAN);
|
Verts[0] = lcVector3(0.0f, OverlayRotateArrowEnd - OverlayMoveArrowCapRadius, OverlayRotateArrowStart);
|
||||||
|
|
||||||
glVertex3f(0.0f, OverlayRotateArrowEnd - OverlayMoveArrowCapRadius, OverlayRotateArrowStart);
|
|
||||||
|
|
||||||
for (int j = 0; j < 9; j++)
|
for (int j = 0; j < 9; j++)
|
||||||
{
|
{
|
||||||
float x = cosf(LC_2PI * j / 8) * OverlayMoveArrowCapRadius;
|
float x = cosf(LC_2PI * j / 8) * OverlayMoveArrowCapRadius;
|
||||||
float y = sinf(LC_2PI * j / 8) * OverlayMoveArrowCapRadius;
|
float y = sinf(LC_2PI * j / 8) * OverlayMoveArrowCapRadius;
|
||||||
glVertex3f(x, OverlayRotateArrowEnd - OverlayMoveArrowCapRadius + y, OverlayRotateArrowCenter);
|
Verts[j + 1] = lcVector3(x, OverlayRotateArrowEnd - OverlayMoveArrowCapRadius + y, OverlayRotateArrowCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 10);
|
||||||
|
|
||||||
glBegin(GL_TRIANGLE_FAN);
|
Verts[0] = lcVector3(0.0f, OverlayRotateArrowStart, OverlayRotateArrowEnd - OverlayMoveArrowCapRadius);
|
||||||
|
|
||||||
glVertex3f(0.0f, OverlayRotateArrowStart, OverlayRotateArrowEnd - OverlayMoveArrowCapRadius);
|
|
||||||
|
|
||||||
for (int j = 0; j < 9; j++)
|
for (int j = 0; j < 9; j++)
|
||||||
{
|
{
|
||||||
float x = cosf(LC_2PI * j / 8) * OverlayMoveArrowCapRadius;
|
float x = cosf(LC_2PI * j / 8) * OverlayMoveArrowCapRadius;
|
||||||
float y = sinf(LC_2PI * j / 8) * OverlayMoveArrowCapRadius;
|
float y = sinf(LC_2PI * j / 8) * OverlayMoveArrowCapRadius;
|
||||||
glVertex3f(x, OverlayRotateArrowCenter, OverlayRotateArrowEnd - OverlayMoveArrowCapRadius + y);
|
Verts[j + 1] = lcVector3(x, OverlayRotateArrowCenter, OverlayRotateArrowEnd - OverlayMoveArrowCapRadius + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 10);
|
||||||
|
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
@ -2492,9 +2491,12 @@ void Project::RenderOverlays(View* view)
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
glBegin(GL_TRIANGLE_FAN);
|
lcVector3 Verts[33];
|
||||||
|
Verts[0] = lcVector3(0.0f, 0.0f, 0.0f);
|
||||||
|
int NumVerts = 1;
|
||||||
|
|
||||||
glVertex3f(0.0f, 0.0f, 0.0f);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(3, GL_FLOAT, 0, Verts);
|
||||||
|
|
||||||
float StartAngle;
|
float StartAngle;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -2509,7 +2511,14 @@ void Project::RenderOverlays(View* view)
|
||||||
float x = cosf((Step * i - StartAngle) * LC_DTOR) * OverlayRotateRadius * OverlayScale;
|
float x = cosf((Step * i - StartAngle) * LC_DTOR) * OverlayRotateRadius * OverlayScale;
|
||||||
float y = sinf((Step * i - StartAngle) * LC_DTOR) * OverlayRotateRadius * OverlayScale;
|
float y = sinf((Step * i - StartAngle) * LC_DTOR) * OverlayRotateRadius * OverlayScale;
|
||||||
|
|
||||||
glVertex3f(0.0f, x, y);
|
Verts[NumVerts++] = lcVector3(0.0f, x, y);
|
||||||
|
|
||||||
|
if (NumVerts == 33)
|
||||||
|
{
|
||||||
|
glDrawArrays(GL_TRIANGLE_FAN, 0, NumVerts);
|
||||||
|
Verts[1] = Verts[32];
|
||||||
|
NumVerts = 2;
|
||||||
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
if (Step > 0)
|
if (Step > 0)
|
||||||
|
@ -2519,8 +2528,10 @@ void Project::RenderOverlays(View* view)
|
||||||
|
|
||||||
} while (Angle >= 0.0f);
|
} while (Angle >= 0.0f);
|
||||||
|
|
||||||
glEnd();
|
if (NumVerts > 2)
|
||||||
|
glDrawArrays(GL_TRIANGLE_FAN, 0, NumVerts);
|
||||||
|
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
@ -2535,8 +2546,7 @@ void Project::RenderOverlays(View* view)
|
||||||
// Draw the circles.
|
// Draw the circles.
|
||||||
if (m_nCurAction == LC_ACTION_ROTATE && !HasAngle && m_nTracking == LC_TRACK_NONE)
|
if (m_nCurAction == LC_ACTION_ROTATE && !HasAngle && m_nTracking == LC_TRACK_NONE)
|
||||||
{
|
{
|
||||||
glBegin(GL_LINE_LOOP);
|
lcVector3 Verts[32];
|
||||||
glColor4f(0.1f, 0.1f, 0.1f, 1.0f);
|
|
||||||
|
|
||||||
for (j = 0; j < 32; j++)
|
for (j = 0; j < 32; j++)
|
||||||
{
|
{
|
||||||
|
@ -2546,12 +2556,15 @@ void Project::RenderOverlays(View* view)
|
||||||
Pt[1] = sinf(LC_2PI * j / 32) * OverlayRotateRadius * OverlayScale;
|
Pt[1] = sinf(LC_2PI * j / 32) * OverlayRotateRadius * OverlayScale;
|
||||||
Pt[2] = 0.0f;
|
Pt[2] = 0.0f;
|
||||||
|
|
||||||
Pt = lcMul31(Pt, Mat);
|
Verts[j] = lcMul31(Pt, Mat);
|
||||||
|
|
||||||
glVertex3f(Pt[0], Pt[1], Pt[2]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
glColor4f(0.1f, 0.1f, 0.1f, 1.0f);
|
||||||
|
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(3, GL_FLOAT, 0, Verts);
|
||||||
|
glDrawArrays(GL_LINE_LOOP, 0, 32);
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
lcVector3 ViewDir = Cam->mTargetPosition - Cam->mPosition;
|
lcVector3 ViewDir = Cam->mTargetPosition - Cam->mPosition;
|
||||||
|
@ -2596,7 +2609,8 @@ void Project::RenderOverlays(View* view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glBegin(GL_LINES);
|
lcVector3 Verts[64];
|
||||||
|
int NumVerts = 0;
|
||||||
|
|
||||||
for (int j = 0; j < 32; j++)
|
for (int j = 0; j < 32; j++)
|
||||||
{
|
{
|
||||||
|
@ -2622,15 +2636,15 @@ void Project::RenderOverlays(View* view)
|
||||||
|
|
||||||
if (m_nCurAction != LC_ACTION_ROTATE || HasAngle || m_nTracking != LC_TRACK_NONE || lcDot(ViewDir, v1 + v2) <= 0.0f)
|
if (m_nCurAction != LC_ACTION_ROTATE || HasAngle || m_nTracking != LC_TRACK_NONE || lcDot(ViewDir, v1 + v2) <= 0.0f)
|
||||||
{
|
{
|
||||||
lcVector3 Pt1 = v1 * (OverlayRotateRadius * OverlayScale);
|
Verts[NumVerts++] = v1 * (OverlayRotateRadius * OverlayScale);
|
||||||
lcVector3 Pt2 = v2 * (OverlayRotateRadius * OverlayScale);
|
Verts[NumVerts++] = v2 * (OverlayRotateRadius * OverlayScale);
|
||||||
|
|
||||||
glVertex3f(Pt1[0], Pt1[1], Pt1[2]);
|
|
||||||
glVertex3f(Pt2[0], Pt2[1], Pt2[2]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(3, GL_FLOAT, 0, Verts);
|
||||||
|
glDrawArrays(GL_LINES, 0, NumVerts);
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
@ -2678,26 +2692,29 @@ void Project::RenderOverlays(View* view)
|
||||||
|
|
||||||
if (HasAngle)
|
if (HasAngle)
|
||||||
{
|
{
|
||||||
glBegin(GL_LINES);
|
|
||||||
|
|
||||||
float StartY = OverlayScale * OverlayRotateRadius;
|
float StartY = OverlayScale * OverlayRotateRadius;
|
||||||
float EndZ = (Angle > 0.0f) ? OverlayScale * OverlayRotateArrowSize : -OverlayScale * OverlayRotateArrowSize;
|
float EndZ = (Angle > 0.0f) ? OverlayScale * OverlayRotateArrowSize : -OverlayScale * OverlayRotateArrowSize;
|
||||||
float TipZ = (Angle > 0.0f) ? -OverlayScale * OverlayRotateArrowCapSize : OverlayScale * OverlayRotateArrowCapSize;
|
float TipZ = (Angle > 0.0f) ? -OverlayScale * OverlayRotateArrowCapSize : OverlayScale * OverlayRotateArrowCapSize;
|
||||||
|
|
||||||
glVertex3f(0.0f, StartY, 0.0f);
|
lcVector3 Verts[6];
|
||||||
glVertex3f(0.0f, StartY, EndZ);
|
|
||||||
|
|
||||||
glVertex3f(0.0f, StartY, EndZ);
|
Verts[0] = lcVector3(0.0f, StartY, 0.0f);
|
||||||
glVertex3f(0.0f, StartY + OverlayScale * OverlayRotateArrowCapSize, EndZ + TipZ);
|
Verts[1] = lcVector3(0.0f, StartY, EndZ);
|
||||||
|
|
||||||
glVertex3f(0.0f, StartY, EndZ);
|
Verts[2] = lcVector3(0.0f, StartY, EndZ);
|
||||||
glVertex3f(0.0f, StartY - OverlayScale * OverlayRotateArrowCapSize, EndZ + TipZ);
|
Verts[3] = lcVector3(0.0f, StartY + OverlayScale * OverlayRotateArrowCapSize, EndZ + TipZ);
|
||||||
|
|
||||||
glEnd();
|
Verts[4] = lcVector3(0.0f, StartY, EndZ);
|
||||||
|
Verts[5] = lcVector3(0.0f, StartY - OverlayScale * OverlayRotateArrowCapSize, EndZ + TipZ);
|
||||||
|
|
||||||
glPopMatrix();
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glVertexPointer(3, GL_FLOAT, 0, Verts);
|
||||||
|
glDrawArrays(GL_LINES, 0, 6);
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
// Draw text.
|
// Draw text.
|
||||||
int Viewport[4] = { 0, 0, view->GetWidth(), view->GetHeight() };
|
int Viewport[4] = { 0, 0, view->GetWidth(), view->GetHeight() };
|
||||||
float Aspect = (float)Viewport[2]/(float)Viewport[3];
|
float Aspect = (float)Viewport[2]/(float)Viewport[3];
|
||||||
|
@ -2728,10 +2745,8 @@ void Project::RenderOverlays(View* view)
|
||||||
int cx, cy;
|
int cx, cy;
|
||||||
m_pScreenFont->GetStringDimensions(&cx, &cy, buf);
|
m_pScreenFont->GetStringDimensions(&cx, &cy, buf);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
glColor4f(0.8f, 0.8f, 0.0f, 1.0f);
|
glColor4f(0.8f, 0.8f, 0.0f, 1.0f);
|
||||||
m_pScreenFont->PrintText(Screen[0] - Viewport[0] - (cx / 2), Screen[1] - Viewport[1] + (cy / 2), 0.0f, buf);
|
m_pScreenFont->PrintText(Screen[0] - Viewport[0] - (cx / 2), Screen[1] - Viewport[1] + (cy / 2), 0.0f, buf);
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
@ -2871,9 +2886,7 @@ void Project::RenderViewports(View* view)
|
||||||
m_pScreenFont->MakeCurrent();
|
m_pScreenFont->MakeCurrent();
|
||||||
glEnable(GL_ALPHA_TEST);
|
glEnable(GL_ALPHA_TEST);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
|
||||||
m_pScreenFont->PrintText(3.0f, (float)view->GetHeight() - 1.0f - 6.0f, 0.0f, view->mCamera->GetName());
|
m_pScreenFont->PrintText(3.0f, (float)view->GetHeight() - 1.0f - 6.0f, 0.0f, view->mCamera->GetName());
|
||||||
glEnd();
|
|
||||||
|
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
@ -2952,9 +2965,6 @@ void Project::RenderInitialize()
|
||||||
// AfxMessageBox ("Could not load background");
|
// AfxMessageBox ("Could not load background");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the perspective correction hint to fastest or nicest...
|
|
||||||
// glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
|
||||||
|
|
||||||
// Grid display list
|
// Grid display list
|
||||||
if (m_nGridList == 0)
|
if (m_nGridList == 0)
|
||||||
m_nGridList = glGenLists(1);
|
m_nGridList = glGenLists(1);
|
||||||
|
@ -2991,30 +3001,10 @@ void Project::RenderInitialize()
|
||||||
|
|
||||||
void Project::AddPiece(Piece* pPiece)
|
void Project::AddPiece(Piece* pPiece)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
// Sort piece array to avoid OpenGL state changes (needs work)
|
|
||||||
void CCADDoc::AddPiece(CPiece* pNewPiece)
|
|
||||||
{
|
|
||||||
POSITION pos1, pos2;
|
|
||||||
|
|
||||||
for (pos1 = m_Pieces.GetHeadPosition(); (pos2 = pos1) != NULL;)
|
|
||||||
{
|
|
||||||
CPiece* pPiece = m_Pieces.GetNext(pos1);
|
|
||||||
if (pPiece->IsTranslucent())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pos2 == NULL || pNewPiece->IsTranslucent())
|
|
||||||
m_Pieces.AddTail(pNewPiece);
|
|
||||||
else
|
|
||||||
m_Pieces.InsertBefore(pos2, pNewPiece);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (m_pPieces != NULL)
|
if (m_pPieces != NULL)
|
||||||
{
|
{
|
||||||
pPiece->m_pNext = m_pPieces;
|
pPiece->m_pNext = m_pPieces;
|
||||||
m_pPieces = pPiece;
|
m_pPieces = pPiece;
|
||||||
// TODO: sorting and BSP
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3038,8 +3028,6 @@ void Project::RemovePiece(Piece* pPiece)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove from BSP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::CalculateStep()
|
void Project::CalculateStep()
|
||||||
|
|
|
@ -160,56 +160,55 @@ void TexFont::GetStringDimensions(int* cx, int* cy, const char* Text) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TexFont::PrintText(float Left, float Top, float ScaleX, float ScaleY, const char* Text) const
|
|
||||||
{
|
|
||||||
float Height = mFontHeight * ScaleY;
|
|
||||||
|
|
||||||
while (*Text != 0)
|
|
||||||
{
|
|
||||||
int ch = *Text;
|
|
||||||
glTexCoord2f(mGlyphs[ch].left, mGlyphs[ch].top);
|
|
||||||
glVertex2f(Left, Top);
|
|
||||||
glTexCoord2f(mGlyphs[ch].left, mGlyphs[ch].bottom);
|
|
||||||
glVertex2f(Left, Top - Height);
|
|
||||||
glTexCoord2f(mGlyphs[ch].right, mGlyphs[ch].bottom);
|
|
||||||
glVertex2f(Left + mGlyphs[ch].width * ScaleX, Top - Height);
|
|
||||||
glTexCoord2f(mGlyphs[ch].right, mGlyphs[ch].top);
|
|
||||||
glVertex2f(Left + mGlyphs[ch].width * ScaleX, Top);
|
|
||||||
|
|
||||||
Left += mGlyphs[ch].width * ScaleX;
|
|
||||||
Text++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Old function, should probably be removed.
|
|
||||||
void TexFont::PrintText(float Left, float Top, float Z, const char* Text) const
|
void TexFont::PrintText(float Left, float Top, float Z, const char* Text) const
|
||||||
{
|
{
|
||||||
while (*Text != 0)
|
int Length = strlen(Text);
|
||||||
|
|
||||||
|
if (!Length)
|
||||||
|
return;
|
||||||
|
|
||||||
|
float* Verts = new float[4 * 5 * Length];
|
||||||
|
float* CurVert = Verts;
|
||||||
|
|
||||||
|
while (*Text)
|
||||||
{
|
{
|
||||||
int ch = *Text;
|
int ch = *Text;
|
||||||
glTexCoord2f(mGlyphs[ch].left, mGlyphs[ch].top);
|
|
||||||
glVertex3f(Left, Top, Z);
|
*CurVert++ = Left;
|
||||||
glTexCoord2f(mGlyphs[ch].left, mGlyphs[ch].bottom);
|
*CurVert++ = Top;
|
||||||
glVertex3f(Left, Top - mFontHeight, Z);
|
*CurVert++ = Z;
|
||||||
glTexCoord2f(mGlyphs[ch].right, mGlyphs[ch].bottom);
|
*CurVert++ = mGlyphs[ch].left;
|
||||||
glVertex3f(Left + mGlyphs[ch].width, Top - mFontHeight, Z);
|
*CurVert++ = mGlyphs[ch].top;
|
||||||
glTexCoord2f(mGlyphs[ch].right, mGlyphs[ch].top);
|
|
||||||
glVertex3f(Left + mGlyphs[ch].width, Top, Z);
|
*CurVert++ = Left;
|
||||||
|
*CurVert++ = Top - mFontHeight;
|
||||||
|
*CurVert++ = Z;
|
||||||
|
*CurVert++ = mGlyphs[ch].left;
|
||||||
|
*CurVert++ = mGlyphs[ch].bottom;
|
||||||
|
|
||||||
|
*CurVert++ = Left + mGlyphs[ch].width;
|
||||||
|
*CurVert++ = Top - mFontHeight;
|
||||||
|
*CurVert++ = Z;
|
||||||
|
*CurVert++ = mGlyphs[ch].right;
|
||||||
|
*CurVert++ = mGlyphs[ch].bottom;
|
||||||
|
|
||||||
|
*CurVert++ = Left + mGlyphs[ch].width;
|
||||||
|
*CurVert++ = Top;
|
||||||
|
*CurVert++ = Z;
|
||||||
|
*CurVert++ = mGlyphs[ch].right;
|
||||||
|
*CurVert++ = mGlyphs[ch].top;
|
||||||
|
|
||||||
Left += mGlyphs[ch].width;
|
Left += mGlyphs[ch].width;
|
||||||
Text++;
|
Text++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Temporary function to draw the axis icon text
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
void TexFont::PrintCharScaled(float scale, int ch) const
|
glVertexPointer(3, GL_FLOAT, 5 * sizeof(float), Verts);
|
||||||
{
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glTexCoord2f(mGlyphs[ch].left, mGlyphs[ch].top);
|
glTexCoordPointer(2, GL_FLOAT, 5 * sizeof(float), Verts + 3);
|
||||||
glVertex2f(-scale * mGlyphs[ch].width, scale * mFontHeight);
|
|
||||||
glTexCoord2f(mGlyphs[ch].left, mGlyphs[ch].bottom);
|
glDrawArrays(GL_QUADS, 0, 4 * Length);
|
||||||
glVertex2f(-scale * mGlyphs[ch].width, -scale * mFontHeight);
|
|
||||||
glTexCoord2f(mGlyphs[ch].right, mGlyphs[ch].bottom);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glVertex2f(scale * mGlyphs[ch].width, -scale * mFontHeight);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glTexCoord2f(mGlyphs[ch].right, mGlyphs[ch].top);
|
|
||||||
glVertex2f(scale * mGlyphs[ch].width, scale * mFontHeight);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Initialize();
|
bool Initialize();
|
||||||
void PrintText(float left, float top, float z, const char* text) const;
|
void PrintText(float Left, float Top, float Z, const char* Text) const;
|
||||||
void PrintText(float Left, float Top, float ScaleX, float ScaleY, const char* Text) const;
|
|
||||||
void PrintCharScaled(float scale, int ch) const;
|
|
||||||
void GetStringDimensions(int* cx, int* cy, const char* Text) const;
|
void GetStringDimensions(int* cx, int* cy, const char* Text) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in a new issue