Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
LIST.C
Package: 《OpenGL三维图形系统开发与实用技术》书的源码.rar [view]
Upload User: tengyuc
Upload Date: 2007-08-14
Package Size: 722k
Code Size: 2k
Category:
OpenGL program
Development Platform:
Visual C++
- // 本程序演示如何创建和运行一个显式列表 #include <GL/glut.h> #include <stdlib.h> GLuint listName; static void init (void) {
- // 生成显式列表名称索引 listName = glGenLists (1);
- // 创建一个显式列表 glNewList (listName, GL_COMPILE); glColor3f (1.0, 0.0, 0.0); // 当前颜色是红色 glBegin (GL_TRIANGLES); glVertex2f (0.0, 0.0); glVertex2f (1.0, 0.0); glVertex2f (0.0, 1.0); glEnd (); glTranslatef (1, 0.0, 0.0); // 移动位置 glEndList (); glShadeModel (GL_FLAT); } static void drawLine (void) { glBegin (GL_LINES); glVertex2f (0.0, 0.5); glVertex2f (15.0, 0.5); glEnd (); } void display(void) { GLuint i; glClear (GL_COLOR_BUFFER_BIT); glColor3f (0.0, 1.0, 0.0); // 当前颜色是绿色 for (i = 0; i < 10; i++) // 绘制10个三角形 glCallList (listName); drawLine (); glFlush (); } void reshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (w <= h) gluOrtho2D (0.0, 2.0, -0.5 * (GLfloat) h/(GLfloat) w, 1.5 * (GLfloat) h/(GLfloat) w); else gluOrtho2D (0.0, 2.0 * (GLfloat) w/(GLfloat) h, -0.5, 1.5); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: exit(0); break; } } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(300, 50); glutCreateWindow(argv[0]); init (); glutReshapeFunc (reshape); glutDisplayFunc (display); glutKeyboardFunc (keyboard); glutMainLoop(); return 0; }