Opengl_ Chess board

Source: Internet
Author: User

#include "stdafx.h"

#include <gl/glut.h>

void Myinit (void)

{

Glclearcolor (0.2, 0.2, 0.2, 0.0); Set the background color to white;

glcolor3f (0.0f, 0.0f, 0.0f); Set the drawing color to black;

Glpointsize (1.0); Set the point size;

Gllinewidth (1.0); Set the line width;

Glmatrixmode (gl_projection); Select the appropriate matrix;

Glloadidentity ();

gluortho2d (0.0, 500.0, 0.0, 500.0); Set the window size;

}

void Drawchessboard (void)

{

Glclear (Gl_color_buffer_bit); Clear screen;

glcolor3f (0.6, 0.6, 0.6);

Glrecti (0.0,0.0,100.0,100.0);

Glrecti (0.0, 200.0, 100.0, 300.0);

Glrecti (0.0, 400.0, 100.0, 500.0);

Glrecti (100.0, 100.0, 200.0, 200.0);

Glrecti (100.0, 300.0, 200.0, 400.0);

Glrecti (200.0, 0.0, 300.0, 100.0);

Glrecti (200.0, 200.0, 300.0, 300.0);

Glrecti (200.0, 400.0, 300.0, 500.0);

Glrecti (300.0, 100.0, 400.0, 200.0);

Glrecti (300.0, 300.0, 400.0, 400.0);

GLRECTI (400, 0, 500, 100);

Glrecti (400, 200, 500, 300);

GLRECTI (400, 400, 500, 500);

Glflush ();

}

int main (int argc,char* argv[])

{

Glutinit (&ARGC, argv); Initialize the toolkit;

Glutinitdisplaymode (Glut_single |     GLUT_RGB); Set the display mode;

Glutinitwindowposition (100, 100); Sets the position of the window on the screen;

Glutinitwindowsize (500, 500); Set the window size;

Glutcreatewindow ("chessboard"); Open the screen window;

Glutdisplayfunc (Drawchessboard); Register redraw function;

Myinit ();

Glutmainloop (); Enter the permanent cycle;

}

Opengl_ Chess board

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.