Browse Source

minor cleanup

testing
totallyfake 4 years ago
parent
commit
345e56dfb1
  1. 4
      res/config.conf
  2. 2
      res/shaders/voxelvert.vert.glsl
  3. 39
      src/scenes/testscene.cpp
  4. 4
      src/scenes/testscene.h

4
res/config.conf

@ -2,8 +2,8 @@ @@ -2,8 +2,8 @@
graphics {
res {
x = 800; horizontal resolution
y = 600; vertical resolution
x = 1920; horizontal resolution
y = 1080; vertical resolution
}
fov = 90
vsync = 0

2
res/shaders/voxelvert.vert.glsl

@ -29,7 +29,7 @@ void main() { @@ -29,7 +29,7 @@ void main() {
vec3 final_position = pos_unpacked + offset_unpacked;
vec4 eyeSpacePosVert = view * model * vec4(final_position, 1.0);
gl_Position = proj * eyeSpacePosVert;
texCoordInterp = vec3(uv_unpacked, 0.0f);//texCoord;
texCoordInterp = vec3(uv_unpacked, 2.0f);//texCoord;
lightDataInterp = vec3(1.0f, 1.0f, 1.0f);
eyeSpacePos = eyeSpacePosVert;
}

39
src/scenes/testscene.cpp

@ -46,31 +46,7 @@ void TestScene::init() { @@ -46,31 +46,7 @@ void TestScene::init() {
tiles.updateTextureAt(1, "res/dirt.png");
tiles.updateTextureAt(2, "res/test.png");
//define vertices
float vertices[] {
-0.01f, 0.01f, 0.0f,
0.01f, -0.01f, 0.0f,
-0.01f, -0.01f, 0.0f,
-0.01f, 0.01f, 0.0f,
0.01f, 0.01f, 0.0f,
0.01f, -0.01f, 0.0f
};
glGenBuffers(1, &vertVBO);
glBindBuffer(GL_ARRAY_BUFFER, vertVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, vertVBO);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
glEnableVertexAttribArray(0);
//shaders
mCursorShader.loadShaderFiles("res/shaders/test.vert.glsl", "res/shaders/test.frag.glsl");
cursorShaders = LoadShaders("res/shaders/test.vert.glsl", "res/shaders/test.frag.glsl");
shaders = LoadShaders("res/shaders/voxelvert.vert.glsl", "res/shaders/voxelfrag.frag.glsl");
glUseProgram(shaders);
@ -91,6 +67,7 @@ void TestScene::init() { @@ -91,6 +67,7 @@ void TestScene::init() {
vg = nvgCreateGL3(NVG_ANTIALIAS | NVG_STENCIL_STROKES);
nvgCreateFont(vg, "mono", "res/fonts/DejaVuSansMono.ttf");
//sdl mouse settings
SDL_SetRelativeMouseMode(SDL_TRUE);
sensitivity = linkedGame->getConfig()->getValue<float>("controls.mouse.sensitivity", 5.0f);
@ -196,16 +173,17 @@ void TestScene::update(const float& dTime) { @@ -196,16 +173,17 @@ void TestScene::update(const float& dTime) {
void TestScene::draw() {
mSkyboxTask->draw();
//draw world TODO: move this to rendertasks
gls::setShader(shaders);
glUniformMatrix4fv(viewMatUni, 1, GL_FALSE, glm::value_ptr(camera.getViewMatrix()));
world.draw();
glDisable(GL_DEPTH_TEST);
mCursorShader.activate();
glBindVertexArray(vao);
glDrawArrays(GL_TRIANGLES, 0, 6);
nvgBeginFrame(vg, 1920, 1080, 1);
int nvgWidth = 1920;
int nvgHeight = 1080;
nvgBeginFrame(vg, nvgWidth, nvgHeight, 1);
nvgFontSize(vg, 14.0f);
nvgFontFace(vg, "mono");
@ -214,6 +192,11 @@ void TestScene::draw() { @@ -214,6 +192,11 @@ void TestScene::draw() {
std::string fpsString = std::to_string(mFPS);
nvgText(vg, 5, 19, fpsString.data(), NULL);
nvgBeginPath(vg);
nvgRect(vg, ((float)nvgWidth / 2.0f) - 15.0f, ((float)nvgHeight / 2.0f) - 15.0f, 30.0f, 30.0f);
nvgFillColor(vg, nvgRGBA(153, 0, 204, 80));
nvgFill(vg);
nvgEndFrame(vg);
glFrontFace(GL_CW);
glEnable(GL_CULL_FACE);

4
src/scenes/testscene.h

@ -45,12 +45,8 @@ public: @@ -45,12 +45,8 @@ public:
void look(); //look with camera
protected:
unsigned vertVBO;
unsigned texVBO;
unsigned vao;
unsigned shaders;
unsigned cursorShaders;
Shader mCursorShader;
float dTime;
float mFPS;
Camera camera;

Loading…
Cancel
Save