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
GLBLEND.C
Package: 《OpenGL三维图形系统开发与实用技术》书的源码.rar [view]
Upload User: tengyuc
Upload Date: 2007-08-14
Package Size: 722k
Code Size: 3k
Category:
OpenGL program
Development Platform:
Visual C++
- #include <GL/glut.h>
- #include <stdlib.h>
- #include <stdio.h>
- #pragma warning( disable : 4305 )
- GLdouble rot_angle;
- void init(void)
- {
- rot_angle = 0.0;
- glClearColor(1.0, 1.0, 1.0, 1.0);
- glShadeModel(GL_FLAT);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- }
- void display(void)
- {
- glClear(GL_COLOR_BUFFER_BIT);
- glPushMatrix();
- glRotated(rot_angle, 1.0, 0.0, 0.0);
- glRotated(rot_angle, 0.0, 1.0, 0.0);
- glBegin(GL_TRIANGLE_STRIP);
- glColor4f(1.0, 0.0, 0.0, 0.3);
- glVertex3f(-1.0, -1.0, 1.0);
- glVertex3f(1.0, -1.0, 1.0);
- glVertex3f(-1.0, 1.0, 1.0);
- glVertex3f(1.0, 1.0, 1.0);
- glColor4f(0.0, 1.0, 0.0, 0.3);
- glVertex3f(-1.0, 1.0, -1.0);
- glVertex3f(1.0, 1.0, -1.0);
- glColor4f(0.0, 0.0, 1.0, 0.3);
- glVertex3f(-1.0, -1.0, -1.0);
- glVertex3f(1.0, -1.0, -1.0);
- glEnd();
- glBegin(GL_TRIANGLE_STRIP);
- glColor4f(1.0, 1.0, 0.0, 0.3);
- glVertex3f(-1.0, 1.0, -1.0);
- glVertex3f(-1.0, 1.0, 1.0);
- glVertex3f(-1.0, -1.0, -1.0);
- glVertex3f(-1.0, -1.0, 1.0);
- glColor4f(0.0, 1.0, 1.0, 0.3);
- glVertex3f(1.0, -1.0, -1.0);
- glVertex3f(1.0, -1.0, 1.0);
- glColor4f(1.0, 0.0, 1.0, 0.3);
- glVertex3f(1.0, 1.0, -1.0);
- glVertex3f(1.0, 1.0, 1.0);
- glEnd();
- glPopMatrix();
- glutSwapBuffers();
- }
- void reshape (int w, int h)
- {
- glViewport(0, 0, (GLsizei) w, (GLsizei) h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluPerspective(60.0, (GLfloat)w / (GLfloat)h, 1.0, 10.0);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- gluLookAt(0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
- }
- void keyboard (unsigned char key, int x, int y)
- {
- switch (key)
- {
- case 27:
- case 'Q':
- case 'q':
- exit(0);
- break;
- }
- }
- void idle(void)
- {
- rot_angle += 0.25;
- if( rot_angle > 360.0 )
- rot_angle -= 360.0;
- glutPostRedisplay();
- }
- int main(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
- glutInitWindowSize(250, 250);
- glutInitWindowPosition(100, 100);
- glutCreateWindow("Transparent Cube");
- init();
- glutDisplayFunc(display);
- glutReshapeFunc(reshape);
- glutKeyboardFunc(keyboard);
- glutIdleFunc(idle);
- glutMainLoop();
- return 0;
- }