当前位置:网站首页>OpenGL draws two points on the screen, a blue point on the right, using anti aliasing technology, and a red point on the left, without anti aliasing technology. Compare the difference between the two
OpenGL draws two points on the screen, a blue point on the right, using anti aliasing technology, and a red point on the left, without anti aliasing technology. Compare the difference between the two
2022-07-24 05:31:00 【Mo xiaodai ^o^】
#define GLUT_DISABLE_ATEXIT_HACK
#include<windows.h>
#include <gl/glut.h>
float angle = 0;
// initialization OpenGL
int choose = 1;
void init(void)
{
glClearColor(1.0f, 1.0f, 0.0f, 0.0f);// Set the background color
glShadeModel(GL_SMOOTH);// Set shading , There are two selection modes :GL_FLAT( No gradients ) and GL_SMOOTH( Gradient transition )
}
// The main drawing process
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);// Clear color cache
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -7.0f); /**< Move to screen 5 A unit of */
if (choose == 1)
{
glDisable(GL_BLEND);
glDisable(GL_POINT_SMOOTH);
glDisable(GL_POLYGON_SMOOTH);
glPointSize(30.0);
glColor3f(1.0f, 0.0f, 0.0f); /**< Assign colors */
glBegin(GL_POINTS);
glVertex2f(-1.0, 0.0);
glEnd();
glEnable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glEnable(GL_POINT_SMOOTH);
/**< Enable hybrid */
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /**< Specify mixing factor */
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); /**< behavior control */
glPointSize(30.0);
glColor3f(0.0f, 0.0f, 1.0f); /**< Assign colors */
glBegin(GL_POINTS);
glVertex2f(0.0, 0.0);
glEnd();
}
glutSwapBuffers();
}
// Call when the window changes size
void reshape(int w, int h) {
glViewport(0, 0, w, h);// Set up the viewport
glMatrixMode(GL_PROJECTION);// Set the current projection transformation mode
glLoadIdentity();// Replace the current transformation matrix with the identity matrix
gluPerspective(45, (float)w / h, 4, 100.0);// Set the orthographic projection body
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void TimerFunction(int value)
{
angle += 10;
if (angle == 360)
angle = 0;
// Redraw the scene with new coordinates
glutPostRedisplay();
glutTimerFunc(500, TimerFunction, 1);
}
// Dealing with keyboards
void keyboard(unsigned char key, int x, int y) {
switch (key)
{
case 'a':
choose = 0;
break;
case 'b':
choose = 1;
break;
case 27://esc Key to exit
exit(0);
break;
default:
break;
}
glutPostRedisplay();
}
// Dealing with keyboards
void specialkeyboard(int key, int x, int y) {
switch (key)
{
case GLUT_KEY_UP:
choose = 1;
break;
case GLUT_KEY_DOWN:
choose = 0;
break;
default:
break;
}
glutPostRedisplay();
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(640, 480);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA);
glutCreateWindow("Basic");// Set the window title
init();// initialization OpenGL
glutDisplayFunc(display);// Set display callback function
glutReshapeFunc(reshape);// Set up reshape Callback function
glutTimerFunc(500, TimerFunction, 1);
glutKeyboardFunc(keyboard);// Set the keyboard callback function
glutSpecialFunc(specialkeyboard);
glutMainLoop();// Enter the main loop
}
边栏推荐
猜你喜欢
随机推荐
空杯心态,重新开始
Find the flops of the network
Promise续(尝试自己实现一个promise)更详细的注释和其它接口暂未完成,下次咱们继续。
谈谈对未来的想法
THREE——OrbitControls轨道控制器
数组_01forEach中的return
用C语言写出三子棋
解决:控制台使用nvm控制node版本时出现exit status 1与exit status 145
special effects - 鼠标点击,自定义 DOM 跟随移动
special effects - 返回顶部(小猫特效)
牛客网刷题
special effects - 蜘蛛网背景特效
canvas - 圆形
构造函数_Map构造函数
index为什么不能作为v-for的key?
Tabs标签页(el-tabs)_造成页面卡死问题
详解浏览器和Node的事件循环机制及区别
Cmake笔记
Relationship between sample and population in Statistics: sample success ratio + central limit theorem (sample mean)
Opengl在屏幕上绘制一个锥体,该锥体有四个面,每个面都是三角形。为该锥体添加光照和纹理效果







![JS:为什么 [] == ![] 返回 true ?](/img/36/94839bf4ce6bd06d2cbe989828c791.png)

