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
SMOOTH.C
Package: openGLProject.rar [view]
Upload User: veshion
Upload Date: 2022-06-28
Package Size: 4841k
Code Size: 1k
Category:
OpenGL program
Development Platform:
Visual C++
- // 本程序主要用于演示两种不同的着色模式 #include <GL/glut.h> #include <stdlib.h>
- #include <GL/glaux.h> void init(void) {
- glClearColor (0.0, 0.0, 0.0, 0.0); } void triangle(void) {
- glBegin (GL_TRIANGLES);
- glColor3f (1.0, 0.0, 0.0);
- glVertex2f (2.0, 10.0);
- glColor3f (0.0, 1.0, 0.0);
- glVertex2f (15.0, 10.0);
- glColor3f (0.0, 0.0, 1.0);
- glVertex2f (2, 23.0);
- glEnd(); } void display(void) {
- glClear (GL_COLOR_BUFFER_BIT);
- // 设置光滑着色模式
- glShadeModel (GL_SMOOTH);
- triangle ();
- glPushMatrix();
- // 设置单一着色模式
- glShadeModel (GL_FLAT);
- glTranslatef(14,0,0);
- triangle ();
- glPopMatrix();
- glFlush (); } void reshape (int w, int h) {
- glViewport (0, 0, (GLsizei) w, (GLsizei) h);
- glMatrixMode (GL_PROJECTION);
- glLoadIdentity ();
- if (w <= h)
- gluOrtho2D (0.0, 30.0, 0.0, 30.0 * (GLfloat) h/(GLfloat) w);
- else
- gluOrtho2D (0.0, 30.0 * (GLfloat) w/(GLfloat) h, 0.0, 30.0);
- glMatrixMode(GL_MODELVIEW); } 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 (500, 500);
- glutInitWindowPosition (100, 100);
- glutCreateWindow (argv[0]);
- init ();
- glutDisplayFunc(display);
- glutReshapeFunc(reshape);
- glutKeyboardFunc (keyboard);
- glutMainLoop();
- return 0;
- }