Develop
2003.04.23 10:52
[c] OpenGL 마우스 이벤트
Views 8754 Comment 0
OpenGL 마우스 이벤트 처리 예제
#include<stdio.h> #include<stdlib.h> #include<GL/glut.h> short rightbuttonpressed = 0; double r=1.0, g=0.0, b=0.0; void display(void){ glClearColor(r, g, b, 1.0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glBegin(GL_LINES); glVertex2f(-1.0, 0.0); glVertex2f(0.0, 0.0); glEnd(); glFlush(); } void keyboard(unsigned char key, int x, int y){ switch(key){ case 'r' : r=1.0; g=b=0.0; glutPostRedisplay(); break; case 'g' : g=1.0; r=b=0.0; glutPostRedisplay(); break; case 'b' : b=1.0; r=g=0.0; glutPostRedisplay(); break; case 'q': exit(0); } } void mousepress(int button, int state, int x, int y){ if((button==GLUT_LEFT_BUTTON) && (state==GLUT_DOWN)) printf("*** The left mouse button was pressed at (%d, %d)n", x, y); else if((button==GLUT_RIGHT_BUTTON) && (state==GLUT_DOWN)) rightbuttonpressed = 1; else if((button==GLUT_RIGHT_BUTTON) && (state==GLUT_UP)) rightbuttonpressed = 0; } void mousemove(int x, int y){ if(rightbuttonpressed) printf("$$$ The right mouse button is now at (%d, %d).n",x,y); } void reshape(int width, int height){ printf("### The new windows size is %dx%d.n",width, height); } void RegisterCallback(void){ glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMouseFunc(mousepress); glutMotionFunc(mousemove); glutReshapeFunc(reshape); } void main(int argc, char **argv){ glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA); glutInitWindowSize(500,500); glutCreateWindow("My Second OpenGL Code"); RegisterCallback(); glutMainLoop(); }
No. | Category | Subject | Author | Date | Views |
---|---|---|---|---|---|
841 | Develop |
'2014 모바일 개발 트렌드' 발표자료입니다.
![]() |
hooni | 2014.10.02 | 1137 |
840 | Develop | Aspect Oriented Programming in Objective-C | hooni | 2015.05.18 | 947 |
839 | Develop |
DDay Memo 1.9.4 소스코드
![]() |
hooni | 2015.10.03 | 0 |
838 | Develop |
GCM 사용하기 2 (단말에 GCM 구현하기)
![]() |
hooni | 2013.07.06 | 23411 |
837 | Develop |
GCM 사용하기 3 (JSP로 GCM 푸시 서버 만들기)
4 ![]() |
hooni | 2013.07.06 | 25425 |
836 | Develop | git 브런치 배우기 (링크) | hooni | 2013.07.09 | 20701 |
835 | Develop |
GPL, AGPL, MPL,.. 한눈에 보는 오픈소스SW 라이선스
![]() |
hooni | 2014.10.14 | 1265 |
834 | Develop | How to Test SMTP AUTH using Telnet | hooni | 2018.04.05 | 1589 |
833 | Develop |
JSON, BSON 변환
![]() |
hooni | 2013.04.23 | 11873 |
832 | Develop | Laravel 5 Failed opening required bootstrap/../vendor/autoload.php | hooni | 2018.01.24 | 1834 |
831 | Develop |
Mac OS 에 Jenkins 설치하기 (Homebrew)
2 ![]() |
hooni | 2017.03.15 | 8395 |
830 | Develop |
macOS에 node, npm 설치하기 (homebrew)
![]() |
hooni | 2021.11.06 | 1459 |