为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

opengl画线 虚线 折线(OpenGL画线虚线折线)

2017-12-07 8页 doc 24KB 25阅读

用户头像

is_260251

暂无简介

举报
opengl画线 虚线 折线(OpenGL画线虚线折线)opengl画线 虚线 折线(OpenGL画线虚线折线) opengl画线 虚线 折线(OpenGL画线虚线折线) * OpenGL graphics, dotted line, various shapes #include "windows.h"" #include #include #include Void myinit (void); Void DrawMyObjects (void); Void myReshape (GLsizei, W, GLsizei, H); Void display...
opengl画线 虚线 折线(OpenGL画线虚线折线)
opengl画线 虚线 折线(OpenGL画线虚线折线) opengl画线 虚线 折线(OpenGL画线虚线折线) * OpenGL graphics, dotted line, various shapes #include "windows.h"" #include #include #include Void myinit (void); Void DrawMyObjects (void); Void myReshape (GLsizei, W, GLsizei, H); Void display (void); Void myinit (void) { GlClearColor (0.0,0.0,0.0,0.0); GlClear (GL_COLOR_BUFFER_BIT); GlShadeModel (GL_FLAT); } Void myReshape (GLsizei, W, GLsizei, H) { GlViewport (0,0, W, H); GlMatrixMode (GL_PROJECTION); GlLoadIdentity (); If (w<=h) GlOrtho (-20.0,20.0, -20.0* (GLfloat), h/ (GLfloat), W, 20.0* (GLfloat), h/ (GLfloat), W, -50.0,50.0); Else GlOrtho (-20.0* (GLfloat), h/ (GLfloat), W, 20.0* (GLfloat), h/ (GLfloat), W, -20.0,20.0, -50.0,50.0); GlMatrixMode (GL_MODELVIEW); GlLoadIdentity (); } Void display (void) { GlColor3f (1.0,1.0,0.0); DrawMyObjects (); GlFlush (); } Void DrawMyObjects (void) { GlPointSize (5); / / set point size GlBegin (GL_POINTS); / / painting GlColor3f (1.0,0.0,0.0); GlVertex2f (-10.0,11.0); GlColor3f (1.0,1.0,0.0); GlVertex2f (-9.0,10.0); GlColor3f (0.0,1.0,1.0); GlVertex2f (-8.0,12.0); GlEnd (); GlLineWidth (1); / / set the line size GlBegin (GL_LINES); / / painting line GlColor3f (1.0,1.0,0.0); GlVertex2f (-11.0,8.0); GlVertex2f (-7.0,7.0); GlColor3f (1.0,0.0,1.0); GlVertex2f (-11.0,9.0); GlVertex2f (-8.0,6.0); GlEnd (); GlLineWidth (1); / / set the closed line size GlBegin (GL_LINE_STRIP); / / not closed line GlVertex2f (-3.0,9.0); GlColor3f (0.0,1.0,0.0); GlVertex2f (2.0,6.0); GlColor3f (0.0,0.0,1.0); GlVertex2f (3.0,8.0); GlColor3f (1.0,0.0,1.0); GlVertex2f (-2.5,6.5); GlEnd (); GlLineWidth (1); / / set the closed line size GlBegin (GL_LINE_LOOP); / / draw closed line GlColor3f (0.0,1.0,1.0); GlVertex2f (7.0,7.0); GlVertex2f (8.0,8.0); GlVertex2f (9.0,6.5); GlVertex2f (10.3,7.5); GlVertex2f (11.5,6.0); GlVertex2f (7.5,6.0); GlEnd (); GlEnable (GL_LINE_STIPPLE); / / draw line start GlLineWidth (1); GlLineStipple (1,0x00FF); / / the first parameter is the ratio of second is 16 hexadecimal number GlBegin (GL_LINES); GlColor3f (1.0,1.0,0.0); GlVertex2f (-11.0,8.0); GlVertex2f (-3.0,7.0); GlEnd (); GlLineStipple (1,0x00FF); GlBegin (GL_LINES); GlColor3f (1.0,0.0,1.0); GlVertex2f (-15.0,9.0); GlVertex2f (-9.0,6.0); GlEnd (); GlDisable (GL_LINE_STIPPLE); / / the end of line painting GlPolygonMode (GL_FRONT, GL_LINE); / / front line / / the first parameter is the front and back GL_FRONT, GL_BACK, GL_FRONT_AND_BACK, second GL_LINE GL_FILL, GL_POINT parameters. GlBegin (GL_POLYGON); / / drawing convex polygon GlColor3f (0.5,0.3,0.7); GlVertex2f (-7.0,2.0); GlVertex2f (-8.0,3.0); GlVertex2f (-10.3,0.5); GlVertex2f (-7.5, -2.0); GlVertex2f (-6.0, -1.0); GlEnd (); GlPolygonMode (GL_FRONT, GL_LINE); / / front line GlPolygonMode (GL_BACK, GL_FILL); / / back filling GlBegin (GL_TRIANGLES); / / draw a triangle GlColor3f (0.2,0.5,0.7); / / counterclockwise, positive GlVertex2f (-10.0, -5.0); GlVertex2f (-12.3, -7.5); GlVertex2f (-8.5, -6.0); GlColor3f (0.2,0.7,0.5); / / clockwise, back GlVertex2f (-8.0, -7.0); GlVertex2f (-7.0, -4.5); GlVertex2f (-5.5, -9.0); GlEnd (); GlBegin (GL_TRIANGLE_STRIP); / / draw linear triangular group GlVertex2f (-1.0, -8.0); GlVertex2f (-2.5, -5.0); GlColor3f (0.8,0.8,0.0); GlVertex2f (1, -7.0); GlColor3f (0.0,0.8,0.8); GlVertex2f (2, -4.0); GlColor3f (0.8,0.0,0.8); GlVertex2f (4, -6.0); GlEnd (); GlBegin (GL_TRIANGLE_FAN); / / fan painting GlVertex2f (8, -6.0); GlVertex2f (10, -3.0); GlColor3f (0.8,0.2,0.5); GlVertex2f (12.5, -4.5); GlColor3f (0.2,0.5,0.8); GlVertex2f (13, -7.5); GlColor3f (0.8,0.5,0.2); GlVertex2f (10.5, -9.0); GlEnd (); GlBegin (GL_QUADS); / / draw quadrilateral GlColor3f (0.7,0.5,0.2); GlVertex2f (0.0,2.0); GlVertex2f (-1.0,3.0); GlVertex2f (-3.3,0.5); GlVertex2f (-0.5, -1.0); GlColor3f (0.5,0.7,0.2); GlVertex2f (3.0,2.0); GlVertex2f (2.0,3.0); GlVertex2f (0.0,0.5); GlVertex2f (2.5, -1.0); GlEnd (); GlBegin (GL_QUADS); / / draw continuous filling quadrilateral GlVertex2f (6, -2.0); GlVertex2f (5.5,1.0); GlVertex2f (8, -1.0); GlColor3f (0.8,0.0,0.0); GlVertex2f (9.0,2.0); GlVertex2f (11, -2.0); GlColor3f (0.0,0.0,0.8); GlVertex2f (11.0,2.0); GlVertex2f (13, -1.0); GlColor3f (0.0,0.8,0.0); GlVertex2f (14.0,1.0); GlEnd (); } Int main (int, argc, char**, argv) { GlutInit (&argc, argv); GlutInitDisplayMode (GLUT_SINGLE GLUT_RGB |); GlutInitWindowSize (500, 500); GlutInitWindowPosition (0, 0); GlutCreateWindow ("Draw"); Myinit (); //init (); GlutReshapeFunc (myReshape); GlutDisplayFunc (display); //glutKeyboardFunc (keyboard); GlutMainLoop (); Return 0; }
/
本文档为【opengl画线 虚线 折线(OpenGL画线虚线折线)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索