ããä¸ã æ¦å¿µçæ¾æ¸
ããç»å¸¸ä¼çå°è®ºåéé¢æ人è¿æ ·é®ï¼
ããåªéè½ä¸è½½OpenGL2.0ç头æ件ååºæ件ï¼
ããå
¶å®ï¼å¯¹äºä¸ä¸ªååæ¥è§¦OpenGLçæ°ææ¥è¯´ï¼å¦ææ¯å¨Windowså¹³å°ä¸å¼åï¼è¿ä¸ªé®é¢æ¯ä¸å®ä¼ç»åçï¼ä¸ºä»ä¹å¢ï¼å 为å¾å¤åè书ä¸é½ä¼æå°OpenGL2.0ï¼ä½æ¯å¾®è½¯å¯¹OpenGLçæ¯æåªå°1.1ï¼1.1以å微软就ä¸åæ¯æäºï¼ä¸ºä»ä¹ï¼å 为微软æ´æ³åå±èªå®¶çDirectXãæ以å¦ææ³ä½¿ç¨OpenGL1.1以ä¸çåè½æè
å½æ°ï¼åªè½ä½¿ç¨OpenGLæ©å±ï¼è¿äºæ©å±æ¯ä¸äºOpenGLå¢ä½æ个人å¼ååºæ¥çè½Windowsä¸ä½¿ç¨çOpenGL1.1以åçä¸äºåè½åå½æ°ãæ以ï¼å¨Windowsä¸æ ¹æ¬å°±æ²¡æä»ä¹OpenGL2.0ç头æ件æåºæ件äºï¼OpenGL1.1以åçä¸è¥¿é½å·²ç»ä»¥æ©å±çå½¢å¼åå¨äºï¼èä¸ï¼å¹¶æ²¡æä¸ä¸ªç»ä¸çæ åï¼ä½ å¯ä»¥ä½¿ç¨glexï¼glewï¼gleeççãä¸é¢æç»åºä¸¤ç§å¸¸ç¨çæ¹æ³ï¼
ãã大å¤æ°äººé½æ¯å¨è¿è¡çº¢å®ä¹¦ä¸çç¨åºæ¶éå°è¿ä¸ªé®é¢ï¼æ¯å¦è¿ä¸ªå½æ°glBlendEquationï¼å®å°±æ¯GL_ARB_imagingæ©å±ä¸çä¸ä¸ªå½æ°ãæ以ï¼å¨ä½¿ç¨ä¸ä¸ªæ©å±ä¹åï¼é¦å
è¦åçå°±æ¯å¤æä½ çæ¾å¡æ¯å¦æ¯æ该æ©å±ã
ããäºã å¦ä½å¤ææ¾å¡ææ¯æçæ©å±ï¼
ãã使ç¨å½æ°glGetStringï¼çä¸ä¸å®çååï¼
ããconst GLubyte * glGetStringï¼ GLenum name ï¼
ããæ们以GL_EXTENSIONS为åæ°è°ç¨è¯¥å½æ°ï¼å°±è½è·å¾å½åæ¾å¡ææ¯æçæææ©å±ï¼åä¸é¢è¿æ ·ï¼
ããconst GLubyte *str = glGetStringï¼GL_EXTENSIONSï¼ ;
ããcout ã str ã endl ;
ããè¾åºçå个æ©å±ä¹é´ä»¥ç©ºæ ¼åéï¼å¦æè¿äºæ©å±ä¸å
å«GL_ARB_imagingï¼é£ä¹ä½ å°±å¯ä»¥ä½¿ç¨glBlendEquationè¿ä¸ªå½æ°äºã
ããå½ç¶ï¼è¿æ ·æ¥è¯¢çåªæ¯glæ©å±ï¼è¿å¯ä»¥ç¨gluGetStringè·å¾gluæ©å±ã
ããä¸ã 使ç¨æ©å±å½æ°
ããå¨å¤æäºæ¾å¡ææ¯æçæ©å±ä»¥åï¼å°±å¯ä»¥ä½¿ç¨è¯¥æ©å±ä¸æå
å«çå½æ°äºä¸é¢è¯¦ç»ä»ç»ä¸¤ç§ä½¿ç¨æ©å±å½æ°çå
·ä½æ¹æ³ï¼
ãã使ç¨glext
ããè¿éä¸è½½ï¼ï¼
http://graphics.ethz.ch/pointshop3d/sourcedoc/html/glext_8h-source.htmlï¼
ããaï¼å¤´æ件çå
å« è¿ä¸ªæ件并ä¸æ¯Windowsç³»ç»ä¸åæçï¼éè¦å°ç½ä¸ä¸è½½ã使ç¨çæ¶åæä¸ç¹è¦æ³¨æï¼å¦æç¨åºä¸è¿ç¨å°äºglut.hæ件ï¼é£ä¹ä¸å®è¦æglext.hæ¾å¨glut.hçåé¢ï¼å 为glext.hè¦ç¨å°gl.hï¼èglut.hä¸å
å«äºgl.hï¼å¦æ顺åºæéäºï¼ç¼è¯çæ¶åä¼æä¸å¤§å é误ï¼æ£ç¡®ç顺åºå¦ä¸ï¼
ãã#include <iostream>
ãã#include <windows.h>
ãã#include <GL/glut.h>
ãã#include <GL/glext.h>
ããbï¼è·åå½æ°æé
ããå
å®ä¹å½æ°æéï¼PFNGLBLENDEQUATIONPROC glBlendEquation = NULL;
ããåè·åå½æ°å°åï¼ ä½¿ç¨wglGetProcAddresså½æ°ï¼æ³¨æè¿ä¸å¥è¦å å¨ä½¿ç¨glBlendEquationå½æ°çè¯å¥ä¹åæææï¼æååé¢ç´§è·ç使ç¨glBlendEquationçå½æ°è¯å¥ï¼åè®°ä¸è¦å å¨ææåç¨åºçå¤é¢ï¼å¦åè·åçæéæ¯æ æç
ããglBlendEquation = ï¼PFNGLBLENDEQUATIONPROCï¼wglGetProcAddressï¼âglBlendEquationâï¼ï¼
ããä¾å¦å¯ä»¥è¿æ ·å ï¼
ããPFNGLBLENDEQUATIONPROC glBlendEquation = ï¼PFNGLBLENDEQUATIONPROCï¼wglGetProcAddressï¼âglBlendEquationâï¼ï¼
ããswitchï¼keyï¼
ãã{
ããcase 'a':
ããcase 'A':
ãã//Note: glBlendEquation is a subset of GL_ARB_imaging, please call glGetString
ãã//first to confirm whether your video card support this extension.
ããglBlendEquationï¼GL_FUNC_ADDï¼ ;
ããbreak ;
ããcase 's':
ããcase 'S':
ããglBlendEquationï¼GL_FUNC_SUBTRACTï¼ ;
ããbreak ;
ããå¦æè§å¾ä¸é¢çæ¹æ³éº»ç¦ï¼é£ä¹å¯ä»¥ä½¿ç¨ä¸é¢çæ¹æ³ï¼ææ¨èè¿ç§æ¹æ³ï¼
ãã1. 使ç¨glew
ããglewä¹æ¯ä¸ä¸ªæ©å±åºï¼å
å«äºOpenGLä¸è®¸å¤æ ¸å¿åæ©å±å½æ°ï¼ç°å¨ççæ¬æ¯1.3.5ï¼æ¯æOpenGL2.1ï¼å¯ä»¥å°è¿éä¸è½½ï¼
ãã
http://glew.sourceforge.net/ããä¸é¢çæ¹æ³å¯è½æäºéº»ç¦ï¼å¦æå·²ç»ä¸è½½äºglewåºçè¯ï¼é£ä¹å¯ä»¥ç´æ¥ä½¿ç¨è¯¥æ©å±ï¼ä½æ¯ä½¿ç¨ä¹åé¦å
è¦ç¡®å®ä½ çæ¾å¡æ¯å¦æ¯æ该æ©å±ãæ¹æ³å¦ä¸ï¼é¦å
è¿æ¯è¦å¤ææ¾å¡æ¯å¦æ¯æ该æ©å±ï¼æ们è¿éåå®å·²ç»æ¯æï¼
ãã1.å
å«å¤´æ件glew.hï¼æ³¨æè¿éåä¸é¢ä¸åï¼è¿åglut.hè¦æ¾å¨glew.hçåé¢äº
ããåä¸é¢è¿æ ·
ãã#include <GL/glew.h>
ãã#include <GL/glut.h>
ããç¶åå°±å¯ä»¥å¨ç¨åºä¸ç´æ¥ä½¿ç¨glBlendEquationäºï¼å
¶ä»æ©å±çå¤æå使ç¨æ¹æ³ä¸æ¤ç±»ä¼¼ã
ããæåè¿æä¸ç¹åè®°ï¼é£å°±æ¯è¿è¦è°ç¨glewInitï¼ï¼ ;æ¥åå§åä¸ä¸æ¹å¯ä½¿ç¨æ©å±ï¼å¦ä¸ï¼
ããGLenum err = glewInitï¼ï¼ ;
ããif ï¼GLEW_OK != errï¼
ãã{
ããMessageBoxAï¼NULL, âerrorâ, âMy Windowâ, 1ï¼ ;
ãã}
ãã.å¨project->settingä¸ï¼æå¼linké项å¡ï¼å ä¸glew.lib
ããæå¨æ件ä¸å ä¸#progmma commentï¼lib, âglew.libâï¼