mirror of
https://github.com/leozide/leocad
synced 2025-01-17 18:11:42 +01:00
Added room in the meshes for normals.
This commit is contained in:
parent
641f4803e2
commit
3d1efcabec
15 changed files with 156 additions and 125 deletions
|
@ -535,7 +535,7 @@ void lcCamera::DrawInterface(lcContext* Context) const
|
|||
};
|
||||
|
||||
Context->SetVertexBufferPointer(Verts);
|
||||
Context->SetVertexFormat(0, 3, 0, 0);
|
||||
Context->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
Context->SetIndexBufferPointer(Indices);
|
||||
|
||||
float LineWidth = lcGetPreferences().mLineWidth;
|
||||
|
|
|
@ -5,13 +5,7 @@
|
|||
|
||||
class Project;
|
||||
class lcPiecesLibrary;
|
||||
|
||||
enum lcLightingMode
|
||||
{
|
||||
LC_LIGHTING_FLAT,
|
||||
LC_LIGHTING_FAKE,
|
||||
LC_LIGHTING_FULL
|
||||
};
|
||||
enum lcLightingMode : int;
|
||||
|
||||
class lcPreferences
|
||||
{
|
||||
|
|
|
@ -75,6 +75,7 @@ lcContext::lcContext()
|
|||
mIndexBufferPointer = NULL;
|
||||
mVertexBufferOffset = (char*)~0;
|
||||
|
||||
mNormalEnabled = false;
|
||||
mTexCoordEnabled = false;
|
||||
mColorEnabled = false;
|
||||
|
||||
|
@ -99,6 +100,7 @@ lcContext::lcContext()
|
|||
mProjectionMatrixDirty = false;
|
||||
mViewProjectionMatrixDirty = false;
|
||||
|
||||
mLightingMode = LC_LIGHTING_UNLIT;
|
||||
mProgramType = LC_NUM_PROGRAMS;
|
||||
}
|
||||
|
||||
|
@ -301,20 +303,24 @@ void lcContext::SetDefaultState()
|
|||
if (gSupportsShaderObjects)
|
||||
{
|
||||
glEnableVertexAttribArray(LC_ATTRIB_POSITION);
|
||||
glDisableVertexAttribArray(LC_ATTRIB_NORMAL);
|
||||
glDisableVertexAttribArray(LC_ATTRIB_TEXCOORD);
|
||||
glDisableVertexAttribArray(LC_ATTRIB_COLOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glVertexPointer(3, GL_FLOAT, 0, NULL);
|
||||
glNormalPointer(GL_INT_2_10_10_10_REV, 0, NULL);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, NULL);
|
||||
glColorPointer(4, GL_FLOAT, 0, NULL);
|
||||
}
|
||||
|
||||
mNormalEnabled = false;
|
||||
mTexCoordEnabled = false;
|
||||
mColorEnabled = false;
|
||||
|
||||
|
@ -340,10 +346,19 @@ void lcContext::SetDefaultState()
|
|||
#ifndef LC_OPENGLES
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
mMatrixMode = GL_MODELVIEW;
|
||||
glShadeModel(GL_FLAT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void lcContext::SetLightingMode(lcLightingMode LightingMode)
|
||||
{
|
||||
if (mLightingMode == LightingMode)
|
||||
return;
|
||||
|
||||
mLightingMode = LightingMode;
|
||||
}
|
||||
|
||||
void lcContext::SetProgram(lcProgramType ProgramType)
|
||||
{
|
||||
if (!gSupportsShaderObjects || mProgramType == ProgramType)
|
||||
|
@ -652,6 +667,9 @@ void lcContext::ClearVertexBuffer()
|
|||
mVertexBufferObject = 0;
|
||||
}
|
||||
|
||||
if (mNormalEnabled)
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
|
||||
if (mTexCoordEnabled)
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
|
@ -692,9 +710,9 @@ void lcContext::SetVertexBufferPointer(const void* VertexBuffer)
|
|||
mVertexBufferOffset = (char*)~0;
|
||||
}
|
||||
|
||||
void lcContext::SetVertexFormat(int BufferOffset, int PositionSize, int TexCoordSize, int ColorSize)
|
||||
void lcContext::SetVertexFormat(int BufferOffset, int PositionSize, int NormalSize, int TexCoordSize, int ColorSize)
|
||||
{
|
||||
int VertexSize = (PositionSize + TexCoordSize + ColorSize) * sizeof(float);
|
||||
int VertexSize = (PositionSize + TexCoordSize + ColorSize) * sizeof(float) + NormalSize * sizeof(quint32);
|
||||
char* VertexBufferPointer = mVertexBufferPointer + BufferOffset;
|
||||
|
||||
if (mVertexBufferOffset != VertexBufferPointer)
|
||||
|
@ -707,11 +725,47 @@ void lcContext::SetVertexFormat(int BufferOffset, int PositionSize, int TexCoord
|
|||
mVertexBufferOffset = VertexBufferPointer;
|
||||
}
|
||||
|
||||
int Offset = PositionSize * sizeof(float);
|
||||
|
||||
if (NormalSize && mLightingMode != LC_LIGHTING_UNLIT)
|
||||
{
|
||||
if (gSupportsShaderObjects)
|
||||
{
|
||||
glVertexAttribPointer(LC_ATTRIB_NORMAL, 4, GL_INT_2_10_10_10_REV, true, VertexSize, VertexBufferPointer + Offset);
|
||||
|
||||
if (!mNormalEnabled)
|
||||
{
|
||||
glEnableVertexAttribArray(LC_ATTRIB_NORMAL);
|
||||
mNormalEnabled = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
glNormalPointer(GL_INT_2_10_10_10_REV, VertexSize, VertexBufferPointer + Offset);
|
||||
|
||||
if (!mNormalEnabled)
|
||||
{
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
mNormalEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gSupportsShaderObjects)
|
||||
glDisableVertexAttribArray(LC_ATTRIB_NORMAL);
|
||||
else
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
mNormalEnabled = false;
|
||||
}
|
||||
|
||||
Offset += NormalSize * sizeof(quint32);
|
||||
|
||||
if (TexCoordSize)
|
||||
{
|
||||
if (gSupportsShaderObjects)
|
||||
{
|
||||
glVertexAttribPointer(LC_ATTRIB_TEXCOORD, TexCoordSize, GL_FLOAT, false, VertexSize, VertexBufferPointer + PositionSize * sizeof(float));
|
||||
glVertexAttribPointer(LC_ATTRIB_TEXCOORD, TexCoordSize, GL_FLOAT, false, VertexSize, VertexBufferPointer + Offset);
|
||||
|
||||
if (!mTexCoordEnabled)
|
||||
{
|
||||
|
@ -721,7 +775,7 @@ void lcContext::SetVertexFormat(int BufferOffset, int PositionSize, int TexCoord
|
|||
}
|
||||
else
|
||||
{
|
||||
glTexCoordPointer(TexCoordSize, GL_FLOAT, VertexSize, VertexBufferPointer + PositionSize * sizeof(float));
|
||||
glTexCoordPointer(TexCoordSize, GL_FLOAT, VertexSize, VertexBufferPointer + Offset);
|
||||
|
||||
if (!mTexCoordEnabled)
|
||||
{
|
||||
|
@ -729,6 +783,8 @@ void lcContext::SetVertexFormat(int BufferOffset, int PositionSize, int TexCoord
|
|||
mTexCoordEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
Offset += 2 * sizeof(float);
|
||||
}
|
||||
else if (mTexCoordEnabled)
|
||||
{
|
||||
|
@ -743,7 +799,7 @@ void lcContext::SetVertexFormat(int BufferOffset, int PositionSize, int TexCoord
|
|||
{
|
||||
if (gSupportsShaderObjects)
|
||||
{
|
||||
glVertexAttribPointer(LC_ATTRIB_COLOR, ColorSize, GL_FLOAT, false, VertexSize, VertexBufferPointer + (PositionSize + TexCoordSize) * sizeof(float));
|
||||
glVertexAttribPointer(LC_ATTRIB_COLOR, ColorSize, GL_FLOAT, false, VertexSize, VertexBufferPointer + Offset);
|
||||
|
||||
if (!mColorEnabled)
|
||||
{
|
||||
|
@ -753,7 +809,7 @@ void lcContext::SetVertexFormat(int BufferOffset, int PositionSize, int TexCoord
|
|||
}
|
||||
else
|
||||
{
|
||||
glColorPointer(ColorSize, GL_FLOAT, VertexSize, VertexBufferPointer + (PositionSize + TexCoordSize) * sizeof(float));
|
||||
glColorPointer(ColorSize, GL_FLOAT, VertexSize, VertexBufferPointer + Offset);
|
||||
|
||||
if (!mColorEnabled)
|
||||
{
|
||||
|
@ -878,13 +934,17 @@ void lcContext::UnbindMesh()
|
|||
if (gSupportsShaderObjects)
|
||||
{
|
||||
glDisableVertexAttribArray(LC_ATTRIB_TEXCOORD);
|
||||
glDisableVertexAttribArray(LC_ATTRIB_NORMAL);
|
||||
glDisableVertexAttribArray(LC_ATTRIB_COLOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
glVertexPointer(3, GL_FLOAT, 0, NULL);
|
||||
glNormalPointer(GL_INT_2_10_10_10_REV, 0, NULL);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, NULL);
|
||||
}
|
||||
|
||||
mNormalEnabled = false;
|
||||
mTexCoordEnabled = false;
|
||||
mColorEnabled = false;
|
||||
}
|
||||
|
@ -967,7 +1027,7 @@ void lcContext::DrawMeshSection(lcMesh* Mesh, lcMeshSection* Section)
|
|||
if (!Texture)
|
||||
{
|
||||
SetProgram(LC_PROGRAM_SIMPLE);
|
||||
SetVertexFormat(VertexBufferOffset, 3, 0, 0);
|
||||
SetVertexFormat(VertexBufferOffset, 3, 1, 0, 0);
|
||||
|
||||
if (mTexture)
|
||||
{
|
||||
|
@ -979,7 +1039,7 @@ void lcContext::DrawMeshSection(lcMesh* Mesh, lcMeshSection* Section)
|
|||
{
|
||||
VertexBufferOffset += Mesh->mNumVertices * sizeof(lcVertex);
|
||||
SetProgram(LC_PROGRAM_TEXTURE);
|
||||
SetVertexFormat(VertexBufferOffset, 3, 2, 0);
|
||||
SetVertexFormat(VertexBufferOffset, 3, 1, 2, 0);
|
||||
|
||||
if (Texture != mTexture)
|
||||
{
|
||||
|
@ -1006,7 +1066,7 @@ void lcContext::DrawMeshSection(lcMesh* Mesh, lcMeshSection* Section)
|
|||
{
|
||||
FlushState();
|
||||
lcMatrix44 WorldViewProjectionMatrix = lcMul(mWorldMatrix, mViewProjectionMatrix);
|
||||
float* VertexBuffer = (float*)Mesh->mVertexData;
|
||||
lcVertex* VertexBuffer = (lcVertex*)Mesh->mVertexData;
|
||||
|
||||
if (Mesh->mIndexType == GL_UNSIGNED_SHORT)
|
||||
{
|
||||
|
@ -1014,10 +1074,10 @@ void lcContext::DrawMeshSection(lcMesh* Mesh, lcMeshSection* Section)
|
|||
|
||||
for (int i = 0; i < Section->NumIndices; i += 4)
|
||||
{
|
||||
lcVector3 p1 = lcMul31(lcVector3(VertexBuffer[Indices[i] * 3], VertexBuffer[Indices[i] * 3 + 1], VertexBuffer[Indices[i] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p2 = lcMul31(lcVector3(VertexBuffer[Indices[i + 1] * 3], VertexBuffer[Indices[i + 1] * 3 + 1], VertexBuffer[Indices[i + 1] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p3 = lcMul31(lcVector3(VertexBuffer[Indices[i + 2] * 3], VertexBuffer[Indices[i + 2] * 3 + 1], VertexBuffer[Indices[i + 2] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p4 = lcMul31(lcVector3(VertexBuffer[Indices[i + 3] * 3], VertexBuffer[Indices[i + 3] * 3 + 1], VertexBuffer[Indices[i + 3] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p1 = lcMul31(VertexBuffer[Indices[i + 0]].Position, WorldViewProjectionMatrix);
|
||||
lcVector3 p2 = lcMul31(VertexBuffer[Indices[i + 1]].Position, WorldViewProjectionMatrix);
|
||||
lcVector3 p3 = lcMul31(VertexBuffer[Indices[i + 2]].Position, WorldViewProjectionMatrix);
|
||||
lcVector3 p4 = lcMul31(VertexBuffer[Indices[i + 3]].Position, WorldViewProjectionMatrix);
|
||||
|
||||
if (((p1.y - p2.y) * (p3.x - p1.x) + (p2.x - p1.x) * (p3.y - p1.y)) * ((p1.y - p2.y) * (p4.x - p1.x) + (p2.x - p1.x) * (p4.y - p1.y)) >= 0)
|
||||
DrawIndexedPrimitives(GL_LINES, 2, Mesh->mIndexType, IndexBufferOffset + Section->IndexOffset + i * sizeof(lcuint16));
|
||||
|
@ -1029,10 +1089,10 @@ void lcContext::DrawMeshSection(lcMesh* Mesh, lcMeshSection* Section)
|
|||
|
||||
for (int i = 0; i < Section->NumIndices; i += 4)
|
||||
{
|
||||
lcVector3 p1 = lcMul31(lcVector3(VertexBuffer[Indices[i] * 3], VertexBuffer[Indices[i] * 3 + 1], VertexBuffer[Indices[i] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p2 = lcMul31(lcVector3(VertexBuffer[Indices[i + 1] * 3], VertexBuffer[Indices[i + 1] * 3 + 1], VertexBuffer[Indices[i + 1] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p3 = lcMul31(lcVector3(VertexBuffer[Indices[i + 2] * 3], VertexBuffer[Indices[i + 2] * 3 + 1], VertexBuffer[Indices[i + 2] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p4 = lcMul31(lcVector3(VertexBuffer[Indices[i + 3] * 3], VertexBuffer[Indices[i + 3] * 3 + 1], VertexBuffer[Indices[i + 3] * 3 + 2]), WorldViewProjectionMatrix);
|
||||
lcVector3 p1 = lcMul31(VertexBuffer[Indices[i + 0]].Position, WorldViewProjectionMatrix);
|
||||
lcVector3 p2 = lcMul31(VertexBuffer[Indices[i + 1]].Position, WorldViewProjectionMatrix);
|
||||
lcVector3 p3 = lcMul31(VertexBuffer[Indices[i + 2]].Position, WorldViewProjectionMatrix);
|
||||
lcVector3 p4 = lcMul31(VertexBuffer[Indices[i + 3]].Position, WorldViewProjectionMatrix);
|
||||
|
||||
if (((p1.y - p2.y) * (p3.x - p1.x) + (p2.x - p1.x) * (p3.y - p1.y)) * ((p1.y - p2.y) * (p4.x - p1.x) + (p2.x - p1.x) * (p4.y - p1.y)) >= 0)
|
||||
DrawIndexedPrimitives(GL_LINES, 2, Mesh->mIndexType, IndexBufferOffset + Section->IndexOffset + i * sizeof(lcuint32));
|
||||
|
|
|
@ -60,6 +60,13 @@ public:
|
|||
};
|
||||
};
|
||||
|
||||
enum lcLightingMode : int
|
||||
{
|
||||
LC_LIGHTING_UNLIT,
|
||||
LC_LIGHTING_FAKE,
|
||||
LC_LIGHTING_FULL
|
||||
};
|
||||
|
||||
enum lcProgramType
|
||||
{
|
||||
LC_PROGRAM_SIMPLE,
|
||||
|
@ -70,8 +77,9 @@ enum lcProgramType
|
|||
|
||||
enum lcProgramAttrib
|
||||
{
|
||||
LC_ATTRIB_POSITION,
|
||||
LC_ATTRIB_TEXCOORD,
|
||||
LC_ATTRIB_POSITION,
|
||||
LC_ATTRIB_NORMAL,
|
||||
LC_ATTRIB_TEXCOORD,
|
||||
LC_ATTRIB_COLOR
|
||||
};
|
||||
|
||||
|
@ -120,6 +128,7 @@ public:
|
|||
mViewProjectionMatrixDirty = true;
|
||||
}
|
||||
|
||||
void SetLightingMode(lcLightingMode LightingMode);
|
||||
void SetProgram(lcProgramType ProgramType);
|
||||
void SetViewport(int x, int y, int Width, int Height);
|
||||
void SetLineWidth(float LineWidth);
|
||||
|
@ -155,7 +164,7 @@ public:
|
|||
void SetIndexBuffer(lcIndexBuffer IndexBuffer);
|
||||
void SetIndexBufferPointer(const void* IndexBuffer);
|
||||
|
||||
void SetVertexFormat(int BufferOffset, int PositionSize, int TexCoordSize, int ColorSize);
|
||||
void SetVertexFormat(int BufferOffset, int PositionSize, int NormalSize, int TexCoordSize, int ColorSize);
|
||||
void DrawPrimitives(GLenum Mode, GLint First, GLsizei Count);
|
||||
void DrawIndexedPrimitives(GLenum Mode, GLsizei Count, GLenum Type, int Offset);
|
||||
|
||||
|
@ -176,7 +185,9 @@ protected:
|
|||
char* mIndexBufferPointer;
|
||||
char* mVertexBufferOffset;
|
||||
|
||||
lcLightingMode mLightingMode;
|
||||
lcProgramType mProgramType;
|
||||
bool mNormalEnabled;
|
||||
bool mTexCoordEnabled;
|
||||
bool mColorEnabled;
|
||||
|
||||
|
|
|
@ -1648,10 +1648,10 @@ inline void lcPolygonPlaneClip(lcVector3* InPoints, int NumInPoints, lcVector3*
|
|||
}
|
||||
|
||||
// Return true if a polygon intersects a set of planes.
|
||||
inline bool lcTriangleIntersectsPlanes(float* p1, float* p2, float* p3, const lcVector4 Planes[6])
|
||||
inline bool lcTriangleIntersectsPlanes(const float* p1, const float* p2, const float* p3, const lcVector4 Planes[6])
|
||||
{
|
||||
const int NumPlanes = 6;
|
||||
float* Points[3] = { p1, p2, p3 };
|
||||
const float* Points[3] = { p1, p2, p3 };
|
||||
int Outcodes[3] = { 0, 0, 0 }, i;
|
||||
int NumPoints = 3;
|
||||
|
||||
|
|
|
@ -78,17 +78,17 @@ void lcMesh::CreateBox()
|
|||
mBoundingBox.Min = Min;
|
||||
mBoundingBox.Max = Max;
|
||||
|
||||
float* Verts = (float*)mVertexData;
|
||||
lcVertex* Verts = (lcVertex*)mVertexData;
|
||||
lcuint16* Indices = (lcuint16*)mIndexData;
|
||||
|
||||
*Verts++ = Min[0]; *Verts++ = Min[1]; *Verts++ = Min[2];
|
||||
*Verts++ = Min[0]; *Verts++ = Max[1]; *Verts++ = Min[2];
|
||||
*Verts++ = Max[0]; *Verts++ = Max[1]; *Verts++ = Min[2];
|
||||
*Verts++ = Max[0]; *Verts++ = Min[1]; *Verts++ = Min[2];
|
||||
*Verts++ = Min[0]; *Verts++ = Min[1]; *Verts++ = Max[2];
|
||||
*Verts++ = Min[0]; *Verts++ = Max[1]; *Verts++ = Max[2];
|
||||
*Verts++ = Max[0]; *Verts++ = Max[1]; *Verts++ = Max[2];
|
||||
*Verts++ = Max[0]; *Verts++ = Min[1]; *Verts++ = Max[2];
|
||||
Verts[0].Position = lcVector3(Min[0], Min[1], Min[2]);
|
||||
Verts[1].Position = lcVector3(Min[0], Max[1], Min[2]);
|
||||
Verts[2].Position = lcVector3(Max[0], Max[1], Min[2]);
|
||||
Verts[3].Position = lcVector3(Max[0], Min[1], Min[2]);
|
||||
Verts[4].Position = lcVector3(Min[0], Min[1], Max[2]);
|
||||
Verts[5].Position = lcVector3(Min[0], Max[1], Max[2]);
|
||||
Verts[6].Position = lcVector3(Max[0], Max[1], Max[2]);
|
||||
Verts[7].Position = lcVector3(Max[0], Min[1], Max[2]);
|
||||
|
||||
lcMeshSection* Section = &mLods[LC_MESH_LOD_HIGH].Sections[0];
|
||||
Section->ColorIndex = gDefaultColor;
|
||||
|
@ -139,7 +139,7 @@ bool lcMesh::MinIntersectDist(const lcVector3& Start, const lcVector3& End, floa
|
|||
if (!lcBoundingBoxRayIntersectDistance(mBoundingBox.Min, mBoundingBox.Max, Start, End, &Distance, NULL) || (Distance >= MinDistance))
|
||||
return false;
|
||||
|
||||
float* Verts = (float*)mVertexData;
|
||||
lcVertex* Verts = (lcVertex*)mVertexData;
|
||||
bool Hit = false;
|
||||
lcVector3 Intersection;
|
||||
|
||||
|
@ -154,12 +154,9 @@ bool lcMesh::MinIntersectDist(const lcVector3& Start, const lcVector3& End, floa
|
|||
|
||||
for (int Idx = 0; Idx < Section->NumIndices; Idx += 3)
|
||||
{
|
||||
float* p1 = Verts + Indices[Idx + 0] * 3;
|
||||
float* p2 = Verts + Indices[Idx + 1] * 3;
|
||||
float* p3 = Verts + Indices[Idx + 2] * 3;
|
||||
lcVector3 v1(p1[0], p1[1], p1[2]);
|
||||
lcVector3 v2(p2[0], p2[1], p2[2]);
|
||||
lcVector3 v3(p3[0], p3[1], p3[2]);
|
||||
const lcVector3& v1 = Verts[Indices[Idx]].Position;
|
||||
const lcVector3& v2 = Verts[Indices[Idx + 1]].Position;
|
||||
const lcVector3& v3 = Verts[Indices[Idx + 2]].Position;
|
||||
|
||||
if (lcLineTriangleMinIntersection(v1, v2, v3, Start, End, &MinDistance, &Intersection))
|
||||
Hit = true;
|
||||
|
@ -180,7 +177,7 @@ bool lcMesh::MinIntersectDist(const lcVector3& Start, const lcVector3& End, floa
|
|||
template<typename IndexType>
|
||||
bool lcMesh::IntersectsPlanes(const lcVector4 Planes[6])
|
||||
{
|
||||
float* Verts = (float*)mVertexData;
|
||||
lcVertex* Verts = (lcVertex*)mVertexData;
|
||||
|
||||
for (int SectionIdx = 0; SectionIdx < mLods[LC_MESH_LOD_HIGH].NumSections; SectionIdx++)
|
||||
{
|
||||
|
@ -192,7 +189,7 @@ bool lcMesh::IntersectsPlanes(const lcVector4 Planes[6])
|
|||
IndexType* Indices = (IndexType*)mIndexData + Section->IndexOffset / sizeof(IndexType);
|
||||
|
||||
for (int Idx = 0; Idx < Section->NumIndices; Idx += 3)
|
||||
if (lcTriangleIntersectsPlanes(&Verts[Indices[Idx]*3], &Verts[Indices[Idx+1]*3], &Verts[Indices[Idx+2]*3], Planes))
|
||||
if (lcTriangleIntersectsPlanes(Verts[Indices[Idx]].Position, Verts[Indices[Idx+1]].Position, Verts[Indices[Idx+2]].Position, Planes))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -215,7 +212,7 @@ void lcMesh::ExportPOVRay(lcFile& File, const char* MeshName, const char** Color
|
|||
sprintf(Line, "#declare lc_%s = union {\n", MeshName);
|
||||
File.WriteLine(Line);
|
||||
|
||||
float* Verts = (float*)mVertexData;
|
||||
lcVertex* Verts = (lcVertex*)mVertexData;
|
||||
|
||||
for (int SectionIdx = 0; SectionIdx < mLods[LC_MESH_LOD_HIGH].NumSections; SectionIdx++)
|
||||
{
|
||||
|
@ -230,10 +227,11 @@ void lcMesh::ExportPOVRay(lcFile& File, const char* MeshName, const char** Color
|
|||
|
||||
for (int Idx = 0; Idx < Section->NumIndices; Idx += 3)
|
||||
{
|
||||
sprintf(Line, " triangle { <%.2f, %.2f, %.2f>, <%.2f, %.2f, %.2f>, <%.2f, %.2f, %.2f> }\n",
|
||||
-Verts[Indices[Idx+0]*3+1] / 25.0f, -Verts[Indices[Idx+0]*3] / 25.0f, Verts[Indices[Idx+0]*3+2] / 25.0f,
|
||||
-Verts[Indices[Idx+1]*3+1] / 25.0f, -Verts[Indices[Idx+1]*3] / 25.0f, Verts[Indices[Idx+1]*3+2] / 25.0f,
|
||||
-Verts[Indices[Idx+2]*3+1] / 25.0f, -Verts[Indices[Idx+2]*3] / 25.0f, Verts[Indices[Idx+2]*3+2] / 25.0f);
|
||||
lcVector3& v1 = Verts[Indices[Idx]].Position;
|
||||
lcVector3& v2 = Verts[Indices[Idx + 1]].Position;
|
||||
lcVector3& v3 = Verts[Indices[Idx + 2]].Position;
|
||||
|
||||
sprintf(Line, " triangle { <%.2f, %.2f, %.2f>, <%.2f, %.2f, %.2f>, <%.2f, %.2f, %.2f> }\n", -v1.y / 25.0f, -v1.x / 25.0f, v1.z / 25.0f, -v2.y / 25.0f, -v2.x / 25.0f, v2.z / 25.0f, -v3.y / 25.0f, -v3.x / 25.0f, v3.z / 25.0f);
|
||||
File.WriteLine(Line);
|
||||
}
|
||||
|
||||
|
@ -355,7 +353,7 @@ bool lcMesh::FileLoad(lcMemFile& File)
|
|||
}
|
||||
}
|
||||
|
||||
File.ReadFloats((float*)mVertexData, 3 * mNumVertices + 5 * mNumTexturedVertices);
|
||||
File.ReadBuffer(mVertexData, mNumVertices * sizeof(lcVertex) + mNumTexturedVertices * sizeof(lcVertexTextured));
|
||||
if (mIndexType == GL_UNSIGNED_SHORT)
|
||||
File.ReadU16((lcuint16*)mIndexData, mIndexDataSize / 2);
|
||||
else
|
||||
|
@ -403,7 +401,7 @@ bool lcMesh::FileSave(lcMemFile& File)
|
|||
}
|
||||
}
|
||||
|
||||
File.WriteFloats((float*)mVertexData, 3 * mNumVertices + 5 * mNumTexturedVertices);
|
||||
File.WriteBuffer(mVertexData, mNumVertices * sizeof(lcVertex) + mNumTexturedVertices * sizeof(lcVertexTextured));
|
||||
if (mIndexType == GL_UNSIGNED_SHORT)
|
||||
File.WriteU16((lcuint16*)mIndexData, mIndexDataSize / 2);
|
||||
else
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "lc_math.h"
|
||||
|
||||
#define LC_MESH_FILE_ID LC_FOURCC('M', 'E', 'S', 'H')
|
||||
#define LC_MESH_FILE_VERSION 0x0111
|
||||
#define LC_MESH_FILE_VERSION 0x0112
|
||||
|
||||
enum lcMeshPrimitiveType
|
||||
{
|
||||
|
@ -19,11 +19,13 @@ enum lcMeshPrimitiveType
|
|||
struct lcVertex
|
||||
{
|
||||
lcVector3 Position;
|
||||
quint32 Normal;
|
||||
};
|
||||
|
||||
struct lcVertexTextured
|
||||
{
|
||||
lcVector3 Position;
|
||||
quint32 Normal;
|
||||
lcVector2 TexCoord;
|
||||
};
|
||||
|
||||
|
|
|
@ -1117,14 +1117,12 @@ void lcModel::DrawBackground(lcGLWidget* Widget)
|
|||
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
#ifndef LC_OPENGLES
|
||||
glDisable(GL_LIGHTING);
|
||||
#endif
|
||||
|
||||
float ViewWidth = (float)Widget->mWidth;
|
||||
float ViewHeight = (float)Widget->mHeight;
|
||||
|
||||
lcContext* Context = Widget->mContext;
|
||||
Context->SetLightingMode(LC_LIGHTING_UNLIT);
|
||||
Context->SetWorldMatrix(lcMatrix44Identity());
|
||||
Context->SetViewMatrix(lcMatrix44Translation(lcVector3(0.375, 0.375, 0.0)));
|
||||
Context->SetProjectionMatrix(lcMatrix44Ortho(0.0f, ViewWidth, 0.0f, ViewHeight, -1.0f, 1.0f));
|
||||
|
@ -1148,7 +1146,7 @@ void lcModel::DrawBackground(lcGLWidget* Widget)
|
|||
|
||||
Context->SetProgram(LC_PROGRAM_VERTEX_COLOR);
|
||||
Context->SetVertexBufferPointer(Verts);
|
||||
Context->SetVertexFormat(0, 2, 0, 4);
|
||||
Context->SetVertexFormat(0, 2, 0, 0, 4);
|
||||
|
||||
Context->DrawPrimitives(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
|
@ -1183,7 +1181,7 @@ void lcModel::DrawBackground(lcGLWidget* Widget)
|
|||
|
||||
Context->SetProgram(LC_PROGRAM_TEXTURE);
|
||||
Context->SetVertexBufferPointer(Verts);
|
||||
Context->SetVertexFormat(0, 2, 2, 0);
|
||||
Context->SetVertexFormat(0, 2, 0, 2, 0);
|
||||
|
||||
Context->DrawPrimitives(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "lc_global.h"
|
||||
#include "lc_profile.h"
|
||||
#include "lc_application.h"
|
||||
#include "lc_context.h"
|
||||
#include "image.h"
|
||||
#include "lc_model.h"
|
||||
#include "project.h"
|
||||
|
@ -58,7 +58,7 @@ lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] =
|
|||
{
|
||||
lcProfileEntry("Settings", "FixedAxes", false), // LC_PROFILE_FIXED_AXES
|
||||
lcProfileEntry("Settings", "LineWidth", 1.0f), // LC_PROFILE_LINE_WIDTH
|
||||
lcProfileEntry("Settings", "LightingMode", LC_LIGHTING_FLAT), // LC_PROFILE_LIGHTING_MODE
|
||||
lcProfileEntry("Settings", "LightingMode", LC_LIGHTING_UNLIT), // LC_PROFILE_LIGHTING_MODE
|
||||
lcProfileEntry("Settings", "DrawAxes", 0), // LC_PROFILE_DRAW_AXES
|
||||
lcProfileEntry("Settings", "DrawEdgeLines", 1), // LC_PROFILE_DRAW_EDGE_LINES
|
||||
lcProfileEntry("Settings", "GridStuds", 1), // LC_PROFILE_GRID_STUDS
|
||||
|
|
|
@ -370,7 +370,7 @@ void lcLight::DrawSpotLight(lcContext* Context) const
|
|||
};
|
||||
|
||||
Context->SetVertexBufferPointer(Verts);
|
||||
Context->SetVertexFormat(0, 3, 0, 0);
|
||||
Context->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
Context->SetIndexBufferPointer(Indices);
|
||||
|
||||
float LineWidth = lcGetPreferences().mLineWidth;
|
||||
|
@ -521,7 +521,7 @@ void lcLight::DrawPointLight(lcContext* Context) const
|
|||
Context->SetInterfaceColor(LC_COLOR_LIGHT);
|
||||
|
||||
Context->SetVertexBufferPointer(Vertices);
|
||||
Context->SetVertexFormat(0, 3, 0, 0);
|
||||
Context->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
Context->SetIndexBufferPointer(Indices);
|
||||
Context->DrawIndexedPrimitives(GL_TRIANGLES, NumIndices, GL_UNSIGNED_SHORT, 0);
|
||||
}
|
||||
|
|
|
@ -529,7 +529,7 @@ void lcPiece::DrawInterface(lcContext* Context) const
|
|||
Context->SetInterfaceColor(LC_COLOR_SELECTED);
|
||||
|
||||
Context->SetVertexBufferPointer(Verts);
|
||||
Context->SetVertexFormat(0, 3, 0, 0);
|
||||
Context->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
|
||||
Context->DrawPrimitives(GL_LINES, 0, 48);
|
||||
|
||||
|
@ -550,7 +550,7 @@ void lcPiece::DrawInterface(lcContext* Context) const
|
|||
Context->SetWorldMatrix(lcMul(mPivotMatrix, mModelWorld));
|
||||
|
||||
Context->SetVertexBufferPointer(Verts);
|
||||
Context->SetVertexFormat(0, 3, 0, 0);
|
||||
Context->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
Context->SetIndexBufferPointer(Indices);
|
||||
|
||||
Context->DrawIndexedPrimitives(GL_LINES, 24, GL_UNSIGNED_SHORT, 0);
|
||||
|
@ -588,7 +588,7 @@ void lcPiece::DrawInterface(lcContext* Context) const
|
|||
Context->SetWorldMatrix(lcMul(mControlPoints[ControlPointIdx].Transform, mModelWorld));
|
||||
|
||||
Context->SetVertexBufferPointer(Verts);
|
||||
Context->SetVertexFormat(0, 3, 0, 0);
|
||||
Context->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
Context->SetIndexBufferPointer(Indices);
|
||||
|
||||
if (IsFocused(LC_PIECE_SECTION_CONTROL_POINT_1 + ControlPointIdx))
|
||||
|
|
|
@ -787,13 +787,12 @@ void Project::Export3DStudio(const QString& FileName)
|
|||
|
||||
File.WriteU16(Mesh->mNumVertices);
|
||||
|
||||
float* Verts = (float*)Mesh->mVertexData;
|
||||
lcVertex* Verts = (lcVertex*)Mesh->mVertexData;
|
||||
const lcMatrix44& ModelWorld = ModelParts[PartIdx].WorldMatrix;
|
||||
|
||||
for (int VertexIdx = 0; VertexIdx < Mesh->mNumVertices; VertexIdx++)
|
||||
{
|
||||
lcVector3 Pos(Verts[VertexIdx * 3], Verts[VertexIdx * 3 + 1], Verts[VertexIdx * 3 + 2]);
|
||||
Pos = lcMul31(Pos, ModelWorld);
|
||||
lcVector3 Pos = lcMul31(Verts[VertexIdx].Position, ModelWorld);
|
||||
File.WriteFloat(Pos[0]);
|
||||
File.WriteFloat(Pos[1]);
|
||||
File.WriteFloat(Pos[2]);
|
||||
|
@ -1736,11 +1735,11 @@ void Project::ExportWavefront(const QString& FileName)
|
|||
continue;
|
||||
|
||||
const lcMatrix44& ModelWorld = ModelParts[PartIdx].WorldMatrix;
|
||||
float* Verts = (float*)Mesh->mVertexData;
|
||||
lcVertex* Verts = (lcVertex*)Mesh->mVertexData;
|
||||
|
||||
for (int i = 0; i < Mesh->mNumVertices * 3; i += 3)
|
||||
for (int VertexIdx = 0; VertexIdx < Mesh->mNumVertices; VertexIdx++)
|
||||
{
|
||||
lcVector3 Vertex = lcMul31(lcVector3(Verts[i], Verts[i+1], Verts[i+2]), ModelWorld);
|
||||
lcVector3 Vertex = lcMul31(Verts[VertexIdx].Position, ModelWorld);
|
||||
sprintf(Line, "v %.2f %.2f %.2f\n", Vertex[0], Vertex[1], Vertex[2]);
|
||||
OBJFile.WriteLine(Line);
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ void TexFont::PrintText(lcContext* Context, float Left, float Top, float Z, cons
|
|||
}
|
||||
|
||||
Context->SetVertexBufferPointer(Verts);
|
||||
Context->SetVertexFormat(0, 3, 2, 0);
|
||||
Context->SetVertexFormat(0, 3, 0, 2, 0);
|
||||
|
||||
Context->DrawPrimitives(GL_TRIANGLES, 0, 6 * (GLsizei)Length);
|
||||
|
||||
|
|
|
@ -568,34 +568,11 @@ void View::OnDraw()
|
|||
|
||||
mContext->SetViewMatrix(mCamera->mWorldView);
|
||||
mContext->SetProjectionMatrix(GetProjectionMatrix());
|
||||
mContext->SetProgram(LC_PROGRAM_SIMPLE); // todo: lighting
|
||||
mContext->SetLightingMode(Preferences.mLightingMode);
|
||||
mContext->SetProgram(LC_PROGRAM_SIMPLE);
|
||||
|
||||
#ifndef LC_OPENGLES
|
||||
const lcModelProperties& Properties = mModel->GetProperties();
|
||||
if (Preferences.mLightingMode != LC_LIGHTING_FLAT)
|
||||
{
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
float Shininess = 64.0f;
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, &Shininess);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, lcVector4(0.8f, 0.8f, 0.8f, 1.0f));
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, lcVector4(0.8f, 0.8f, 0.8f, 1.0f));
|
||||
|
||||
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lcVector4(Properties.mAmbientColor, 1.0f));
|
||||
|
||||
// for (int LightIdx = 0; LightIdx < mLights.GetSize(); LightIdx++)
|
||||
// mLights[LightIdx]->Setup(LightIdx);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
glShadeModel(GL_FLAT);
|
||||
}
|
||||
|
||||
if (Properties.mFogEnabled)
|
||||
{
|
||||
|
@ -614,19 +591,13 @@ void View::OnDraw()
|
|||
mContext->UnbindMesh(); // context remove
|
||||
|
||||
#ifndef LC_OPENGLES
|
||||
if (Preferences.mLightingMode != LC_LIGHTING_FLAT)
|
||||
{
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
glShadeModel(GL_FLAT);
|
||||
}
|
||||
|
||||
if (Properties.mFogEnabled)
|
||||
glDisable(GL_FOG);
|
||||
#endif
|
||||
|
||||
if (DrawInterface)
|
||||
{
|
||||
mContext->SetLightingMode(LC_LIGHTING_UNLIT);
|
||||
mContext->SetProgram(LC_PROGRAM_SIMPLE);
|
||||
mContext->DrawInterfaceObjects(mScene.mInterfaceObjects);
|
||||
|
||||
|
@ -676,7 +647,7 @@ void View::DrawSelectMoveOverlay()
|
|||
|
||||
mContext->SetIndexBuffer(mRotateMoveIndexBuffer);
|
||||
mContext->SetVertexBuffer(mRotateMoveVertexBuffer);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
|
||||
lcObject* Focus = mModel->GetFocusObject();
|
||||
lcuint32 AllowedTransforms = Focus ? Focus->GetAllowedTransforms() : LC_OBJECT_TRANSFORM_MOVE_X | LC_OBJECT_TRANSFORM_MOVE_Y | LC_OBJECT_TRANSFORM_MOVE_Z | LC_OBJECT_TRANSFORM_ROTATE_X | LC_OBJECT_TRANSFORM_ROTATE_Y | LC_OBJECT_TRANSFORM_ROTATE_Z;
|
||||
|
@ -829,7 +800,7 @@ void View::DrawSelectMoveOverlay()
|
|||
|
||||
mContext->SetVertexBufferPointer(Verts);
|
||||
mContext->ClearIndexBuffer();
|
||||
mContext->SetVertexFormat(0, 3, 0, 0);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
|
||||
mContext->DrawPrimitives(GL_LINES, 0, 2);
|
||||
mContext->DrawPrimitives(GL_TRIANGLE_STRIP, 2, 18);
|
||||
|
@ -917,7 +888,7 @@ void View::DrawRotateOverlay()
|
|||
int NumVerts = 1;
|
||||
|
||||
mContext->SetVertexBufferPointer(Verts);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
|
||||
float StartAngle;
|
||||
int i = 0;
|
||||
|
@ -979,7 +950,7 @@ void View::DrawRotateOverlay()
|
|||
mContext->SetWorldMatrix(lcMatrix44Identity());
|
||||
|
||||
mContext->SetVertexBufferPointer(Verts);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
|
||||
mContext->DrawPrimitives(GL_LINE_LOOP, 0, 32);
|
||||
}
|
||||
|
@ -1052,7 +1023,7 @@ void View::DrawRotateOverlay()
|
|||
}
|
||||
|
||||
mContext->SetVertexBufferPointer(Verts);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
|
||||
mContext->DrawPrimitives(GL_LINES, 0, NumVerts);
|
||||
}
|
||||
|
@ -1110,7 +1081,7 @@ void View::DrawRotateOverlay()
|
|||
Verts[5] = lcVector3(0.0f, StartY - OverlayScale * OverlayRotateArrowCapSize, EndZ + TipZ);
|
||||
|
||||
mContext->SetVertexBufferPointer(Verts);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
|
||||
mContext->DrawPrimitives(GL_LINES, 0, 6);
|
||||
}
|
||||
|
@ -1213,7 +1184,7 @@ void View::DrawSelectZoomRegionOverlay()
|
|||
glEnable(GL_BLEND);
|
||||
|
||||
mContext->SetVertexBufferPointer(Verts);
|
||||
mContext->SetVertexFormat(0, 2, 0, 0);
|
||||
mContext->SetVertexFormat(0, 2, 0, 0, 0);
|
||||
|
||||
mContext->SetColor(0.25f, 0.25f, 1.0f, 1.0f);
|
||||
mContext->DrawPrimitives(GL_TRIANGLE_STRIP, 0, 10);
|
||||
|
@ -1277,7 +1248,7 @@ void View::DrawRotateViewOverlay()
|
|||
*CurVert++ = cx - r + OverlayCameraSquareSize; *CurVert++ = cy - OverlayCameraSquareSize;
|
||||
|
||||
mContext->SetVertexBufferPointer(Verts);
|
||||
mContext->SetVertexFormat(0, 2, 0, 0);
|
||||
mContext->SetVertexFormat(0, 2, 0, 0, 0);
|
||||
|
||||
GLushort Indices[64 + 32] =
|
||||
{
|
||||
|
@ -1453,7 +1424,7 @@ void View::DrawGrid()
|
|||
mContext->SetProgram(LC_PROGRAM_TEXTURE);
|
||||
mContext->SetColor(lcVector4FromColor(Preferences.mGridStudColor));
|
||||
|
||||
mContext->SetVertexFormat(0, 3, 2, 0);
|
||||
mContext->SetVertexFormat(0, 3, 0, 2, 0);
|
||||
mContext->DrawPrimitives(GL_TRIANGLE_STRIP, 0, 4);
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
@ -1470,7 +1441,7 @@ void View::DrawGrid()
|
|||
|
||||
int NumVerts = 2 * (MaxX - MinX + MaxY - MinY + 2);
|
||||
|
||||
mContext->SetVertexFormat(BufferOffset, 3, 0, 0);
|
||||
mContext->SetVertexFormat(BufferOffset, 3, 0, 0, 0);
|
||||
mContext->DrawPrimitives(GL_LINES, 0, NumVerts);
|
||||
}
|
||||
|
||||
|
@ -1510,7 +1481,7 @@ void View::DrawAxes()
|
|||
mContext->SetProjectionMatrix(lcMatrix44Ortho(0, mWidth, 0, mHeight, -50, 50));
|
||||
|
||||
mContext->SetVertexBufferPointer(Verts);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0);
|
||||
mContext->SetVertexFormat(0, 3, 0, 0, 0);
|
||||
mContext->SetIndexBufferPointer(Indices);
|
||||
|
||||
mContext->SetColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
@ -1540,7 +1511,7 @@ void View::DrawAxes()
|
|||
gTexFont.GetGlyphTriangles(PosZ.x, PosZ.y, PosZ.z, 'Z', TextBuffer + 5 * 6 * 2);
|
||||
|
||||
mContext->SetVertexBufferPointer(TextBuffer);
|
||||
mContext->SetVertexFormat(0, 3, 2, 0);
|
||||
mContext->SetVertexFormat(0, 3, 0, 2, 0);
|
||||
|
||||
mContext->SetColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
mContext->DrawPrimitives(GL_TRIANGLES, 0, 6 * 3);
|
||||
|
@ -1556,12 +1527,10 @@ void View::DrawViewport()
|
|||
mContext->SetWorldMatrix(lcMatrix44Identity());
|
||||
mContext->SetViewMatrix(lcMatrix44Translation(lcVector3(0.375, 0.375, 0.0)));
|
||||
mContext->SetProjectionMatrix(lcMatrix44Ortho(0.0f, mWidth, 0.0f, mHeight, -1.0f, 1.0f));
|
||||
mContext->SetLightingMode(LC_LIGHTING_UNLIT);
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
#ifndef LC_OPENGLES
|
||||
glDisable(GL_LIGHTING);
|
||||
#endif
|
||||
|
||||
if (gMainWindow->GetActiveView() == this)
|
||||
{
|
||||
|
@ -1570,7 +1539,7 @@ void View::DrawViewport()
|
|||
float Verts[8] = { 0.0f, 0.0f, mWidth - 1.0f, 0.0f, mWidth - 1.0f, mHeight - 1.0f, 0.0f, mHeight - 1.0f };
|
||||
|
||||
mContext->SetVertexBufferPointer(Verts);
|
||||
mContext->SetVertexFormat(0, 2, 0, 0);
|
||||
mContext->SetVertexFormat(0, 2, 0, 0, 0);
|
||||
mContext->DrawPrimitives(GL_LINE_LOOP, 0, 4);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget *parent, void *data) :
|
|||
ui->gridLines->setChecked(options->Preferences.mDrawGridLines);
|
||||
ui->gridLineSpacing->setText(QString::number(options->Preferences.mGridLineSpacing));
|
||||
ui->axisIcon->setChecked(options->Preferences.mDrawAxes);
|
||||
ui->enableLighting->setChecked(options->Preferences.mLightingMode != LC_LIGHTING_FLAT);
|
||||
ui->enableLighting->setChecked(options->Preferences.mLightingMode != LC_LIGHTING_UNLIT);
|
||||
|
||||
QPixmap pix(12, 12);
|
||||
|
||||
|
@ -112,7 +112,7 @@ void lcQPreferencesDialog::accept()
|
|||
options->Preferences.mGridLineSpacing = gridLineSpacing;
|
||||
|
||||
options->Preferences.mDrawAxes = ui->axisIcon->isChecked();
|
||||
options->Preferences.mLightingMode = ui->enableLighting->isChecked() ? LC_LIGHTING_FULL : LC_LIGHTING_FLAT;
|
||||
options->Preferences.mLightingMode = ui->enableLighting->isChecked() ? LC_LIGHTING_FULL : LC_LIGHTING_UNLIT;
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue