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
STENCIL.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 <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <GL/glut.h> static void Init(void) { glClearColor(0.0, 0.0, 0.0, 0.0); glClearStencil(0); glStencilMask(1); glEnable(GL_STENCIL_TEST); } static void Reshape(int width, int height) { glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0); glMatrixMode(GL_MODELVIEW); } static void Key(unsigned char key, int x, int y) { switch (key)
- {
- case 27:
- exit(0); } } static void Draw(void) { glClear(GL_COLOR_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); glStencilFunc(GL_ALWAYS, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); glColor3ub(200, 0, 0); glBegin(GL_POLYGON); glVertex3i(-4, -4, 0); glVertex3i( 4, -4, 0); glVertex3i( 0, 4, 0); glEnd(); glStencilFunc(GL_EQUAL, 1, 1); glStencilOp(GL_INCR, GL_KEEP, GL_DECR); glColor3ub(0, 200, 0); glBegin(GL_POLYGON); glVertex3i(3, 3, 0); glVertex3i(-3, 3, 0); glVertex3i(-3, -3, 0); glVertex3i(3, -3, 0); glEnd(); glStencilFunc(GL_EQUAL, 1, 1); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glColor3ub(0, 0, 200); glBegin(GL_POLYGON); glVertex3i(3, 3, 0); glVertex3i(-3, 3, 0); glVertex3i(-3, -3, 0); glVertex3i(3, -3, 0); glEnd(); glutSwapBuffers(); } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_STENCIL | GLUT_DOUBLE); glutInitWindowSize(300, 300); glutCreateWindow("Stencil Test"); Init(); glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Draw); glutMainLoop(); }