⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppp.cpp

📁 apple.rar
💻 CPP
字号:
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>

void myinit(void);
void CALLBACK myReshape(GLsizei w, GLsizei h);
void CALLBACK display(void);

  /* 初始化 alpha 融合的参数 */
void myinit(void)
  {
    glEnable (GL_BLEND);
    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glShadeModel (GL_FLAT);
    glClearColor (0.0, 0.0, 0.0, 0.0);
  }

void CALLBACK display(void)
  {
    glClear(GL_COLOR_BUFFER_BIT);

    glColor4f (1.0, 0.0, 0.0, 0.7);
    glRectf (0.25, 0.4, 0.75, 0.9);

    glColor4f (0.0, 1.0, 0.0, 0.5);
    glRectf (0.1, 0.1, 0.6, 0.6);
    
    glColor4f (0.0, 0.0, 1.0, 0.3);
    glRectf (0.4, 0.1, 0.9, 0.6);
    
    glFlush();
  }

void CALLBACK myReshape(GLsizei w, GLsizei h)
  {
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    if (w <= h)
      gluOrtho2D (0.0, 1.0, 0.0, 1.0*(GLfloat)h/(GLfloat)w);
    else
      gluOrtho2D (0.0, 1.0*(GLfloat)w/(GLfloat)h, 0.0, 1.0);
    glMatrixMode(GL_MODELVIEW);
  }

void main(void)
  {
    auxInitDisplayMode (AUX_SINGLE | AUX_RGBA);
    auxInitPosition (0, 0, 500, 500);
    auxInitWindow ("Alpha 2D Blending");
    myinit();
    auxReshapeFunc (myReshape);
    auxMainLoop(display);
  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -