mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 00:13:33 +02:00
Updating plugins to core profile
This commit is contained in:
parent
0edd7fd3c4
commit
29c9e6e45e
4 changed files with 18 additions and 55 deletions
interface/src
libraries
display-plugins/src/display-plugins
render-utils/src
|
@ -1104,25 +1104,19 @@ void Application::paintGL() {
|
|||
auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
|
||||
GLuint finalTexture = gpu::GLBackend::getTextureID(primaryFbo->getRenderBuffer(0));
|
||||
uvec2 finalSize = toGlm(size);
|
||||
#ifdef Q_OS_MAC
|
||||
glFinish();
|
||||
#else
|
||||
// Ensure the rendering context commands are completed when rendering
|
||||
GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
#endif
|
||||
// Ensure the sync object is flushed to the driver thread before releasing the context
|
||||
// CRITICAL for the mac driver apparently.
|
||||
glFlush();
|
||||
_offscreenContext->doneCurrent();
|
||||
|
||||
// Switches to the display plugin context
|
||||
displayPlugin->preDisplay();
|
||||
|
||||
// Ensure all operations from the previous context are complete before we try to read the fbo
|
||||
#ifdef Q_OS_MAC
|
||||
// FIXME once we move to core profile, use fencesync on both platforms
|
||||
#else
|
||||
// FIXME? make the sync a parameter to preDisplay and let the plugin manage this
|
||||
glWaitSync(sync, 0, GL_TIMEOUT_IGNORED);
|
||||
glDeleteSync(sync);
|
||||
#endif
|
||||
|
||||
|
||||
{
|
||||
PROFILE_RANGE(__FUNCTION__ "/pluginDisplay");
|
||||
displayPlugin->display(finalTexture, finalSize);
|
||||
|
|
|
@ -36,36 +36,16 @@ void OpenGLDisplayPlugin::finishFrame() {
|
|||
doneCurrent();
|
||||
};
|
||||
|
||||
static float PLANE_VERTICES[] = {
|
||||
-1, -1, 0, 0,
|
||||
-1, +1, 0, 1,
|
||||
+1, -1, 1, 0,
|
||||
+1, +1, 1, 1,
|
||||
};
|
||||
|
||||
void OpenGLDisplayPlugin::customizeContext(PluginContainer * container) {
|
||||
using namespace oglplus;
|
||||
Context::BlendFunc(BlendFunction::SrcAlpha, BlendFunction::OneMinusSrcAlpha);
|
||||
Context::Disable(Capability::Blend);
|
||||
Context::Disable(Capability::DepthTest);
|
||||
Context::Disable(Capability::CullFace);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
_program = loadDefaultShader();
|
||||
auto attribs = _program->ActiveAttribs();
|
||||
for(size_t i = 0; i < attribs.Size(); ++i) {
|
||||
auto attrib = attribs.At(i);
|
||||
if (String("Position") == attrib.Name()) {
|
||||
_positionAttribute = attrib.Index();
|
||||
} else if (String("TexCoord") == attrib.Name()) {
|
||||
_texCoordAttribute = attrib.Index();
|
||||
}
|
||||
qDebug() << attrib.Name().c_str();
|
||||
}
|
||||
_vertexBuffer.reset(new oglplus::Buffer());
|
||||
_vertexBuffer->Bind(Buffer::Target::Array);
|
||||
_vertexBuffer->Data(Buffer::Target::Array, BufferData(PLANE_VERTICES));
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
_plane = loadPlane(_program);
|
||||
}
|
||||
|
||||
void OpenGLDisplayPlugin::activate(PluginContainer * container) {
|
||||
|
@ -77,8 +57,8 @@ void OpenGLDisplayPlugin::deactivate(PluginContainer* container) {
|
|||
|
||||
makeCurrent();
|
||||
Q_ASSERT(0 == glGetError());
|
||||
_vertexBuffer.reset();
|
||||
_program.reset();
|
||||
_plane.reset();
|
||||
doneCurrent();
|
||||
}
|
||||
|
||||
|
@ -132,16 +112,6 @@ void OpenGLDisplayPlugin::display(
|
|||
}
|
||||
|
||||
void OpenGLDisplayPlugin::drawUnitQuad() {
|
||||
using namespace oglplus;
|
||||
_program->Bind();
|
||||
_vertexBuffer->Bind(Buffer::Target::Array);
|
||||
glEnableVertexAttribArray(_positionAttribute);
|
||||
glVertexAttribPointer(_positionAttribute, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, 0);
|
||||
glEnableVertexAttribArray(_texCoordAttribute);
|
||||
glVertexAttribPointer(_texCoordAttribute, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 4, (void*)(sizeof(float) * 2));
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glDisableVertexAttribArray(_positionAttribute);
|
||||
glDisableVertexAttribArray(_texCoordAttribute);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glUseProgram(0);
|
||||
_plane->Draw();
|
||||
}
|
|
@ -39,9 +39,7 @@ protected:
|
|||
|
||||
QTimer _timer;
|
||||
ProgramPtr _program;
|
||||
BufferPtr _vertexBuffer;
|
||||
GLint _positionAttribute{0};
|
||||
GLint _texCoordAttribute{0};
|
||||
ShapeWrapperPtr _plane;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@
|
|||
using namespace oglplus;
|
||||
using namespace oglplus::shapes;
|
||||
|
||||
static const char * SIMPLE_TEXTURED_VS = R"VS(#version 120
|
||||
static const char * SIMPLE_TEXTURED_VS = R"VS(#version 410 core
|
||||
#pragma line __LINE__
|
||||
|
||||
attribute vec3 Position;
|
||||
attribute vec2 TexCoord;
|
||||
in vec3 Position;
|
||||
in vec2 TexCoord;
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
out vec2 vTexCoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(Position, 1);
|
||||
|
@ -26,16 +26,17 @@ void main() {
|
|||
|
||||
)VS";
|
||||
|
||||
static const char * SIMPLE_TEXTURED_FS = R"FS(#version 120
|
||||
static const char * SIMPLE_TEXTURED_FS = R"FS(#version 410 core
|
||||
#pragma line __LINE__
|
||||
|
||||
uniform sampler2D sampler;
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
in vec2 vTexCoord;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main() {
|
||||
|
||||
gl_FragColor = texture2D(sampler, vTexCoord);
|
||||
FragColor = texture(sampler, vTexCoord);
|
||||
}
|
||||
|
||||
)FS";
|
||||
|
|
Loading…
Reference in a new issue