3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-27 11:55:25 +02:00

Working on GL 4.1 core

This commit is contained in:
Bradley Austin Davis 2015-06-20 19:31:15 -07:00 committed by Brad Davis
parent f51c43f90d
commit 0000b5a8c8
7 changed files with 64 additions and 50 deletions
libraries
tests/render-utils

View file

@ -1,5 +1,5 @@
<!
// Config.slh
// Input.slh
// interface/src
//
// Created by Bradley Austin Davis on 2015/06/19.

View file

@ -1,6 +1,6 @@
set(TARGET_NAME model)
AUTOSCRIBE_SHADER_LIB(gpu)
AUTOSCRIBE_SHADER_LIB(gpu model)
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
setup_hifi_library()

View file

@ -2,6 +2,7 @@
<$VERSION_HEADER$>
// Generated on <$_SCRIBE_DATE$>
// skybox.frag
// fragment shader
//
// Created by Sam Gateau on 5/5/2015.
// Copyright 2015 High Fidelity, Inc.
@ -12,14 +13,22 @@
uniform samplerCube cubeMap;
varying vec3 normal;
varying vec2 texcoord;
varying vec3 color;
struct Skybox {
vec4 _color;
};
uniform skyboxBuffer {
Skybox _skybox;
};
in vec3 _normal;
out vec4 _fragColor;
void main(void) {
vec3 coord = normalize(normal);
vec4 texel = textureCube(cubeMap, coord);
vec3 pixel = pow(texel.xyz * color, vec3(1.0/2.2)); // manual Gamma correction
gl_FragData[0] = vec4(pixel, 0.0);
vec3 coord = normalize(_normal);
vec3 texel = texture(cubeMap, coord).rgb;
vec3 color = texel * _skybox._color.rgb;
vec3 pixel = pow(color, vec3(1.0/2.2)); // manual Gamma correction
_fragColor = vec4(pixel, 0.0);
}

View file

@ -11,39 +11,24 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Inputs.slh@>
<@include gpu/Transform.slh@>
<$declareStandardTransform()$>
struct Skybox {
vec4 _color;
};
uniform skyboxBuffer {
Skybox _skybox;
};
Skybox getSkybox() {
return _skybox;
}
varying vec3 normal;
varying vec2 texcoord;
varying vec3 color;
void main(void) {
texcoord = inPosition.xy;
Skybox skybox = getSkybox();
color = skybox._color.xyz;
out vec3 _normal;
void main(void) {
// standard transform
TransformCamera cam = getTransformCamera();
vec3 clipDir = vec3(texcoord.xy, 0.0);
vec3 clipDir = vec3(inPosition.xy, 0.0);
vec3 eyeDir;
<$transformClipToEyeDir(cam, clipDir, eyeDir)$>;
<$transformEyeToWorldDir(cam, eyeDir, normal)$>;
// Position is supposed to cmoe in clip space
gl_Position = vec4(texcoord.xy, 0.0, 1.0);
}
<$transformClipToEyeDir(cam, clipDir, eyeDir)$>
<$transformEyeToWorldDir(cam, eyeDir, _normal)$>
// Position is supposed to come in clip space
gl_Position = vec4(inPosition.xy, 0.0, 1.0);
}

View file

@ -12,12 +12,13 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
<@include gpu/Input.slh@>
<@include gpu/Inputs.slh@>
out vec4 texCoord0;
void main(void) {
gl_Position = ftransform();
vec4 projected = gl_Position / gl_Position.w;
gl_TexCoord[0] = vec4(dot(projected, gl_ObjectPlaneS[3]) * gl_Position.w,
texCoord0 = vec4(dot(projected, gl_ObjectPlaneS[3]) * gl_Position.w,
dot(projected, gl_ObjectPlaneT[3]) * gl_Position.w, 0.0, gl_Position.w);
}

View file

@ -7,4 +7,6 @@ setup_hifi_project(Quick Gui OpenGL)
# link in the shared libraries
link_hifi_libraries(render-utils gpu shared)
copy_dlls_beside_windows_executable()
include_directories("${PROJECT_BINARY_DIR}")
message(${PROJECT_BINARY_DIR})
copy_dlls_beside_windows_executable()

View file

@ -15,6 +15,8 @@
#pragma GCC diagnostic ignored "-Wdouble-promotion"
#endif
#include <mutex>
#include <QWindow>
#include <QFile>
#include <QTime>
@ -41,6 +43,14 @@
#include <PathUtils.h>
#include <QDir>
#include "gpu/Batch.h"
#include "gpu/Context.h"
#include "../../libraries/model/Skybox_vert.h"
#include "../../libraries/model/Skybox_frag.h"
class RateCounter {
std::vector<float> times;
QElapsedTimer timer;
@ -114,8 +124,8 @@ public:
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
format.setDepthBufferSize(16);
format.setStencilBufferSize(8);
format.setVersion(4, 5);
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
format.setVersion(4, 1);
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
format.setOption(QSurfaceFormat::DebugContext);
setFormat(format);
@ -134,7 +144,7 @@ public:
connect(logger, &QOpenGLDebugLogger::messageLogged, this, [&](const QOpenGLDebugMessage & debugMessage) {
qDebug() << debugMessage;
});
// logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
logger->startLogging(QOpenGLDebugLogger::SynchronousLogging);
}
qDebug() << (const char*)glGetString(GL_VERSION);
@ -155,12 +165,12 @@ public:
glGetError();
#endif
_textRenderer[0] = TextRenderer::getInstance(SANS_FONT_FAMILY, 12, false);
_textRenderer[1] = TextRenderer::getInstance(SERIF_FONT_FAMILY, 12, false,
TextRenderer::SHADOW_EFFECT);
_textRenderer[2] = TextRenderer::getInstance(MONO_FONT_FAMILY, 48, -1,
false, TextRenderer::OUTLINE_EFFECT);
_textRenderer[3] = TextRenderer::getInstance(INCONSOLATA_FONT_FAMILY, 24);
// _textRenderer[0] = TextRenderer::getInstance(SANS_FONT_FAMILY, 12, false);
// _textRenderer[1] = TextRenderer::getInstance(SERIF_FONT_FAMILY, 12, false,
// TextRenderer::SHADOW_EFFECT);
// _textRenderer[2] = TextRenderer::getInstance(MONO_FONT_FAMILY, 48, -1,
// false, TextRenderer::OUTLINE_EFFECT);
// _textRenderer[3] = TextRenderer::getInstance(INCONSOLATA_FONT_FAMILY, 24);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -169,7 +179,7 @@ public:
makeCurrent();
setFramePosition(QPoint(-1000, 0));
// setFramePosition(QPoint(-1000, 0));
resize(QSize(800, 600));
}
@ -251,7 +261,14 @@ void QTestWindow::draw() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0, 0, _size.width() * devicePixelRatio(), _size.height() * devicePixelRatio());
renderText();
static std::once_flag once;
std::call_once(once, [&]{
auto skyVS = gpu::ShaderPointer(gpu::Shader::createVertex(std::string(Skybox_vert)));
auto skyFS = gpu::ShaderPointer(gpu::Shader::createPixel(std::string(Skybox_frag)));
auto skyShader = gpu::ShaderPointer(gpu::Shader::createProgram(skyVS, skyFS));
gpu::Shader::makeProgram(*skyShader);
});
// renderText();
_context->swapBuffers(this);
glFinish();