Comments (6)
Hi, thanks for the detailed report!
Hmm. Actually I think I know what's happening here -- Framebuffer::clearColor()
is not equivalent to glClearColor()
but rather glClearBuffer(), a slightly different (and newer) API. So then, what the code in the first listing is doing is basically this:
- calling the
clearColor()
clears the framebuffer with a red color (instead of setting the clear color to red, as you assumed) - then, calling the
clear()
clears the framebuffer again, but with the globally set clear color (so it basically clears back to black and so it looks like nothing was changed)
Setting the clear color (without clearing anything) is done using GL::Renderer::setClearColor() instead, so to fix the above either:
- remove the second
clear()
, and call justclearColor()
, or - call
GL::Renderer::setClearColor(Color4::red())
instead ofqtDefaultFramebuffer.clearColor()
What might be helpful for you -- the documentation has a table mapping from GL APIs to Magnum APIs, so if you know what you want to do in raw GL, you can use the table to see the equivalent Magnum APIs. It's also possible to use the search to search for e.g. glClearColor and it'll show what function it corresponds to. Every function documentation also lists GL APIs used underneath.
Hope this helps! :)
Originally I thought you're hitting a driver bug because very recently I was pushing some workarounds for Intel drivers on Windows where using clearColor()
didn't do anything but clear()
did. But since you're using master
, you should be using the workaround already (if on an Intel GPU) and it should be listed in the engine startup log.
from magnum-bootstrap.
Thanks a lot for the fast and detailed explanation. I was confused because I misinterpreted the documentation of GL::Renderer::setClearColor but now it is "clear" to me.
Now, I just tried both approaches:
void MyApplication::initializeGL() {
_context.create();
GL::Renderer::setClearColor(Color4::red());
/* TODO: Add your initialization code here */
}
void MyApplication::paintGL() {
/* Reset state to avoid Qt affecting Magnum */
GL::Context::current().resetState(GL::Context::State::ExitExternal);
/* Using framebuffer provided by Qt as default framebuffer */
auto qtDefaultFramebuffer = GL::Framebuffer::wrap(defaultFramebufferObject(), {{}, {width(), height()}});
qtDefaultFramebuffer.clear(GL::FramebufferClear::Color);
/* TODO: Add your drawing code here */
/* Clean up Magnum state and back to Qt */
GL::Context::current().resetState(GL::Context::State::EnterExternal);
}
This one worked as spected cleaning the buffer with red color.
void MyApplication::initializeGL() {
_context.create();
/* TODO: Add your initialization code here */
}
void MyApplication::paintGL() {
/* Reset state to avoid Qt affecting Magnum */
GL::Context::current().resetState(GL::Context::State::ExitExternal);
/* Using framebuffer provided by Qt as default framebuffer */
auto qtDefaultFramebuffer = GL::Framebuffer::wrap(defaultFramebufferObject(), {{}, {width(), height()}});
qtDefaultFramebuffer.clearColor(GL_COLOR_ATTACHMENT0, Color4::green());
/* TODO: Add your drawing code here */
/* Clean up Magnum state and back to Qt */
GL::Context::current().resetState(GL::Context::State::EnterExternal);
}
Unfortunately this one didn't work, leaving the frame buffer with a gray-black color instead of green. Is GL_COLOR_ATTACHMENT0 the right attachment to clear?
This is the startup info:
Renderer: GeForce GTX 1050/PCIe/SSE2 by NVIDIA Corporation
OpenGL version: 4.6.0 NVIDIA 399.07
Using optional features:
GL_ARB_ES2_compatibility
GL_ARB_ES3_1_compatibility
GL_ARB_direct_state_access
GL_ARB_get_texture_sub_image
GL_ARB_invalidate_subdata
GL_ARB_multi_bind
GL_ARB_robustness
GL_ARB_separate_shader_objects
GL_ARB_texture_filter_anisotropic
GL_ARB_texture_storage
GL_ARB_texture_storage_multisample
GL_ARB_vertex_array_object
GL_KHR_debug
Using driver workarounds:
no-layout-qualifiers-on-old-glsl
nv-zero-context-profile-mask
nv-implementation-color-read-format-dsa-broken
nv-windows-dangling-transform-feedback-varying-names
nv-cubemap-inconsistent-compressed-image-size
nv-cubemap-broken-full-compressed-image-query
nv-compressed-block-size-in-bits
from magnum-bootstrap.
Haha, right, the GL_COLOR_ATTACHMENT0
looked suspicious to me. Now I know why :) The index passed to clearColor()
is interpreted as GL_COLOR_ATTACHMENT0 + index
, so in this case you're clearing atttachment number 36064 ;)
Try this instead:
qtDefaultFramebuffer.clearColor(0, Color4::green());
Also, the code you have above should throw some GL error. You can either check GL errors manually (which is tedious), or you can run the app with --magnum-gpu-validation on
passed on the command line (or, equivalently, setting the MAGNUM_GPU_VALIDATION=ON
environment variable since I'm not sure how Qt propagates the command-line arguments). With this enabled, the driver should print a detailed info about every GL error that happens, NVidia drivers are exceptionally good at showing what's wrong. A bit of caution though -- it might happen that Qt itself would be spamming the output with its own GL errors in which case it would be hard to know what's your error and what Qt's. I'm being optimistic and trust Qt to not cause any GL error, but I never verified that myself so I can't be sure :)
In general, none of the Magnum APIs expect raw GL enums, it's always either a numeric value or a C++11 scoped enum wrapping the raw GL values in a more typesafe way.
from magnum-bootstrap.
Alright that was it :). I added the command in the build configuration and the console was displaying some clear errors.
Thanks for the tips, I'll take them in consideration.
from magnum-bootstrap.
Great :)
Anything else or can this be closed as resolved? :) For general questions you can join the Gitter channel (simply log in with your GitHub account), usually there's always someone around who's happy to help.
from magnum-bootstrap.
Yes, that's all.
from magnum-bootstrap.
Related Issues (20)
- Linker Error (SDL2) HOT 1
- Not installing `.wasm` HOT 1
- Build Output Directories HOT 3
- Building woes HOT 23
- vcpkg doesn't play well with FindXYZ modules HOT 4
- Unable to build on VS2019 HOT 4
- Help understanding bootstrap emscripten js error HOT 6
- Android Gradle build HOT 7
- base-Qt reports wrong OpenGL Version HOT 9
- ANDROID_SDK variable has wrong path on Windows. HOT 2
- GL::Context: unsupported OpenGL version (0, 0) output while building base-wxwidgets HOT 12
- magnum + wxWidgets sample projects, mouse drag can rotate the camera, but not as expected HOT 1
- Building Issue - The fully qualified file name must be less than 260 characters HOT 1
- Add bootstrap example using FLTK HOT 2
- Linking issue with scenegraph3D bootstrap project HOT 1
- Separate declarations from implementations HOT 1
- Cross platform bootstrap? HOT 18
- Getting started tutorial issue - can't find SDL2 HOT 3
- Segment fault using Getting Started Guide on Ubuntu 16.06 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magnum-bootstrap.