TESTIMAGE: new visual testcase

master
Martin Gerhardy 2016-06-30 20:13:38 +02:00
parent b9ca6698a3
commit 5e5e9cc675
14 changed files with 101 additions and 32 deletions

View File

@ -76,7 +76,7 @@ clean-local-config:
edit-local-config:
$(Q)$(EDITOR) $(LOCAL_CONFIG_DIR)/shapetool/shapetool.vars
server client shapetool shadertool noisetool tests testmesh testdepthbuffer: cmake
server client shapetool shadertool noisetool tests testmesh testdepthbuffer testtexture: cmake
$(Q)cd $(BUILDDIR); make $@ copy-data-shared copy-data-$@ $(JOB_FLAG)
$(Q)cd $(BUILDDIR); $(GDB_CMD) $(VOGL_CMD) ./$@ $(ARGS)

View File

@ -0,0 +1,8 @@
$out vec4 o_color;
$in vec2 v_texcoord;
uniform sampler2D u_texture;
void main() {
o_color = $texture2D(u_texture, v_texcoord);
}

View File

@ -0,0 +1,2 @@
#define TEXTURED
#include "_fullscreen.vert"

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -8,6 +8,7 @@
#include "video/Mesh.h"
#include "video/Camera.h"
#include "frontend/Axis.h"
#include "core/AppModule.h"
class TestApp: public video::WindowedApp {
protected:

View File

@ -1,3 +1,4 @@
add_subdirectory(testdepthbuffer)
add_subdirectory(testmesh)
add_subdirectory(testtexture)
#add_subdirectory(testtemplate)

View File

@ -1,5 +1,4 @@
#include "TestDepthBuffer.h"
#include "core/AppModule.h"
#include "video/ScopedViewPort.h"
TestDepthBuffer::TestDepthBuffer(io::FilesystemPtr filesystem, core::EventBusPtr eventBus) :

View File

@ -1,5 +1,4 @@
#include "TestMesh.h"
#include "core/AppModule.h"
TestMesh::TestMesh(io::FilesystemPtr filesystem, core::EventBusPtr eventBus) :
Super(filesystem, eventBus) {

View File

@ -3,5 +3,5 @@ set(SRCS
TestTemplate.h TestTemplate.cpp
)
engine_add_executable(TARGET ${PROJECT_NAME} SRCS ${SRCS} WINDOWED)
target_link_libraries(${PROJECT_NAME} frontend util)
target_link_libraries(${PROJECT_NAME} testcore)
#generate_shaders(${PROJECT_NAME} color)

View File

@ -1,29 +1,10 @@
#include "TestTemplate.h"
#include "core/AppModule.h"
#include "video/GLFunc.h"
#include "core/Color.h"
TestTemplate::TestTemplate(io::FilesystemPtr filesystem, core::EventBusPtr eventBus) :
Super(filesystem, eventBus, 21000) {
init("engine", "testtemplate");
Super(filesystem, eventBus) {
}
TestTemplate::~TestTemplate() {
}
core::AppState TestTemplate::onInit() {
const core::AppState state = Super::onInit();
GLDebug::enable(GLDebug::Medium);
const glm::vec4& color = ::core::Color::Red;
glClearColor(color.r, color.g, color.b, color.a);
return state;
}
core::AppState TestTemplate::onRunning() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
return core::AppState::Cleanup;
void TestTemplate::doRender() {
}
int main(int argc, char *argv[]) {

View File

@ -4,15 +4,13 @@
#pragma once
#include "video/WindowedApp.h"
#include "testcore/TestApp.h"
class TestTemplate: public video::WindowedApp {
class TestTemplate: public TestApp {
private:
using Super = video::WindowedApp;
using Super = TestApp;
void doRender() override;
public:
TestTemplate(io::FilesystemPtr filesystem, core::EventBusPtr eventBus);
~TestTemplate();
core::AppState onInit() override;
core::AppState onRunning() override;
};

View File

@ -0,0 +1,7 @@
project(testtexture)
set(SRCS
TestTexture.h TestTexture.cpp
)
engine_add_executable(TARGET ${PROJECT_NAME} SRCS ${SRCS} WINDOWED)
target_link_libraries(${PROJECT_NAME} testcore)
generate_shaders(${PROJECT_NAME} color texture)

View File

@ -0,0 +1,48 @@
#include "TestTexture.h"
TestTexture::TestTexture(io::FilesystemPtr filesystem, core::EventBusPtr eventBus) :
Super(filesystem, eventBus) {
}
core::AppState TestTexture::onInit() {
_camera.setOrtho(true);
const core::AppState state = Super::onInit();
if (!_textureShader.setup()) {
Log::error("Failed to init the texture shader");
return core::AppState::Cleanup;
}
_texture = video::createTexture("texture.png");
if (!_texture) {
Log::error("Failed to load texture");
return core::AppState::Cleanup;
}
const glm::ivec2& fullscreenQuadIndices = _texturedFullscreenQuad.createFullscreenTexturedQuad();
_texturedFullscreenQuad.addAttribute(_textureShader.getLocationPos(), fullscreenQuadIndices.x, 3);
_texturedFullscreenQuad.addAttribute(_textureShader.getLocationTexcoord(), fullscreenQuadIndices.y, 2);
return state;
}
void TestTexture::doRender() {
video::ScopedShader scoped(_textureShader);
_textureShader.setTexture(0);
_texture->bind();
core_assert_always(_texturedFullscreenQuad.bind());
glDrawArrays(GL_TRIANGLES, 0, _texturedFullscreenQuad.elements(0));
_texturedFullscreenQuad.unbind();
_texture->unbind();
}
core::AppState TestTexture::onCleanup() {
_textureShader.shutdown();
_texture->shutdown();
_texturedFullscreenQuad.shutdown();
return Super::onCleanup();
}
int main(int argc, char *argv[]) {
return core::getApp<TestTexture>()->startMainLoop(argc, argv);
}

View File

@ -0,0 +1,25 @@
/**
* @file
*/
#pragma once
#include "testcore/TestApp.h"
#include "video/Texture.h"
#include "TesttextureShaders.h"
#include "video/VertexBuffer.h"
class TestTexture: public TestApp {
private:
using Super = TestApp;
video::TexturePtr _texture;
shader::TextureShader _textureShader;
video::VertexBuffer _texturedFullscreenQuad;
void doRender() override;
public:
TestTexture(io::FilesystemPtr filesystem, core::EventBusPtr eventBus);
core::AppState onInit() override;
core::AppState onCleanup() override;
};