Details about the implementation code of various graph functions in OpenGL:

Source: Internet
Author: User

In the previous blog, I posted some differences between drawing graphical functions in OpenGL and showed different functions in the same group of data. The blog address is http://www.5dkx.com/arch/138.html.

In this article, we provide the specific OpenGL program code for implementing the previous blog.

Below is the program list

// Triangle. cpp: defines the entry point of the console application.
//
/*
File: huizhi. cpp
Done: use OpenGL to draw ry
Author: www.5dkx.com
Date: 2010-3-18
*/
# Include "windows. H"
# Include "Gl/Gl. H"
# Include "Gl/Glaux. H"
# Include "Gl/Glu. H"

# Pragma comment (Lib, "opengl32.lib ")
# Pragma comment (Lib, "Glaux. lib ")
# Pragma comment (Lib, "glu32.lib ");

Void myinit ();
Void callback myreshape (glsizei W, glsizei H );
Void mydraw ();
Void callback mydisplay ();
Int main ()
{

Myinit ();
Auxreshapefunc (myreshape );
Auxmainloop (mydisplay );
Return 0;
}

 

Void myinit ()
{
Auxinitdisplaymode (aux_single | aux_rgba );
Auxinitposition (100,100,500,500 );
Auxinit0000wa ("test ");
Glclearcolor (0., 0.0, 0.0, 0.0 );
Glclear (gl_color_buffer_bit );
}
Void callback myreshape (glsizei W, glsizei H)
{
Glviewport (0, 0, W, H );
Glmatrixmode (gl_projection );
Glloadidentity ();
GlMatrixMode (GL_MODELVIEW );
}
Void CALLBACK MyDisplay ()
{
GlClearColor (0, 0.0, 0.0, 0.0 );
GlClear (GL_COLOR_BUFFER_BIT );
MyDraw ();
GlFlush ();
}

Void MyDraw ()
{
GLfloat Vertex [] [2] ={{-0.0, 0.8 },{ 0.5, 0.8 },{ 0.75, 0.0 },{ 0.5,-0.5 }};
GlBegin (GL_TRIANGLE_STRIP); // you can use OpenGL to plot geometric functions.
GlVertex2f (-0.5, 0.0 );
GlVertex2f (-0.4, 0.5 );
For (int I = 0; I <4; I ++)
{
// GlColor3f (0.1, GLfloat (I/10), 0.1 );
GlVertex2fv (Vertex [I]);
// Sleep (1, 5000 );
}
GlEnd ();
}
 


Initial: http://www.5dkx.com/arch/139.html

Non-special instructions are original articles such as reprint, please note: reprint from 5d happy blog [http://www.5DKX.com/]

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.