Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <GLUT/glut.h>
- void display(void)
- {
- glClear(GL_COLOR_BUFFER_BIT);
- glColor3d(0.0, 0.0, 0.0);//色
- glBegin(GL_LINE_LOOP);
- glVertex2d(-0.1, -0.1);//位置
- glVertex2d(0.1, -0.1);//位置
- glVertex2d(0.1, 0.1);//位置
- glVertex2d(-0.1, 0.1);//位置
- glEnd();
- glFlush();
- }
- void keyboard(unsigned char key, int x, int y)
- {
- switch (key) {
- case 'q':
- case 'Q':
- case '\033': /* '\033' は ESC の ASCII コード */
- exit(0);
- default:
- break;
- }
- }
- void resize(int w, int h)
- {
- }
- void mouse(int button, int state, int x, int y)
- {
- switch (button) {
- case GLUT_LEFT_BUTTON:
- glEnd();
- glFlush();
- }
- }
- void motion(int x, int y)
- {
- glEnable(GL_COLOR_LOGIC_OP);
- glLogicOp(GL_INVERT);
- glBegin(GL_LINES);
- glVertex2i(x, y);
- glEnd();
- glFlush();
- }
- void init(void)
- {
- glClearColor(1.0, 1.0, 1.0, 0.0);
- }
- int main(int argc, char *argv[])
- {
- glutInitWindowPosition(100, 100);//ウィンドウの位置
- glutInitWindowSize(600, 600);//ウィンドウの幅と大きさ
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_RGBA);
- glutCreateWindow(argv[0]);
- glutDisplayFunc(display);
- glutKeyboardFunc(keyboard);
- init();
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement