FRONTEND: started map renderer for mini and world map
parent
1925cbda81
commit
f440758f92
|
@ -1,8 +0,0 @@
|
||||||
$out vec4 o_color;
|
|
||||||
$in vec2 v_texcoord;
|
|
||||||
|
|
||||||
uniform sampler2D u_texture;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
o_color = $texture2D(u_texture, v_texcoord);
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
uniform mat4 u_view;
|
|
||||||
uniform mat4 u_model;
|
|
||||||
uniform mat4 u_projection;
|
|
||||||
$in vec3 a_pos;
|
|
||||||
$in vec2 a_texcoord;
|
|
||||||
$out vec2 v_texcoord;
|
|
||||||
|
|
||||||
void main(void) {
|
|
||||||
v_texcoord = a_texcoord;
|
|
||||||
gl_Position = u_projection * u_view * u_model * vec4(a_pos, 1.0);
|
|
||||||
}
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "MapRenderer.h"
|
||||||
|
#include "video/ScopedFrameBuffer.h"
|
||||||
|
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
MapRenderer::MapRenderer(const voxel::WorldPtr& world) :
|
||||||
|
_world(world) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapRenderer::shutdown() {
|
||||||
|
_frameBuffer.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MapRenderer::init() {
|
||||||
|
// TODO: size
|
||||||
|
const glm::vec2 dim(42, 42);
|
||||||
|
if (!_frameBuffer.init(dim)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// TODO: setup shader
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapRenderer::updateMiniMap() {
|
||||||
|
// TODO: render minimap to texture
|
||||||
|
video::ScopedFrameBuffer scoped(_frameBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int MapRenderer::renderMiniMap(const video::Camera& camera, const glm::vec2& pos, int* vertices) {
|
||||||
|
// TODO: render fbo in ortho mode to the given coordinates
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "voxel/World.h"
|
||||||
|
#include "video/Camera.h"
|
||||||
|
#include "video/FrameBuffer.h"
|
||||||
|
#include "FrontendShaders.h"
|
||||||
|
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Class to render the minimap and the worldmap of the voxel chunks
|
||||||
|
*/
|
||||||
|
class MapRenderer {
|
||||||
|
private:
|
||||||
|
voxel::WorldPtr _world;
|
||||||
|
video::FrameBuffer _frameBuffer;
|
||||||
|
public:
|
||||||
|
MapRenderer(const voxel::WorldPtr& world);
|
||||||
|
|
||||||
|
bool init();
|
||||||
|
void shutdown();
|
||||||
|
|
||||||
|
// TODO: maybe the list of chunks to include in the minimap? That way we can also use this class
|
||||||
|
// for the worldmap
|
||||||
|
void updateMiniMap();
|
||||||
|
|
||||||
|
int renderMiniMap(const video::Camera& camera, const glm::vec2& pos, int* vertices);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -11,7 +11,7 @@ set(SRCS
|
||||||
)
|
)
|
||||||
set(LIB ui)
|
set(LIB ui)
|
||||||
add_library(${LIB} ${SRCS})
|
add_library(${LIB} ${SRCS})
|
||||||
generate_shaders(${LIB} ui)
|
generate_shaders(${LIB} texture)
|
||||||
target_link_libraries(${LIB} core io video turbobadger)
|
target_link_libraries(${LIB} core io video turbobadger)
|
||||||
set_target_properties(${LIB} PROPERTIES FOLDER ${LIB})
|
set_target_properties(${LIB} PROPERTIES FOLDER ${LIB})
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public:
|
||||||
class UIRendererGL: public TBRendererBatcher {
|
class UIRendererGL: public TBRendererBatcher {
|
||||||
private:
|
private:
|
||||||
UIBitmapGL _white;
|
UIBitmapGL _white;
|
||||||
shader::UiShader _shader;
|
shader::TextureShader _shader;
|
||||||
GLuint _buffer = 0u;
|
GLuint _buffer = 0u;
|
||||||
GLuint _vao = 0u;
|
GLuint _vao = 0u;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue