Develop
2003.04.23 10:52
[c] OpenGL 마우스 이벤트
조회 수 8753 댓글 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(); }
번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|---|
649 | Develop |
[ios] iOS 의 인앱구매 소개
![]() |
hooni | 2014.04.29 | 3894 |
648 | Develop |
[php] 3 Ways to Detect Mobile or Desktop in PHP
![]() |
hooni | 2020.01.28 | 3978 |
647 | Develop | [ios] UDID 사용 제한에 따른 대안들 | hooni | 2014.03.13 | 4013 |
646 | Develop | [ios] 아이폰 GPS 사용하기 | hooni | 2014.05.24 | 4038 |
645 | Develop | [android] 코드에서 문자열로 Resource 가져오기 | hooni | 2015.07.09 | 4065 |
644 | Develop |
[ios] iOS 7 이상 UIBarButtonItem 여백
![]() |
hooni | 2014.03.27 | 4095 |
643 | Develop |
[ios] DatePicker iOS 6.x 이하 디자인.
![]() |
hooni | 2014.04.10 | 4121 |
642 | Develop |
[ios] AES256 알고리즘을 이용해 데이터 암호화/복호화 방법
![]() |
hooni | 2015.07.21 | 4183 |
641 | Develop |
[ios] 애플 앱스토어 IDFA 리뷰 정책 변경 안내
![]() |
hooni | 2014.05.07 | 4242 |
640 | Develop |
[c#]뉴 툴바 개인적으로 만든거.. (old)
![]() |
hooni | 2013.04.23 | 4272 |
639 | Develop | [ios] URL Scheme 이용하여 앱 설치 확인 | hooni | 2014.03.10 | 4408 |
638 | Develop |
[ios] 앱딜리게이트 라이프사이클 (AppDelegate Lifecycle)
![]() |
hooni | 2014.05.09 | 4505 |