3,881
社区成员
发帖
与我相关
我的任务
分享
#include "glut.h"
#include "limits.h"
int ajust(int color)
{
return color / 255.f * INT_MAX;
}
void display()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.f, 500.f, 500.f, 0.f, 1.f, 100.f);
glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT);
glColor3i(0, 0, ajust(128));
glBegin(GL_LINES);
glVertex3f(0, 200, -10);
glVertex3f(500, 200, -10);
glEnd();
glFlush();
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
glutCreateWindow("gl test");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
#include "glut.h"
#include "limits.h"
int ajust(int color)
{
return color / 255 * INT_MAX;
}
void display()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.f, 500.f, 500.f, 0.f, 1.f, 100.f);
glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT);
glColor3i(0, 0, ajust(255));
glBegin(GL_LINES);
glVertex3f(0, 200, -10);
glVertex3f(500, 200, -10);
glEnd();
glFlush();
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_SINGLE);
glutCreateWindow("gl test");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}