void display() {
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//gluOrtho2D(0, 800, 0, 800);
glLineWidth(10.0f);glBegin(GL_LINES);
glColor3f(1.0, 0.0, 0.0);
glVertex2f(-1.0f, -1.0f);
glVertex2f(1.0f, 1.0f);glColor3f(0.0, 1.0, 0.0);
glVertex2f(-1.0f, 1.0f);
glVertex2f(1.0f, -1.0f);
glEnd();
gluOrtho2D(0, 800, 0, 800);
glBegin(GL_LINES);
glColor3f(1.0, 1.0, 0.0);
glVertex2i(400, 800);
glVertex2i(400, 0);
glEnd();
glFlush();
glutSwapBuffers();}
void main(int argc, char** argv) {
glutInit(&argc, argv);
// glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(800, 800);
glutInitWindowPosition(100, 100);
glutCreateWindow("Points");
//glutDisplayFunc(display);glutDisplayFunc(display);
glutMainLoop();
}#endif
//https://elixir.bootlin.com/linux/v5.6/source
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
After initialization, the entire coordinate plane will be initialized to [-1.0, 1.0] [-1.0, 1.0]
and
gluOrtho2D(0, 800, 0, 800)
Will initialize the range of the coordinate plane to [0, 800] [0, 800]
The results are shown in the figure.
When using non-fixed pipelines for texture rendering, the mapping relationship between texture and vertex coordinates is often used. Here, the two-dimensional texture coordinate mapping is introduced ...
As shown in the figure: The original image is based on 2x2 pixels, and the pixel value of each group is representing the value of the upper left corner (that is,0~8), Find the average filtering of the...
Screen coordinates transform into world coordinates method one Method Two...
OpenGL is a coordinate system that transforms coordinates to a screen center as a coordinate system with a screen center. The X, Y axis of the screen display area is [-1, 1]. Figure: The coordinate sy...
Learned in the OpenGL Programming Guide,Strong push: detailed explanation of caster99 blogger、The homogeneous coordinate understanding of jeffasd god、Homogeneous coordinates Baidu Encyclopedia OpenGL ...
The screenshot of the program is as follows: It looks cool: it's actually a cool picture The program source code is as follows: The LoadFileContext function is as follows: The Dec...
Ellipse Reference book: Computer Graphics Fourth Edition Electronic Industry Press...