Loading...
Searching...
No Matches
OpenGL Rendering

Prev Tutorial: Render vector graphics and manipulate the framebuffer
Next Tutorial: Font rendering

Original author Amir Hassan (kallaballa) amir@.nosp@m.viel.nosp@m.-zu.o.nosp@m.rg
Compatibility OpenCV >= 4.7

Render a blue screen using OpenGL

This example simply paints the screen blue using OpenGL without shaders for brevity. One important detail of this example is that states are being preserved between invocations of a context type (in this case the gl context).

Render OpenGL Blue Screen
Downloading...
using namespace cv;
using namespace cv::v4d;
class RenderOpenGLPlan : public Plan {
public:
void setup(Ptr<V4D> win) override {
win->gl([]() {
//Sets the clear color to blue
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
});
}
void infer(Ptr<V4D> win) override {
win->gl([]() {
//Clears the screen. The clear color and other GL-states are preserved between context-calls.
glClear(GL_COLOR_BUFFER_BIT);
});
}
};
int main() {
Ptr<V4D> window = V4D::make(960, 960, "GL Blue Screen");
window->run<RenderOpenGLPlan>(0);
}
Definition: v4d.hpp:68
std::shared_ptr< _Tp > Ptr
Definition: cvstd_wrapper.hpp:23
Definition: backend.hpp:15
"black box" representation of the file storage associated with a file on disk.
Definition: core.hpp:106