개강하고 과제에 쌓여지내느라~
오늘도 밤을 새고 있습니다. ㅠ_ㅠ
괜시리 연계전공으로 컴퓨터 과목을 들어서~
시작하자 마자 과제라니.. 너무 하십니다. 교수님들 ㅠ_ㅠ
(저는 교수님 수업만 듣는게 아니라구욧! - 출처- 골방환상곡)
누군가 도와주실 분 !!!?? ^-^
간단한 그래픽스프로그래밍 입니다.
설명까지 해주신다면 금상첨화! 저는 지금 용어조차 모르기 때문에.. 도대체 콜백 함수가 뭡니까? 하 참네.
----------------------------------------
※ 수업자료 중 “animating a display – double buffering “ source code 참조
--------------------회전하는 사각형------
#include <glut.h>
#include <stdlib.h>
#include <math.h>
#define DEGREES_TO_RADIANS 3.14159/180.0
static GLfloat spin = 0.0;
GLfloat x, y;
int singleb, doubleb;
void square()
{
glBegin(GL_QUADS);
glVertex2f(x,y);
glVertex2f(-y,x);
glVertex2f(-x,-y);
glVertex2f(y,-x);
glEnd();
}
void displayd()
{
glClear (GL_COLOR_BUFFER_BIT);
square();
glutSwapBuffers ();
}
void displays()
{
glClear (GL_COLOR_BUFFER_BIT);
square();
glFlush();
}
void spinDisplay ()
{
spin = spin + 2.0;
if (spin > 360.0) spin = spin - 360.0;
x= 25.0*cos(DEGREES_TO_RADIANS * spin);
y= 25.0*sin(DEGREES_TO_RADIANS * spin);
glutSetWindow(singleb);
glutPostRedisplay();
glutSetWindow(doubleb);
glutPostRedisplay();
}
void myinit ()
{
glClearColor (0.0, 0.0, 0.0, 1.0);
glColor3f (1.0, 1.0, 1.0);
glShadeModel (GL_FLAT);
}
void mouse(int btn, int state, int x, int y)
{
if(btn==GLUT_LEFT_BUTTON && state==GLUT_DOWN)
glutIdleFunc(spinDisplay);
if(btn==GLUT_MIDDLE_BUTTON && state==GLUT_DOWN)
glutIdleFunc(NULL);
}
void myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (w <= h)
glOrtho (-50.0, 50.0, -50.0*(GLfloat)h/(GLfloat)w,
50.0*(GLfloat)h/(GLfloat)w, -1.0, 1.0);
else
glOrtho (-50.0*(GLfloat)w/(GLfloat)h,
50.0*(GLfloat)w/(GLfloat)h, -50.0, 50.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity ();
}
/* main loop
* open window with initial window size, title bar,
* RGBA display mode, and handle input events
*/
int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
singleb
