docs
This commit is contained in:
parent
eefd327845
commit
4b48c7c28c
@ -148,6 +148,7 @@ void WorldRenderer::draw(const GfxContext& pctx, Camera* camera, bool hudVisible
|
|||||||
Assets* assets = engine->getAssets();
|
Assets* assets = engine->getAssets();
|
||||||
Atlas* atlas = assets->getAtlas("blocks");
|
Atlas* atlas = assets->getAtlas("blocks");
|
||||||
Shader* shader = assets->getShader("main");
|
Shader* shader = assets->getShader("main");
|
||||||
|
Shader* linesShader = assets->getShader("lines");
|
||||||
|
|
||||||
const Viewport& viewport = pctx.getViewport();
|
const Viewport& viewport = pctx.getViewport();
|
||||||
int displayWidth = viewport.getWidth();
|
int displayWidth = viewport.getWidth();
|
||||||
@ -156,7 +157,7 @@ void WorldRenderer::draw(const GfxContext& pctx, Camera* camera, bool hudVisible
|
|||||||
// Drawing background sky plane
|
// Drawing background sky plane
|
||||||
skybox->draw(pctx, camera, assets, level->getWorld()->daytime, fog);
|
skybox->draw(pctx, camera, assets, level->getWorld()->daytime, fog);
|
||||||
|
|
||||||
Shader* linesShader = assets->getShader("lines");
|
// Actually world render with depth buffer on
|
||||||
{
|
{
|
||||||
GfxContext ctx = pctx.sub();
|
GfxContext ctx = pctx.sub();
|
||||||
ctx.setDepthTest(true);
|
ctx.setDepthTest(true);
|
||||||
@ -174,16 +175,18 @@ void WorldRenderer::draw(const GfxContext& pctx, Camera* camera, bool hudVisible
|
|||||||
shader->uniform1f("u_dayTime", level->world->daytime);
|
shader->uniform1f("u_dayTime", level->world->daytime);
|
||||||
shader->uniform3f("u_cameraPos", camera->position);
|
shader->uniform3f("u_cameraPos", camera->position);
|
||||||
shader->uniform1i("u_cubemap", 1);
|
shader->uniform1i("u_cubemap", 1);
|
||||||
|
|
||||||
|
// Light emission when an emissive item is chosen
|
||||||
{
|
{
|
||||||
auto inventory = player->getInventory();
|
auto inventory = player->getInventory();
|
||||||
ItemStack& stack = inventory->getSlot(player->getChosenSlot());
|
ItemStack& stack = inventory->getSlot(player->getChosenSlot());
|
||||||
ItemDef* item = indices->getItemDef(stack.getItemId());
|
auto item = indices->getItemDef(stack.getItemId());
|
||||||
assert(item != nullptr);
|
|
||||||
float multiplier = 0.5f;
|
float multiplier = 0.5f;
|
||||||
shader->uniform3f("u_torchlightColor",
|
shader->uniform3f("u_torchlightColor",
|
||||||
item->emission[0] / 15.0f * multiplier,
|
item->emission[0] / 15.0f * multiplier,
|
||||||
item->emission[1] / 15.0f * multiplier,
|
item->emission[1] / 15.0f * multiplier,
|
||||||
item->emission[2] / 15.0f * multiplier);
|
item->emission[2] / 15.0f * multiplier
|
||||||
|
);
|
||||||
shader->uniform1f("u_torchlightDistance", 6.0f);
|
shader->uniform1f("u_torchlightDistance", 6.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,8 +199,7 @@ void WorldRenderer::draw(const GfxContext& pctx, Camera* camera, bool hudVisible
|
|||||||
// Selected block
|
// Selected block
|
||||||
if (PlayerController::selectedBlockId != -1 && hudVisible){
|
if (PlayerController::selectedBlockId != -1 && hudVisible){
|
||||||
blockid_t id = PlayerController::selectedBlockId;
|
blockid_t id = PlayerController::selectedBlockId;
|
||||||
Block* block = indices->getBlockDef(id);
|
auto block = indices->getBlockDef(id);
|
||||||
assert(block != nullptr);
|
|
||||||
const glm::vec3 pos = PlayerController::selectedBlockPosition;
|
const glm::vec3 pos = PlayerController::selectedBlockPosition;
|
||||||
const glm::vec3 point = PlayerController::selectedPointPosition;
|
const glm::vec3 point = PlayerController::selectedPointPosition;
|
||||||
const glm::vec3 norm = PlayerController::selectedBlockNormal;
|
const glm::vec3 norm = PlayerController::selectedBlockNormal;
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
|
||||||
|
/// @brief Cubemap texture
|
||||||
class Cubemap : public Texture {
|
class Cubemap : public Texture {
|
||||||
public:
|
public:
|
||||||
Cubemap(uint width, uint height, ImageFormat format);
|
Cubemap(uint width, uint height, ImageFormat format);
|
||||||
|
|||||||
@ -21,10 +21,21 @@ public:
|
|||||||
Mesh(vertexBuffer, vertices, nullptr, 0, attrs) {};
|
Mesh(vertexBuffer, vertices, nullptr, 0, attrs) {};
|
||||||
~Mesh();
|
~Mesh();
|
||||||
|
|
||||||
|
/// @brief Update GL vertex and index buffers data without changing VAO attributes
|
||||||
|
/// @param vertexBuffer vertex data buffer
|
||||||
|
/// @param vertices number of vertices in new buffer
|
||||||
|
/// @param indexBuffer indices buffer
|
||||||
|
/// @param indices number of values in indices buffer
|
||||||
void reload(const float* vertexBuffer, size_t vertices, const int* indexBuffer = nullptr, size_t indices = 0);
|
void reload(const float* vertexBuffer, size_t vertices, const int* indexBuffer = nullptr, size_t indices = 0);
|
||||||
|
|
||||||
|
/// @brief Draw mesh with specified primitives type
|
||||||
|
/// @param primitive primitives type
|
||||||
void draw(unsigned int primitive);
|
void draw(unsigned int primitive);
|
||||||
|
|
||||||
|
/// @brief Draw mesh as triangles
|
||||||
void draw();
|
void draw();
|
||||||
|
|
||||||
|
/// @brief Total numbers of alive mesh objects
|
||||||
static int meshesCount;
|
static int meshesCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user