Porting to web
This commit is contained in:
1 parent
6961152d34
commit
723b973c7f
16 files changed
+182
-22
No files matched your search
@@ -5,8 +5,16 @@
|
||||
#include "Environment.h"
|
||||
#include "StoneObject.h"
|
||||
|
||||
|
||||
namespace ZL {
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
using std::min;
|
||||
using std::max;
|
||||
#endif
|
||||
|
||||
extern const char* CONST_ZIP_FILE;
|
||||
|
||||
Matrix3f GetRotationForTriangle(const Triangle& tri) {
|
||||
|
||||
Vector3f vA = tri.data[0];
|
||||
@@ -66,16 +74,18 @@ namespace ZL {
|
||||
planetRenderStruct.RefreshVBO();
|
||||
|
||||
|
||||
sandTexture = std::make_unique<Texture>(CreateTextureDataFromPng("./resources/sand2.png", ""));
|
||||
stoneTexture = std::make_unique<Texture>(CreateTextureDataFromPng("./resources/rock.png", ""));
|
||||
|
||||
sandTexture = std::make_unique<Texture>(CreateTextureDataFromPng("./resources/sand2.png", CONST_ZIP_FILE));
|
||||
stoneTexture = std::make_unique<Texture>(CreateTextureDataFromPng("./resources/rock.png", CONST_ZIP_FILE));
|
||||
|
||||
|
||||
#ifndef SIMPLIFIED
|
||||
// Атмосфера
|
||||
planetAtmosphereRenderStruct.data = planetData.getAtmosphereLod().vertexData;
|
||||
if (planetAtmosphereRenderStruct.data.PositionData.size() > 0)
|
||||
{
|
||||
planetAtmosphereRenderStruct.RefreshVBO();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
planetStones = CreateStoneGroupData(778, planetData.getLodLevel(lodIndex));
|
||||
@@ -195,6 +205,7 @@ namespace ZL {
|
||||
|
||||
void PlanetObject::draw(Renderer& renderer) {
|
||||
|
||||
#ifndef SIMPLIFIED
|
||||
{
|
||||
if (stoneMapFB == nullptr)
|
||||
{
|
||||
@@ -210,6 +221,7 @@ namespace ZL {
|
||||
stoneMapFB->GenerateMipmaps();
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
//bakeStoneTexture(renderer);
|
||||
|
||||
@@ -220,7 +232,9 @@ namespace ZL {
|
||||
drawPlanet(renderer);
|
||||
drawStones(renderer);
|
||||
|
||||
#ifndef SIMPLIFIED
|
||||
drawAtmosphere(renderer);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PlanetObject::drawPlanet(Renderer& renderer)
|
||||
@@ -291,8 +305,10 @@ namespace ZL {
|
||||
playerLightFactor = max(0.0f, (playerLightFactor + 0.2f) / 1.2f);
|
||||
renderer.RenderUniform1f("uPlayerLightFactor", playerLightFactor);
|
||||
|
||||
#ifndef SIMPLIFIED
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, stoneMapFB->getTextureID());
|
||||
#endif
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, sandTexture->getTexID());
|
||||
|
||||
@@ -357,7 +373,7 @@ namespace ZL {
|
||||
Vector3f playerDirWorld = Environment::shipPosition.normalized();
|
||||
float playerLightFactor = max(0.0f, (playerDirWorld.dot(-sunDirWorld) + 0.2f) / 1.2f);
|
||||
renderer.RenderUniform1f("uPlayerLightFactor", playerLightFactor);
|
||||
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
glEnable(GL_BLEND);
|
||||
@@ -365,6 +381,7 @@ namespace ZL {
|
||||
glBindTexture(GL_TEXTURE_2D, stoneTexture->getTexID());
|
||||
|
||||
for (int i : triangleIndicesToDraw)
|
||||
//for (int i = 0; i < stonesToRender.size(); i++)
|
||||
{
|
||||
if (stonesToRender[i].data.PositionData.size() > 0)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user