mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-10 18:47:23 +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
|
@ -1104,24 +1104,18 @@ void Application::paintGL() {
|
||||||
auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
|
auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
|
||||||
GLuint finalTexture = gpu::GLBackend::getTextureID(primaryFbo->getRenderBuffer(0));
|
GLuint finalTexture = gpu::GLBackend::getTextureID(primaryFbo->getRenderBuffer(0));
|
||||||
uvec2 finalSize = toGlm(size);
|
uvec2 finalSize = toGlm(size);
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
glFinish();
|
|
||||||
#else
|
|
||||||
// Ensure the rendering context commands are completed when rendering
|
// Ensure the rendering context commands are completed when rendering
|
||||||
GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
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();
|
_offscreenContext->doneCurrent();
|
||||||
|
|
||||||
// Switches to the display plugin context
|
// Switches to the display plugin context
|
||||||
displayPlugin->preDisplay();
|
displayPlugin->preDisplay();
|
||||||
|
|
||||||
// Ensure all operations from the previous context are complete before we try to read the fbo
|
// 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);
|
glWaitSync(sync, 0, GL_TIMEOUT_IGNORED);
|
||||||
glDeleteSync(sync);
|
glDeleteSync(sync);
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
{
|
||||||
PROFILE_RANGE(__FUNCTION__ "/pluginDisplay");
|
PROFILE_RANGE(__FUNCTION__ "/pluginDisplay");
|
||||||
|
|
|
@ -36,36 +36,16 @@ void OpenGLDisplayPlugin::finishFrame() {
|
||||||
doneCurrent();
|
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) {
|
void OpenGLDisplayPlugin::customizeContext(PluginContainer * container) {
|
||||||
using namespace oglplus;
|
using namespace oglplus;
|
||||||
Context::BlendFunc(BlendFunction::SrcAlpha, BlendFunction::OneMinusSrcAlpha);
|
Context::BlendFunc(BlendFunction::SrcAlpha, BlendFunction::OneMinusSrcAlpha);
|
||||||
Context::Disable(Capability::Blend);
|
Context::Disable(Capability::Blend);
|
||||||
Context::Disable(Capability::DepthTest);
|
Context::Disable(Capability::DepthTest);
|
||||||
Context::Disable(Capability::CullFace);
|
Context::Disable(Capability::CullFace);
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
|
|
||||||
_program = loadDefaultShader();
|
_program = loadDefaultShader();
|
||||||
auto attribs = _program->ActiveAttribs();
|
_plane = loadPlane(_program);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::activate(PluginContainer * container) {
|
void OpenGLDisplayPlugin::activate(PluginContainer * container) {
|
||||||
|
@ -77,8 +57,8 @@ void OpenGLDisplayPlugin::deactivate(PluginContainer* container) {
|
||||||
|
|
||||||
makeCurrent();
|
makeCurrent();
|
||||||
Q_ASSERT(0 == glGetError());
|
Q_ASSERT(0 == glGetError());
|
||||||
_vertexBuffer.reset();
|
|
||||||
_program.reset();
|
_program.reset();
|
||||||
|
_plane.reset();
|
||||||
doneCurrent();
|
doneCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,16 +112,6 @@ void OpenGLDisplayPlugin::display(
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLDisplayPlugin::drawUnitQuad() {
|
void OpenGLDisplayPlugin::drawUnitQuad() {
|
||||||
using namespace oglplus;
|
|
||||||
_program->Bind();
|
_program->Bind();
|
||||||
_vertexBuffer->Bind(Buffer::Target::Array);
|
_plane->Draw();
|
||||||
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);
|
|
||||||
}
|
}
|
|
@ -39,9 +39,7 @@ protected:
|
||||||
|
|
||||||
QTimer _timer;
|
QTimer _timer;
|
||||||
ProgramPtr _program;
|
ProgramPtr _program;
|
||||||
BufferPtr _vertexBuffer;
|
ShapeWrapperPtr _plane;
|
||||||
GLint _positionAttribute{0};
|
|
||||||
GLint _texCoordAttribute{0};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,13 @@
|
||||||
using namespace oglplus;
|
using namespace oglplus;
|
||||||
using namespace oglplus::shapes;
|
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__
|
#pragma line __LINE__
|
||||||
|
|
||||||
attribute vec3 Position;
|
in vec3 Position;
|
||||||
attribute vec2 TexCoord;
|
in vec2 TexCoord;
|
||||||
|
|
||||||
varying vec2 vTexCoord;
|
out vec2 vTexCoord;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = vec4(Position, 1);
|
gl_Position = vec4(Position, 1);
|
||||||
|
@ -26,16 +26,17 @@ void main() {
|
||||||
|
|
||||||
)VS";
|
)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__
|
#pragma line __LINE__
|
||||||
|
|
||||||
uniform sampler2D sampler;
|
uniform sampler2D sampler;
|
||||||
|
|
||||||
varying vec2 vTexCoord;
|
in vec2 vTexCoord;
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
gl_FragColor = texture2D(sampler, vTexCoord);
|
FragColor = texture(sampler, vTexCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
)FS";
|
)FS";
|
||||||
|
|
Loading…
Reference in a new issue