OpenGL implements three light sources

The previous article implemented a simple lighting model, and the lighting used came from a point in space. But in the real world, we have many types of lighting, such as: 1. Directional Light 2.Point Light 3. Spotlight The purpose of this article is to implement these light sources respectively. 1. Directional light (also called […]

OpenGL custom shader

The purpose of this article is how to use OpenGL to customize Shader. First make sure you can draw forms and triangles: portal Previously, Shader was written directly in the code, which was very inconvenient to use. The general method for projects is to customize the shader file and then read the text content How […]

OpenGL space coordinate transformation

First, you need to understand matrices. Matrices are often used for coordinate transformation in programs. Common matrices are: 1. Scaling matrix 2. Displacement matrix More one-dimensional coordinates: Homogeneous Coordinates use: 1. Allows us to displace on a 3D vector (we cannot displace the vector without the w component) 2. Divide the x, y and z […]

OpenGL_Learn07 (Transform)

1. Vector Vectors have a direction and a magnitude. If a vector has 2 dimensions, it represents the direction of a plane (imagine a 2D image), and when it has 3 dimensions, it can represent the direction of a 3D world. You can think of these 2D vectors as 3D vectors with z coordinate 0. […]

Qt opengl draws points, lines, triangles, polygons (2)

Article directory 1. Related macro definition parameters 2. Code and example diagrams 1. Point LG_POINTS 0x0000 2. Line GL_LINES 0x0001 3. Line GL_LINE_LOOP 0x0002 4. GL_LINE_STRIP 0x0003 5. GL_TRIANGLES 0x0004 6. GL_TRIANGLE_STRIP 0x0005 7. GL_TRIANGLE_FAN 0x0006 8. GL_QUADS 0x0007 9. GL_QUAD_STRIP 0x0008 10. GL_POLYGON 0x0009 Summarize 1. Related macro definition parameters #define GL_POINTS 0x0000 // […]

OpenGL_Learn05 (texture)

1. Texture map wall.jpg (512×512) (learnopengl-cn.github.io) Texture filtering is divided into: proximity and linear, which is the same as opencv image processing. Multi-level gradient texture Four sampling methods: Code: std_image.h https://github.com/nothings/stb/blob/master/stb_image.h picture https://learnopengl-cn.github.io/img/01/06/container.jpg main.cpp If the load image reports an error, remember to add the macro: STB_IMAGE_IMPLEMENTATION #include <glad/glad.h> #include <GLFW/glfw3.h> #include <iostream> #include “stb_image.h” […]

OpenGL_Learn06 (Texture)

Following the previous OpenGL_Learn05 (Texture)-CSDN Blog 1. Modify fragment shader Modify the fragment shader to only make the smiley face look the other way == ======>>>>> The Y-axis of the texture coordinates has not been changed. What needs to be changed is the texture coordinates of the X-axis. The code snippet is rewritten as follows […]

Simple drawing tool based on C++(MSVC) and OpenGL

simple-openl-graphic-tool Source code can be downloaded from this project repository: github gitee ?Simple drawing tool based on C++ (MSVC) and OpenGL? Dynamically draw graphics through rubber band technology; Liang-Barsky algorithm batches clipping of straight lines and polylines; Bresenham algorithm draws ellipses at the midpoint of ellipses. Contains executable files, environment configuration guide. Personal website: www.bytesc.top […]

QT OpenGL (1) 2D Painting Example

2D Painting Example For the convenience of reference, this article is translated and organized from the original website documents. If there is any infringement, please contact me. Official website Directory 2D Painting Example Overview Helper class definition Helper class implementation Widget class definition Widget class implementation GLWidget class definition GLWidget class implementation Window class definition […]

Watch me speed pass opengl freeglut for water homework!

Reference Video Basics of Computer Graphics – Implementation of OpenGL_bilibili_bilibiliT Graphics drawing Point GL_POINTS #define FREEGLUT_STATIC // Define a static library for calling functions #include <GL/freeglut.h> // Include the header file void myPoints() { //show three points in screen glClear(GL_COLOR_BUFFER_BIT); glPointSize(3); glBegin(GL_POINTS); //show what to draw,here we draw points glColor3f(1.0, 0.0, 0.0); //color:red glVertex2i(-3, 3);//coordinate […]