|
|
|
@ -844,6 +844,7 @@ namespace olc |
|
|
|
|
std::vector<olc::vf2d> pos; |
|
|
|
|
std::vector<olc::vf2d> uv; |
|
|
|
|
std::vector<float> w; |
|
|
|
|
std::vector<float> z; |
|
|
|
|
std::vector<olc::Pixel> tint; |
|
|
|
|
olc::DecalMode mode = olc::DecalMode::NORMAL; |
|
|
|
|
olc::DecalStructure structure = olc::DecalStructure::FAN; |
|
|
|
@ -1081,7 +1082,7 @@ namespace olc |
|
|
|
|
void DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const olc::Pixel tint = olc::WHITE); |
|
|
|
|
void DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<float>& depth, const std::vector<olc::vf2d>& uv, const olc::Pixel tint = olc::WHITE); |
|
|
|
|
void DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<olc::Pixel>& tint); |
|
|
|
|
void DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<float>& w,const std::vector<olc::Pixel> &tint); |
|
|
|
|
void DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<float>& w, const std::vector<float>& z,const std::vector<olc::Pixel> &tint); |
|
|
|
|
|
|
|
|
|
// Draws a line in Decal Space
|
|
|
|
|
void DrawLineDecal(const olc::vf2d& pos1, const olc::vf2d& pos2, Pixel p = olc::WHITE); |
|
|
|
@ -2499,6 +2500,7 @@ namespace olc |
|
|
|
|
olc::vf2d uvbr = (source_pos + source_size - olc::vf2d(0.0001f, 0.0001f)) * decal->vUVScale; |
|
|
|
|
di.uv = { { uvtl.x, uvtl.y }, { uvtl.x, uvbr.y }, { uvbr.x, uvbr.y }, { uvbr.x, uvtl.y } }; |
|
|
|
|
di.w = { 1,1,1,1 }; |
|
|
|
|
di.z = { 0,0,0,0 }; |
|
|
|
|
di.mode = nDecalMode; |
|
|
|
|
di.structure = nDecalStructure; |
|
|
|
|
vLayers[nTargetLayer].vecDecalInstance.push_back(di); |
|
|
|
@ -2527,6 +2529,7 @@ namespace olc |
|
|
|
|
olc::vf2d uvbr = uvtl + ((source_size) * decal->vUVScale); |
|
|
|
|
di.uv = { { uvtl.x, uvtl.y }, { uvtl.x, uvbr.y }, { uvbr.x, uvbr.y }, { uvbr.x, uvtl.y } }; |
|
|
|
|
di.w = { 1,1,1,1 }; |
|
|
|
|
di.z = { 0,0,0,0 }; |
|
|
|
|
di.mode = nDecalMode; |
|
|
|
|
di.structure = nDecalStructure; |
|
|
|
|
vLayers[nTargetLayer].vecDecalInstance.push_back(di); |
|
|
|
@ -2554,6 +2557,7 @@ namespace olc |
|
|
|
|
di.pos = { { vScreenSpacePos.x, vScreenSpacePos.y }, { vScreenSpacePos.x, vScreenSpaceDim.y }, { vScreenSpaceDim.x, vScreenSpaceDim.y }, { vScreenSpaceDim.x, vScreenSpacePos.y } }; |
|
|
|
|
di.uv = { { 0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f} }; |
|
|
|
|
di.w = { 1, 1, 1, 1 }; |
|
|
|
|
di.z = { 0,0,0,0 }; |
|
|
|
|
di.mode = nDecalMode; |
|
|
|
|
di.structure = nDecalStructure; |
|
|
|
|
vLayers[nTargetLayer].vecDecalInstance.push_back(di); |
|
|
|
@ -2574,6 +2578,7 @@ namespace olc |
|
|
|
|
di.uv[i] = uv[i]; |
|
|
|
|
di.tint[i] = col[i]; |
|
|
|
|
di.w[i] = 1.0f; |
|
|
|
|
di.z[i] = 0.0f; |
|
|
|
|
} |
|
|
|
|
di.mode = nDecalMode; |
|
|
|
|
di.structure = nDecalStructure; |
|
|
|
@ -2595,13 +2600,14 @@ namespace olc |
|
|
|
|
di.uv[i] = uv[i]; |
|
|
|
|
di.tint[i] = tint; |
|
|
|
|
di.w[i] = 1.0f; |
|
|
|
|
di.z[i] = 0.0f; |
|
|
|
|
} |
|
|
|
|
di.mode = nDecalMode; |
|
|
|
|
di.structure = nDecalStructure; |
|
|
|
|
vLayers[nTargetLayer].vecDecalInstance.push_back(di); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<float>& w,const std::vector<olc::Pixel> &tint) |
|
|
|
|
void PixelGameEngine::DrawPolygonDecal(olc::Decal* decal, const std::vector<olc::vf2d>& pos, const std::vector<olc::vf2d>& uv, const std::vector<float>& w, const std::vector<float>& z,const std::vector<olc::Pixel> &tint) |
|
|
|
|
{ |
|
|
|
|
DecalInstance di; |
|
|
|
|
di.decal = decal; |
|
|
|
@ -2609,6 +2615,7 @@ namespace olc |
|
|
|
|
di.pos.resize(di.points); |
|
|
|
|
di.uv.resize(di.points); |
|
|
|
|
di.w.resize(di.points); |
|
|
|
|
di.z.resize(di.points); |
|
|
|
|
di.tint.resize(di.points); |
|
|
|
|
for (uint32_t i = 0; i < di.points; i++) |
|
|
|
|
{ |
|
|
|
@ -2616,6 +2623,7 @@ namespace olc |
|
|
|
|
di.uv[i] = uv[i]; |
|
|
|
|
di.tint[i] = tint[i]; |
|
|
|
|
di.w[i] = w[i]; |
|
|
|
|
di.z[i] = z[i]; |
|
|
|
|
} |
|
|
|
|
di.mode = nDecalMode; |
|
|
|
|
di.structure = nDecalStructure; |
|
|
|
@ -2637,6 +2645,7 @@ namespace olc |
|
|
|
|
di.uv[i] = uv[i]; |
|
|
|
|
di.tint[i] = tint[i]; |
|
|
|
|
di.w[i] = 1.0f; |
|
|
|
|
di.z[i] = 0.0f; |
|
|
|
|
} |
|
|
|
|
di.mode = nDecalMode; |
|
|
|
|
di.structure = nDecalStructure; |
|
|
|
@ -2658,6 +2667,7 @@ namespace olc |
|
|
|
|
di.uv[i] = uv[i]; |
|
|
|
|
di.tint[i] = tint; |
|
|
|
|
di.w[i] = 1.0f; |
|
|
|
|
di.z[i] = 0.0f; |
|
|
|
|
} |
|
|
|
|
di.mode = nDecalMode; |
|
|
|
|
di.structure = nDecalStructure; |
|
|
|
@ -2679,6 +2689,7 @@ namespace olc |
|
|
|
|
{ |
|
|
|
|
di.pos[i] = { pos[i][0], pos[i][1] }; |
|
|
|
|
di.w[i] = pos[i][2]; |
|
|
|
|
di.z[i] = pos[i][2]; |
|
|
|
|
di.uv[i] = tex[i]; |
|
|
|
|
di.tint[i] = col[i];
|
|
|
|
|
} |
|
|
|
@ -2700,10 +2711,12 @@ namespace olc |
|
|
|
|
di.uv[0] = { 0.0f, 0.0f }; |
|
|
|
|
di.tint[0] = p; |
|
|
|
|
di.w[0] = 1.0f; |
|
|
|
|
di.z[0] = 0.0f; |
|
|
|
|
di.pos[1] = { (pos2.x * vInvScreenSize.x) * 2.0f - 1.0f, ((pos2.y * vInvScreenSize.y) * 2.0f - 1.0f) * -1.0f }; |
|
|
|
|
di.uv[1] = { 0.0f, 0.0f }; |
|
|
|
|
di.tint[1] = p; |
|
|
|
|
di.w[1] = 1.0f; |
|
|
|
|
di.z[1] = 0.0f; |
|
|
|
|
di.mode = olc::DecalMode::WIREFRAME; |
|
|
|
|
vLayers[nTargetLayer].vecDecalInstance.push_back(di); |
|
|
|
|
} |
|
|
|
@ -2745,6 +2758,7 @@ namespace olc |
|
|
|
|
di.pos[i] = di.pos[i] * vInvScreenSize * 2.0f - olc::vf2d(1.0f, 1.0f); |
|
|
|
|
di.pos[i].y *= -1.0f; |
|
|
|
|
di.w[i] = 1; |
|
|
|
|
di.z[i] = 0; |
|
|
|
|
} |
|
|
|
|
di.mode = nDecalMode; |
|
|
|
|
di.structure = nDecalStructure; |
|
|
|
@ -2759,6 +2773,7 @@ namespace olc |
|
|
|
|
di.points = 4; |
|
|
|
|
di.tint = { tint, tint, tint, tint }; |
|
|
|
|
di.w = { 1, 1, 1, 1 }; |
|
|
|
|
di.z = { 0,0,0,0 }; |
|
|
|
|
di.pos.resize(4); |
|
|
|
|
di.pos[0] = (olc::vf2d(0.0f, 0.0f) - center) * scale; |
|
|
|
|
di.pos[1] = (olc::vf2d(0.0f, source_size.y) - center) * scale; |
|
|
|
@ -2787,6 +2802,7 @@ namespace olc |
|
|
|
|
di.decal = decal; |
|
|
|
|
di.tint = { tint, tint, tint, tint }; |
|
|
|
|
di.w = { 1, 1, 1, 1 }; |
|
|
|
|
di.z = { 0,0,0,0 }; |
|
|
|
|
di.pos.resize(4); |
|
|
|
|
di.uv = { { 0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f} }; |
|
|
|
|
olc::vf2d center; |
|
|
|
@ -2823,6 +2839,7 @@ namespace olc |
|
|
|
|
di.decal = decal; |
|
|
|
|
di.tint = { tint, tint, tint, tint }; |
|
|
|
|
di.w = { 1, 1, 1, 1 }; |
|
|
|
|
di.z = { 0,0,0,0 }; |
|
|
|
|
di.pos.resize(4); |
|
|
|
|
di.uv = { { 0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, 0.0f} }; |
|
|
|
|
olc::vf2d center; |
|
|
|
@ -3966,6 +3983,8 @@ namespace olc |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
glEnable(GL_DEPTH_TEST); |
|
|
|
|
glDepthFunc(GL_LESS);
|
|
|
|
|
if (nDecalMode == DecalMode::WIREFRAME) |
|
|
|
|
glBegin(GL_LINE_LOOP); |
|
|
|
|
else |
|
|
|
@ -3983,14 +4002,14 @@ namespace olc |
|
|
|
|
{ |
|
|
|
|
glColor4ub(decal.tint[n].r, decal.tint[n].g, decal.tint[n].b, decal.tint[n].a); |
|
|
|
|
glTexCoord4f(decal.uv[n].x, decal.uv[n].y, 0.0f, decal.w[n]); |
|
|
|
|
glVertex2f(decal.pos[n].x, decal.pos[n].y); |
|
|
|
|
glVertex3f(decal.pos[n].x, decal.pos[n].y, decal.z[n]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
glEnd(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//glDisable(GL_DEPTH_TEST);
|
|
|
|
|
glDisable(GL_DEPTH_TEST); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
uint32_t CreateTexture(const uint32_t width, const uint32_t height, const bool filtered, const bool clamp) override |
|
|
|
|