texture loading!
This commit is contained in:
@@ -22,9 +22,9 @@
|
||||
|
||||
namespace Game
|
||||
{
|
||||
void EntityRenderData::Render(const Model* models, const Material* materials)
|
||||
void EntityRenderData::Render(const Model* models, const Material* materials, const Texture* textures)
|
||||
{
|
||||
if (models == nullptr || materials == nullptr) return;
|
||||
if (models == nullptr || materials == nullptr || textures == nullptr) return;
|
||||
if (!Generated::IsValid(ModelH) || MaterialHandle == EMaterial::UNDEFINED) return;
|
||||
if (!Visible) return;
|
||||
auto& rendering = GameRendering::Get();
|
||||
@@ -46,12 +46,20 @@ namespace Game
|
||||
timeValues[0] = GetInstance().Time.Now;
|
||||
|
||||
float texInfo[4]{0.0f};
|
||||
texInfo[0] = currentMaterial.Textures[0].Info.width;
|
||||
texInfo[1] = currentMaterial.Textures[0].Info.height;
|
||||
texInfo[0] = textures[0].Info.width;
|
||||
texInfo[1] = textures[0].Info.height;
|
||||
texInfo[2] = rendering.DitherTextures.DitherTexWH;
|
||||
texInfo[3] = rendering.DitherTextures.DitherTexDepth;
|
||||
|
||||
bgfx::setTexture(0, currentMaterial.Textures[0].SamplerHandle, currentMaterial.Textures[0].Handle);
|
||||
bgfx::UniformHandle sampler = rendering.DefaultSampler;
|
||||
bgfx::TextureHandle tex = rendering.Textures[0].RenderHandle;
|
||||
if (IsValid(TextureHandle))
|
||||
{
|
||||
sampler = textures[TextureHandle.TextureIdx].SamplerHandle;
|
||||
tex = textures[TextureHandle.TextureIdx].RenderHandle;
|
||||
}
|
||||
|
||||
bgfx::setTexture(0, sampler, tex);
|
||||
bgfx::setTexture(1, rendering.DitherTextures.DitherSampler, rendering.DitherTextures.FinalTex);
|
||||
bgfx::setTexture(2, rendering.DitherTextures.RampSampler, rendering.DitherTextures.RampTex);
|
||||
bgfx::setUniform(currentMaterial.Uniforms[Material::UTime], timeValues);
|
||||
@@ -248,7 +256,7 @@ namespace Game
|
||||
END_PERF(GetShared().Window.PerfCounters, PerfCounterType::GameLevelUpdate, GetShared().Window.FrameCounter);
|
||||
}
|
||||
|
||||
void Level::Render(uint16_t viewId, const Model* models, const Material* materials)
|
||||
void Level::Render(uint16_t viewId, const Model* models, const Material* materials, const Texture* textures)
|
||||
{
|
||||
ZoneScopedN("Level Render");
|
||||
auto& shared = GetShared();
|
||||
@@ -275,10 +283,10 @@ namespace Game
|
||||
|
||||
bgfx::touch(viewId);
|
||||
|
||||
Cubes.Render(models, materials);
|
||||
Tests.Render(models, materials);
|
||||
PuzzleTiles.Render(models, materials);
|
||||
UIQuads.Render(models, materials);
|
||||
Cubes.Render(models, materials, textures);
|
||||
Tests.Render(models, materials, textures);
|
||||
PuzzleTiles.Render(models, materials, textures);
|
||||
UIQuads.Render(models, materials, textures);
|
||||
}
|
||||
|
||||
void Cube::Setup()
|
||||
@@ -335,10 +343,18 @@ namespace Game
|
||||
void WorldPuzzle::Update()
|
||||
{
|
||||
Transform& camTransform = GetInstance().Player.PlayerCamTransform;
|
||||
camTransform.UpdateMatrixForCam();
|
||||
Vec3 cameraPos = camTransform.GetPosition() * -1;
|
||||
Level& level = GetInstance().GameLevel;
|
||||
auto& staticCards = Puzzle::GetStaticPuzzleData().Cards;
|
||||
|
||||
Transform boardTransform;
|
||||
boardTransform.Rotation = camTransform.Rotation.Inverse();
|
||||
Vec3 fw = {camTransform.M.M[2], camTransform.M.M[6], camTransform.M.M[10]};
|
||||
Vec3 pos = camTransform.GetPosition() * -1;
|
||||
pos += fw;
|
||||
boardTransform.SetPosition(pos);
|
||||
|
||||
for (int8_t y = 0; y < Data.HeightTiles / Puzzle::Config::CardSize; ++y)
|
||||
{
|
||||
for (int8_t x = 0; x < Data.WidthTiles / Puzzle::Config::CardSize; ++x)
|
||||
@@ -352,6 +368,8 @@ namespace Game
|
||||
quad.EData.Visible = IsValid;
|
||||
|
||||
tile.EData.ModelH = IsValid ? staticCards[card.RefCard.Idx].ModelHandle : staticCards[0].ModelHandle;
|
||||
quad.EData.TextureHandle =
|
||||
IsValid ? staticCards[card.RefCard.Idx].BoardTextureHandle : Generated::TextureHandle{};
|
||||
Vec3 cardPos = {
|
||||
(float)card.Position.X * Puzzle::Config::CardScaleWorld,
|
||||
-5.0f,
|
||||
@@ -364,14 +382,9 @@ namespace Game
|
||||
tile.EData.Transform.SetPosition(cardPos);
|
||||
bx::mtxRotateY(tile.EData.Transform.Rotation.M, card.Rotation * bx::kPi * 0.5f);
|
||||
|
||||
camTransform.UpdateMatrixForCam();
|
||||
Vec3 fw = {camTransform.M.M[2], camTransform.M.M[6], camTransform.M.M[10]};
|
||||
Vec3 pos = camTransform.GetPosition() * -1;
|
||||
pos += fw;
|
||||
pos += Vec3{cardPos.x, cardPos.z, 0.0f} * 0.025f;
|
||||
quad.EData.Transform.SetPosition(pos);
|
||||
quad.EData.Transform = boardTransform;
|
||||
quad.EData.Transform.TranslateLocal(Vec3{(float)card.Position.X, (float)card.Position.Y, 0.0f} * 0.21f);
|
||||
quad.EData.Transform.Scale = {0.1f, 0.1f, 0.1f};
|
||||
quad.EData.Transform.Rotation = camTransform.Rotation.Inverse();
|
||||
quad.EData.Transform.Rotate(Vec3{bx::kPi * 0.5f, 0.0f, 0.0f});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user