[컴퓨터그래픽스] 키보드 마우스 입력을 통한 화면 변경
#include #include #include #define PI 3.141592 #define CCW 0 #define CW 1 using namespace glm; vec3 my_triangle1[3] = { vec3(-10.f, 0.f, 0.f), vec3(10.f, 0.f, 0.f), vec3(0.f, 10.f, 0.f) }; // CCW vec3 my_triangle2[3] = { vec3(10.f, 0.f, 0.f), vec3(-10.f, 0.f, 0.f), vec3(0.f, 10.f, 0.f) }; // CW vec3 faceNorm[2]; vec3 eyeVec; GLfloat angle[2]; GLint culling = 3; // nothing first GLint isTriangle1..
2021. 4. 3.
[컴퓨터그래픽스] openGL 사용하지 않고 culling 수행하기
#include #include #include #define PI 3.141592 #define CCW 0 #define CW 1 using namespace glm; vec3 my_triangle1[3] = { vec3(-10.f, 0.f, 0.f), vec3(10.f, 0.f, 0.f), vec3(0.f, 10.f, 0.f) }; // CCW vec3 my_triangle2[3] = { vec3(10.f, 0.f, 0.f), vec3(-10.f, 0.f, 0.f), vec3(0.f, 10.f, 0.f) }; // CW vec3 faceNorm[2]; vec3 eyeVec; GLfloat angle[2]; GLint culling = CW; GLint isTriangle1 = 0; GLint isTr..
2021. 4. 3.
[컴퓨터그래픽스] gluLookat 변경을 통한 애니메이션 만들기
#include //#include int g_timeDelta = 0, g_prevTime = 0; GLfloat g_x = 0.f; GLfloat g_velocityX = 0.f; void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); g_x += g_velocityX + (GLfloat)g_timeDelta / 1000.f; //printf("%f", g_x); glLoadIdentity(); gluLookAt(g_x, 0.f, -0.1f, g_x, 0.f, 0.f, 0.f, 1.f, 0.f); glColor3f(1.0f, 1.0f, 1.0f); glRectf(.25, .25, -.25, -.25); glu..
2021. 4. 3.
[컴퓨터그래픽스] transformation, scale, rotation
#include #include #include int g_timeDelta = 0, g_prevTime = 0; int inc_y = 1; GLfloat g_x = 0.f; GLfloat g_y = 1.f; GLfloat g_velocityX = 0.5f; GLfloat g_velocityY = 0.01f; GLfloat vertices[] = { -0.8, -0.8, -0.8, 0.8, -0.8, -0.8, 0.8, 0.8, -0.8, -0.8, 0.8, -0.8, -0.8, -0.8, 0.8, 0.8, -0.8, 0.8, 0.8, 0.8, 0.8, -0.8, 0.8, 0.8 }; GLubyte faces[] = { 7, 5, 6, 7, 4, 5, 3, 2, 1, 3, 1, 0, 2, 6, 5, 2,..
2021. 4. 3.
[컴퓨터그래픽스] 소용돌이 실습 (함수 사용하지 않기)
void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); GLfloat rotation[16] = { cos(30.0), 0, -sin(30.0), 0, 0, 1, 0, 0, sin(30.0), 0, cos(30.0), 0, 0, 0, 0, 1 }; GLfloat translation[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, -0.1, 0, 1 }; glPushMatrix(); glColor3f(0.5f, 0.5f, 0.5f); glPointSize(3); glBegin(GL_POINTS); glVertex4f(0.25f, 0.8f, 0.0f, 1.0f); glEnd();..
2021. 4. 3.