9 1 checker c include GLglut h include

  • Slides: 124
Download presentation

예제 9 -1 텍스처 맵이 적용된 체크판: checker. c #include <GL/glut. h> #include <stdlib.

예제 9 -1 텍스처 맵이 적용된 체크판: checker. c #include <GL/glut. h> #include <stdlib. h> #include <stdio. h> /* Create checkerboard texture */ #define check. Image. Width 64 #define check. Image. Height 64 static GLubyte check. Image[check. Image. Height][check. Image. Width][4]; #ifdef GL_VERSION_1_1 static GLuint tex. Name; #endif 2010 -2학기 가상현실 8

void make. Check. Image(void) { int i, j, c; for (i = 0; i

void make. Check. Image(void) { int i, j, c; for (i = 0; i < check. Image. Height; i++) { for (j = 0; j < check. Image. Width; j++) { c = ((((i&0 x 8)==0)^((j&0 x 8))==0))*255; check. Image[i][j][0] = (GLubyte) c; check. Image[i][j][1] = (GLubyte) c; check. Image[i][j][2] = (GLubyte) c; check. Image[i][j][3] = (GLubyte) 255; } } } 2010 -2학기 가상현실 9

void init(void) { gl. Clear. Color (0. 0, 0. 0); gl. Shade. Model(GL_FLAT); gl.

void init(void) { gl. Clear. Color (0. 0, 0. 0); gl. Shade. Model(GL_FLAT); gl. Enable(GL_DEPTH_TEST); make. Check. Image(); gl. Pixel. Storei(GL_UNPACK_ALIGNMENT, 1); #ifdef GL_VERSION_1_1 gl. Gen. Textures(1, &tex. Name); gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name); #endif 2010 -2학기 가상현실 10

gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_S, GL_REPEAT); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_T, GL_REPEAT); gl. Tex.

gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_S, GL_REPEAT); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_T, GL_REPEAT); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); #ifdef GL_VERSION_1_1 gl. Tex. Image 2 D(GL_TEXTURE_2 D, 0, GL_RGBA, check. Image. Width, check. Image. Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, check. Image); #else gl. Tex. Image 2 D(GL_TEXTURE_2 D, 0, 4, check. Image. Width, check. Image. Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, check. Image); #endif } 2010 -2학기 가상현실 11

void display(void) { gl. Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gl. Enable(GL_TEXTURE_2 D); gl. Tex. Envf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,

void display(void) { gl. Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gl. Enable(GL_TEXTURE_2 D); gl. Tex. Envf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); #ifdef GL_VERSION_1_1 gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name); #endif gl. Begin(GL_QUADS); gl. Tex. Coord 2 f(0. 0, 0. 0); gl. Tex. Coord 2 f(0. 0, 1. 0); gl. Tex. Coord 2 f(1. 0, 0. 0); 2010 -2학기 gl. Vertex 3 f(-2. 0, -1. 0, 0. 0); gl. Vertex 3 f(-2. 0, 1. 0, 0. 0); gl. Vertex 3 f(0. 0, -1. 0, 0. 0); 가상현실 12

gl. Tex. Coord 2 f(0. 0, 0. 0); gl. Vertex 3 f(1. 0, -1.

gl. Tex. Coord 2 f(0. 0, 0. 0); gl. Vertex 3 f(1. 0, -1. 0, 0. 0); gl. Tex. Coord 2 f(0. 0, 1. 0); gl. Vertex 3 f(1. 0, 0. 0); gl. Tex. Coord 2 f(1. 0, 1. 0); gl. Vertex 3 f(2. 41421, 1. 0, -1. 41421); gl. Tex. Coord 2 f(1. 0, 0. 0); gl. Vertex 3 f(2. 41421, -1. 0, -1. 41421); gl. End(); gl. Flush(); gl. Disable(GL_TEXTURE_2 D); } void reshape(int w, int h) { gl. Viewport(0, 0, (GLsizei) w, (GLsizei) h); gl. Matrix. Mode(GL_PROJECTION); gl. Load. Identity(); 2010 -2학기 가상현실 13

glu. Perspective(60. 0, (GLfloat) w/(GLfloat) h, 1. 0, 30. 0); gl. Matrix. Mode(GL_MODELVIEW); gl.

glu. Perspective(60. 0, (GLfloat) w/(GLfloat) h, 1. 0, 30. 0); gl. Matrix. Mode(GL_MODELVIEW); gl. Load. Identity(); gl. Translatef(0. 0, -3. 6); } void keyboard (unsigned char key, int x, int y) { switch (key) { case 27: exit(0); break; default: break; } } 2010 -2학기 가상현실 14

int main(int argc, char** argv) { glut. Init(&argc, argv); glut. Init. Display. Mode(GLUT_SINGLE |

int main(int argc, char** argv) { glut. Init(&argc, argv); glut. Init. Display. Mode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glut. Init. Window. Size(250, 250); glut. Init. Window. Position(100, 100); glut. Create. Window(argv[0]); init(); glut. Display. Func(display); glut. Reshape. Func(reshape); glut. Keyboard. Func(keyboard); glut. Main. Loop(); return 0; } 2010 -2학기 가상현실 15

예제 9 -2 텍스처 프록시로 텍스처 리소스 요청하기 GLInt width; gl. Tex. Image 2

예제 9 -2 텍스처 프록시로 텍스처 리소스 요청하기 GLInt width; gl. Tex. Image 2 D(GL_PROXY_TEXTURE_2 D, 0, GL_RGBA 8, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); gl. Get. Tex. Level. Parameteriv(GL_PROXY_TEXTURE_2 D, 0, GL_TEXTURE_WIDTH, &width); 2010 -2학기 가상현실 23

예제 9 -3 텍스처 서브 이미지 교체: texsub. c #include <GL/glut. h> #include <stdlib.

예제 9 -3 텍스처 서브 이미지 교체: texsub. c #include <GL/glut. h> #include <stdlib. h> #include <stdio. h> #ifdef GL_VERSION_1_1 #define check. Image. Width 64 #define check. Image. Height 64 #define sub. Image. Width 16 #define sub. Image. Height 16 static GLubyte check. Image[check. Image. Height][check. Image. Width][4]; static GLubyte sub. Image[sub. Image. Height][sub. Image. Width][4]; static GLuint tex. Name; 2010 -2학기 가상현실 25

void make. Check. Images(void) { int i, j, c; for (i = 0; i

void make. Check. Images(void) { int i, j, c; for (i = 0; i < check. Image. Height; i++) { for (j = 0; j < check. Image. Width; j++) { c = (((i&0 x 8)==0)^((j&0 x 8)==0))*255; //정정 check. Image[i][j][0] = (GLubyte) c; check. Image[i][j][1] = (GLubyte) c; check. Image[i][j][2] = (GLubyte) c; check. Image[i][j][3] = (GLubyte) 255; } } 2010 -2학기 가상현실 26

for (i = 0; i < sub. Image. Height; i++) { for (j =

for (i = 0; i < sub. Image. Height; i++) { for (j = 0; j < sub. Image. Width; j++) { c = (((i&0 x 4)==0)^((j&0 x 4)==0))*255; //정정 sub. Image[i][j][0] = (GLubyte) c; sub. Image[i][j][1] = (GLubyte) 0; sub. Image[i][j][2] = (GLubyte) 0; sub. Image[i][j][3] = (GLubyte) 255; } }} void init(void) { gl. Clear. Color (0. 0, 0. 0); gl. Shade. Model(GL_FLAT); gl. Enable(GL_DEPTH_TEST); 2010 -2학기 가상현실 27

make. Check. Images(); gl. Pixel. Storei(GL_UNPACK_ALIGNMENT, 1); gl. Gen. Textures(1, &tex. Name); gl. Bind.

make. Check. Images(); gl. Pixel. Storei(GL_UNPACK_ALIGNMENT, 1); gl. Gen. Textures(1, &tex. Name); gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_S, GL_REPEAT); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_T, GL_REPEAT); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl. Tex. Image 2 D(GL_TEXTURE_2 D, 0, GL_RGBA, check. Image. Width, check. Image. Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, check. Image); } 2010 -2학기 가상현실 28

void display(void) { gl. Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gl. Enable(GL_TEXTURE_2 D); gl. Tex. Envf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,

void display(void) { gl. Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gl. Enable(GL_TEXTURE_2 D); gl. Tex. Envf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name); gl. Begin(GL_QUADS); gl. Tex. Coord 2 f(0. 0, 0. 0); gl. Vertex 3 f(-2. 0, -1. 0, 0. 0); gl. Tex. Coord 2 f(0. 0, 1. 0); gl. Vertex 3 f(-2. 0, 1. 0, 0. 0); gl. Tex. Coord 2 f(1. 0, 1. 0); gl. Vertex 3 f(0. 0, 1. 0, 0. 0); gl. Tex. Coord 2 f(1. 0, 0. 0); gl. Vertex 3 f(0. 0, -1. 0, 0. 0); 2010 -2학기 가상현실 29

gl. Tex. Coord 2 f(0. 0, 0. 0); gl. Vertex 3 f(1. 0, -1.

gl. Tex. Coord 2 f(0. 0, 0. 0); gl. Vertex 3 f(1. 0, -1. 0, 0. 0); gl. Tex. Coord 2 f(0. 0, 1. 0); gl. Vertex 3 f(1. 0, 0. 0); gl. Tex. Coord 2 f(1. 0, 1. 0); gl. Vertex 3 f(2. 41421, 1. 0, -1. 41421); gl. Tex. Coord 2 f(1. 0, 0. 0); gl. Vertex 3 f(2. 41421, -1. 0, -1. 41421); gl. End(); gl. Flush(); gl. Disable(GL_TEXTURE_2 D); } void reshape(int w, int h) { gl. Viewport(0, 0, (GLsizei) w, (GLsizei) h); gl. Matrix. Mode(GL_PROJECTION); gl. Load. Identity(); 2010 -2학기 가상현실 30

glu. Perspective(60. 0, (GLfloat) w/(GLfloat) h, 1. 0, 30. 0); gl. Matrix. Mode(GL_MODELVIEW); gl.

glu. Perspective(60. 0, (GLfloat) w/(GLfloat) h, 1. 0, 30. 0); gl. Matrix. Mode(GL_MODELVIEW); gl. Load. Identity(); gl. Translatef(0. 0, -3. 6); } void keyboard (unsigned char key, int x, int y){ switch (key) { case 's': case 'S': gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name); gl. Tex. Sub. Image 2 D(GL_TEXTURE_2 D, 0, 12, 44, sub. Image. Width, sub. Image. Height, GL_RGBA, GL_UNSIGNED_BYTE, sub. Image); glut. Post. Redisplay(); break; 2010 -2학기 가상현실 31

case 'r': case 'R': gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name); gl. Tex. Image 2

case 'r': case 'R': gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name); gl. Tex. Image 2 D(GL_TEXTURE_2 D, 0, GL_RGBA, check. Image. Width, check. Image. Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, check. Image); glut. Post. Redisplay(); break; case 27: exit(0); break; default: break; } } 2010 -2학기 가상현실 32

int main(int argc, char** argv) { glut. Init(&argc, argv); glut. Init. Display. Mode(GLUT_SINGLE |

int main(int argc, char** argv) { glut. Init(&argc, argv); glut. Init. Display. Mode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glut. Init. Window. Size(250, 250); glut. Init. Window. Position(100, 100); glut. Create. Window(argv[0]); init(); glut. Display. Func(display); glut. Reshape. Func(reshape); glut. Keyboard. Func(keyboard); glut. Main. Loop(); return 0; } 2010 -2학기 가상현실 33

#else int main(int argc, char** argv) { fprintf (stderr, "This program demonstrates a feature

#else int main(int argc, char** argv) { fprintf (stderr, "This program demonstrates a feature which is not in Open. GL Version 1. 0. n"); fprintf (stderr, "If your implementation of Open. GL Version 1. 0 has the right extensions, n"); fprintf (stderr, "you may be able to modify this program to make it run. n"); return 0; } #endif 2010 -2학기 가상현실 34

void gl. Tex. Image 3 D(GLenum target, GLint level, GLint internal. Format, GLsizei width,

void gl. Tex. Image 3 D(GLenum target, GLint level, GLint internal. Format, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *texels) l l l 3차원 텍스처 정의 모든 변수는 gl. Tex. Image 2 D() 와 같은 의미로 사용되나 텍셀은 3 차원 배열이고 depth 변수가 추가. Depth 값은 2 m(테두리가 있 을 경우엔 2 m+1) 사용자는 밉맵과 프록시를 공급할 수 있으며, 동일한 필터링 옵 션이 가능 2010 -2학기 가상현실 42

3차원 텍스처의 전체 또는 부분을 대체하려면 gl. Tex. Sub. Image 3 D() 를 사용

3차원 텍스처의 전체 또는 부분을 대체하려면 gl. Tex. Sub. Image 3 D() 를 사용 void gl. Tex. Sub. Image 3 D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *texels); l l l 현존하는 3차원 텍스처 이미지를 대체하는 3차원 텍스처 배열을 정의 target 변수는 GL_TEXTURE_3 D로 해야 함 level, format, type : gl. Tex. Image 3 D() 에서 사용된 것과 같다. 2010 -2학기 가상현실 43

*IMAGE_HEIGHT 픽셀 저장 모드 Subimage In layer 1 *ROW_LENGTH Subimage Height *SKIP_PIXELS In layer

*IMAGE_HEIGHT 픽셀 저장 모드 Subimage In layer 1 *ROW_LENGTH Subimage Height *SKIP_PIXELS In layer 0 *SKIP_ROWS *IMAGE_ HEIGHT layer 1 layer 0 2010 -2학기 가상현실 47

예제 9 -5 밉맵 텍스처: mipmap. c #include <GL/glut. h> #include <stdlib. h> GLubyte

예제 9 -5 밉맵 텍스처: mipmap. c #include <GL/glut. h> #include <stdlib. h> GLubyte GLubyte mipmap. Image 32[32][4]; mipmap. Image 16[16][4]; mipmap. Image 8[8][8][4]; mipmap. Image 4[4][4][4]; mipmap. Image 2[2][2][4]; mipmap. Image 1[1][1][4]; #ifdef GL_VERSION_1_1 static GLuint tex. Name; #endif 2010 -2학기 가상현실 49

void make. Images(void) { int i, j; for (i = 0; i < 32;

void make. Images(void) { int i, j; for (i = 0; i < 32; i++) { for (j = 0; j < 32; j++) { mipmap. Image 32[i][j][0] mipmap. Image 32[i][j][1] mipmap. Image 32[i][j][2] mipmap. Image 32[i][j][3] } } 2010 -2학기 = = 255; 0; 255; 가상현실 50

for (i = 0; i < 16; i++) { for (j = 0; j

for (i = 0; i < 16; i++) { for (j = 0; j < 16; j++) { mipmap. Image 16[i][j][0] = 255; mipmap. Image 16[i][j][1] = 0; mipmap. Image 16[i][j][2] = 255; mipmap. Image 16[i][j][3] = 255; } for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { mipmap. Image 8[i][j][0] = 255; mipmap. Image 8[i][j][1] = 0; mipmap. Image 8[i][j][2] = 0; mipmap. Image 8[i][j][3] = 255; } } 2010 -2학기 가상현실 } 51

for (i = 0; i < 4; i++) { for (j = 0; j

for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { mipmap. Image 4[i][j][0] mipmap. Image 4[i][j][1] mipmap. Image 4[i][j][2] mipmap. Image 4[i][j][3] } for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { mipmap. Image 2[i][j][0] mipmap. Image 2[i][j][1] mipmap. Image 2[i][j][2] mipmap. Image 2[i][j][3] } } 2010 -2학기 = = 0; 255; = = 0; 0; 255; 가상현실 } 52

mipmap. Image 1[0][0][0] mipmap. Image 1[0][0][1] mipmap. Image 1[0][0][2] mipmap. Image 1[0][0][3] = =

mipmap. Image 1[0][0][0] mipmap. Image 1[0][0][1] mipmap. Image 1[0][0][2] mipmap. Image 1[0][0][3] = = 255; } void init(void) { gl. Enable(GL_DEPTH_TEST); gl. Shade. Model(GL_FLAT); gl. Translatef(0. 0, -3. 6); make. Images(); gl. Pixel. Storei(GL_UNPACK_ALIGNMENT, 1); 2010 -2학기 가상현실 53

ifdef GL_VERSION_1_1 gl. Gen. Textures(1, &tex. Name); gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name); #endif

ifdef GL_VERSION_1_1 gl. Gen. Textures(1, &tex. Name); gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name); #endif gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_S, GL_REPEAT); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_T, GL_REPEAT); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); gl. Tex. Image 2 D(GL_TEXTURE_2 D, 0, GL_RGBA, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmap. Image 32); 2010 -2학기 가상현실 54

gl. Tex. Image 2 D(GL_TEXTURE_2 D, 1, GL_RGBA, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmap. Image

gl. Tex. Image 2 D(GL_TEXTURE_2 D, 1, GL_RGBA, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmap. Image 16); gl. Tex. Image 2 D(GL_TEXTURE_2 D, 2, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmap. Image 8); gl. Tex. Image 2 D(GL_TEXTURE_2 D, 3, GL_RGBA, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmap. Image 4); gl. Tex. Image 2 D(GL_TEXTURE_2 D, 4, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmap. Image 2); gl. Tex. Image 2 D(GL_TEXTURE_2 D, 5, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, mipmap. Image 1); gl. Tex. Envf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); gl. Enable(GL_TEXTURE_2 D); } 2010 -2학기 가상현실 55

void display(void) { gl. Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); #ifdef GL_VERSION_1_1 gl. Bind. Texture(GL_TEXTURE_2 D, tex.

void display(void) { gl. Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); #ifdef GL_VERSION_1_1 gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name); #endif gl. Begin(GL_QUADS); gl. Tex. Coord 2 f(0. 0, 0. 0); gl. Vertex 3 f(-2. 0, -1. 0, 0. 0); gl. Tex. Coord 2 f(0. 0, 8. 0); gl. Vertex 3 f(-2. 0, 1. 0, 0. 0); gl. Tex. Coord 2 f(8. 0, 8. 0); gl. Vertex 3 f(2000. 0, 1. 0, -6000. 0); gl. Tex. Coord 2 f(8. 0, 0. 0); gl. Vertex 3 f(2000. 0, -1. 0, -6000. 0); gl. End(); gl. Flush(); } 2010 -2학기 가상현실 56

void reshape(int w, int h){ gl. Viewport(0, 0, (GLsizei) w, (GLsizei) h); gl. Matrix.

void reshape(int w, int h){ gl. Viewport(0, 0, (GLsizei) w, (GLsizei) h); gl. Matrix. Mode(GL_PROJECTION); gl. Load. Identity(); glu. Perspective(60. 0, (GLfloat)w/(GLfloat)h, 1. 0, 30000. 0); gl. Matrix. Mode(GL_MODELVIEW); gl. Load. Identity(); } void keyboard (unsigned char key, int x, int y) { switch (key) { case 27: exit(0); break; default: break; } } 2010 -2학기 가상현실 57

int main(int argc, char** argv) { glut. Init(&argc, argv); glut. Init. Display. Mode (GLUT_SINGLE

int main(int argc, char** argv) { glut. Init(&argc, argv); glut. Init. Display. Mode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glut. Init. Window. Size (500, 500); glut. Init. Window. Position (50, 50); glut. Create. Window (argv[0]); init (); glut. Display. Func(display); glut. Reshape. Func(reshape); glut. Keyboard. Func(keyboard); glut. Main. Loop(); return 0; } 2010 -2학기 가상현실 58

자동화된 밉맵 생성 만약 레벨 0이나 그 이상 최고 해상도의 맵을 만들었다고 가정한다면 glu.

자동화된 밉맵 생성 만약 레벨 0이나 그 이상 최고 해상도의 맵을 만들었다고 가정한다면 glu. Build. D 1 Mipmaps(), glu. Build 2 DMipmaps(), glu. Build 3 DMipmaps() 루틴 은 1 * 1 해상도로 감소하는 피라미드 형태의 밉맵을 만들고 정의 int glu. Build 1 DMipmaps(GLenum target, GLint internal. Format, GLint width, GLenum format, GLenum type, void *texels); int glu. Build 2 DMipmaps(GLenum target, GLint internal. Format, GLint width, GLenum height, GLenum format, GLenum type, void *texels); int glu. Build 3 DMipmpas(GLenum target, GLint internal. Format, GLint width, GLenum height, GLenum depth, GLenum format, GLenum type, void *texels); 일련의 밉맵을 만들고 이미지를 읽기 위해서 gl. Tex. Image*D()를 호출한다. 모든 밉맵들이 성공적으로 만들어지면 0값을 반환하고 실패시 GLU 에러코 드 반환 2010 -2학기 가상현실 60

세부적 제어의 밉맵 레벨 MIN_LOD와 MAX_LOD는 밉맵 축소의 값( , 텍스처 이미지에 폴리 곤으로의

세부적 제어의 밉맵 레벨 MIN_LOD와 MAX_LOD는 밉맵 축소의 값( , 텍스처 이미지에 폴리 곤으로의 스케일 인자)의 최대, 최소값을 제공 BASE_LEVEL과 MAX_LEVEL을 사용하여 gl. Tex. Parameter*()는 MIN_LOD와 MAX_LOD를 설정 l l gl. Tex. Parameterf(GL_TEXTURE_2 D, GL_TEXTURE_MIN_LOD, 2. 5); gl. Tex. Parameterf(GL_TEXTURE_2 D, GL_TEXTURE_MAX_LOD, 4. 5); 2010 -2학기 가상현실 64

자동화된 밉맵 부분 집합 생성 밉맵 레벨의 발전된 제어를 통해 glu. Build*DMipmaps()로정의된 밉맵의 부

자동화된 밉맵 부분 집합 생성 밉맵 레벨의 발전된 제어를 통해 glu. Build*DMipmaps()로정의된 밉맵의 부 분 집합을 만들 필요가 있다. 밉멥 레벨들의 부분집합의 계산과 읽기를 위하여 glu. Build*DMipmap. Levels()를 호출 l int glu. Build 1 DMipmap. Levels(GLenum target, GLint internal. Format, GLint width, GLenum format, GLenum type, GLint level, GLint base, GLint max, void *texels); l int glu. Build 2 DMipmap. Levels(GLenum target, GLint internal. Format, GLint width, Glint height, GLenum format, GLenum type, GLint level, GLint base, GLint max, void *texels); l int glu. Build 3 DMipmap. Levels(GLenum target, GLint internal. Format, GLint width, Glint height, GLint depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, void *texels); 2010 -2학기 가상현실 65

확대와 축소를 위한 필터링 방법 매개변수 값 GL_TEXTURE_MAG_FLITER GL_NEAREST 또는 GL_LINEAR GL_TEXTURE_MIN_FILTER GL_NEAREST, GL_LINEAR,

확대와 축소를 위한 필터링 방법 매개변수 값 GL_TEXTURE_MAG_FLITER GL_NEAREST 또는 GL_LINEAR GL_TEXTURE_MIN_FILTER GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR GL_NEAREST(최근점법): 픽셀의 중심에 가까운 좌표를 가지는 텍셀이 확 대와 축소를 위해 사용 GL_LINEAR(보간법): 픽셀의 중심에 가까이 위치한 텍셀의 2 x 2배열의 조정 된 선형 평균 사용 GL_NEAREST_MIPMAP_NEAREST: 각각의 밉맵내에서 가장 가까운 텍셀값 을 선택 GL_NEAREST_MIPMAP_LINEAR: 각각의 밉맵 내에서 선형적으로 보간 2010 -2학기 가상현실 67

예제 9 -7 텍스처 오브젝트 바인딩: texbind. c #include <GL/glut. h> #include <stdlib. h>

예제 9 -7 텍스처 오브젝트 바인딩: texbind. c #include <GL/glut. h> #include <stdlib. h> #include <stdio. h> #ifdef GL_VERSION_1_1 #define check. Image. Width 64 #define check. Image. Height 64 static GLubyte check. Image[check. Image. Height][check. Image. Width][4]; static GLubyte other. Image[check. Image. Height][check. Image. Width][4]; static GLuint tex. Name[2]; 2010 -2학기 가상현실 73

void make. Check. Images(void) { int i, j, c; for (i = 0; i

void make. Check. Images(void) { int i, j, c; for (i = 0; i < check. Image. Height; i++) { for (j = 0; j < check. Image. Width; j++) { c = ((((i&0 x 8)==0)^((j&0 x 8))==0))*255; check. Image[i][j][0] = (GLubyte) c; check. Image[i][j][1] = (GLubyte) c; check. Image[i][j][2] = (GLubyte) c; check. Image[i][j][3] = (GLubyte) 255; c = ((((i&0 x 10)==0)^((j&0 x 10))==0))*255; 2010 -2학기 가상현실 74

other. Image[i][j][0] other. Image[i][j][1] other. Image[i][j][2] other. Image[i][j][3] = = (GLubyte) c; 0; 0;

other. Image[i][j][0] other. Image[i][j][1] other. Image[i][j][2] other. Image[i][j][3] = = (GLubyte) c; 0; 0; 255; } } } void init(void) { gl. Clear. Color (0. 0, 0. 0); gl. Shade. Model(GL_FLAT); gl. Enable(GL_DEPTH_TEST); 2010 -2학기 가상현실 75

make. Check. Images(); gl. Pixel. Storei(GL_UNPACK_ALIGNMENT, 1); gl. Gen. Textures(2, tex. Name); gl. Bind.

make. Check. Images(); gl. Pixel. Storei(GL_UNPACK_ALIGNMENT, 1); gl. Gen. Textures(2, tex. Name); gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name[0]); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_S, GL_CLAMP); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_T, GL_CLAMP); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl. Tex. Image 2 D(GL_TEXTURE_2 D, 0, GL_RGBA, check. Image. Width, check. Image. Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, check. Image); 2010 -2학기 가상현실 76

gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name[1]); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_S, GL_CLAMP); gl. Tex.

gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name[1]); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_S, GL_CLAMP); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_T, GL_CLAMP); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl. Tex. Envf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); gl. Tex. Image 2 D(GL_TEXTURE_2 D, 0, GL_RGBA, check. Image. Width, check. Image. Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, other. Image); gl. Enable(GL_TEXTURE_2 D); } 2010 -2학기 가상현실 77

void display(void) { gl. Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name[0]); gl.

void display(void) { gl. Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name[0]); gl. Begin(GL_QUADS); gl. Tex. Coord 2 f(0. 0, 0. 0); gl. Vertex 3 f(-2. 0, -1. 0, 0. 0); gl. Tex. Coord 2 f(0. 0, 1. 0); gl. Vertex 3 f(-2. 0, 1. 0, 0. 0); gl. Tex. Coord 2 f(1. 0, 1. 0); gl. Vertex 3 f(0. 0, 1. 0, 0. 0); gl. Tex. Coord 2 f(1. 0, 0. 0); gl. Vertex 3 f(0. 0, -1. 0, 0. 0); gl. End(); 2010 -2학기 가상현실 78

gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name[1]); gl. Begin(GL_QUADS); gl. Tex. Coord 2 f(0. 0,

gl. Bind. Texture(GL_TEXTURE_2 D, tex. Name[1]); gl. Begin(GL_QUADS); gl. Tex. Coord 2 f(0. 0, 0. 0); gl. Vertex 3 f(1. 0, -1. 0, 0. 0); gl. Tex. Coord 2 f(0. 0, 1. 0); gl. Vertex 3 f(1. 0, 0. 0); gl. Tex. Coord 2 f(1. 0, 1. 0); gl. Vertex 3 f(2. 41421, 1. 0, -1. 41421); gl. Tex. Coord 2 f(1. 0, 0. 0); gl. Vertex 3 f(2. 41421, -1. 0, -1. 41421); gl. End(); gl. Flush(); } void reshape(int w, int h) { gl. Viewport(0, 0, (GLsizei) w, (GLsizei) h); gl. Matrix. Mode(GL_PROJECTION); 2010 -2학기 가상현실 79

gl. Load. Identity(); glu. Perspective(60. 0, (GLfloat) w/(GLfloat) h, 1. 0, 30. 0); gl.

gl. Load. Identity(); glu. Perspective(60. 0, (GLfloat) w/(GLfloat) h, 1. 0, 30. 0); gl. Matrix. Mode(GL_MODELVIEW); gl. Load. Identity(); gl. Translatef(0. 0, -3. 6); } void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: exit(0); break; } } 2010 -2학기 가상현실 80

int main(int argc, char** argv) { glut. Init(&argc, argv); glut. Init. Display. Mode(GLUT_SINGLE |

int main(int argc, char** argv) { glut. Init(&argc, argv); glut. Init. Display. Mode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glut. Init. Window. Size(250, 250); glut. Init. Window. Position(100, 100); glut. Create. Window(argv[0]); init(); glut. Reshape. Func(reshape); glut. Display. Func(display); glut. Keyboard. Func (keyboard); glut. Main. Loop(); return 0; } 2010 -2학기 가상현실 81

#else int main(int argc, char** argv) { fprintf (stderr, "This program demonstrates a feature

#else int main(int argc, char** argv) { fprintf (stderr, "This program demonstrates a feature which is not in Open. GL Version 1. 0. n"); fprintf (stderr, "If your implementation of Open. GL Version 1. 0 has the right extensions, n"); fprintf (stderr, "you may be able to modify this program to make it run. n"); return 0; } #endif 2010 -2학기 가상현실 82

S: source, f: fragment l 텍스처의 교체와 변조 함수 (GL_REPLACE, GL_MODULATE) 베이스 내부 형식

S: source, f: fragment l 텍스처의 교체와 변조 함수 (GL_REPLACE, GL_MODULATE) 베이스 내부 형식 텍스처 교체 함 텍스처 변조 함 수 수 GL_DECAL GL_ALPHA C = Cf A = As C = Cf A = Af. As 정의되지 않음 GL_LUMINANCE C = Cs A = Af C = Cf. Ls A = As 정의되지 않음 GL_ALUMINANCE _ALPHA C = Cs C = Af C = Cf. Ls A = Af. As 정의되지 않음 GL_INTENSITY C = Cs A = If C = Cf. Ls A = Af. Is 정의되지 않음 GL_RGB C = Cs A = Af C = Cf. Cs A = As C = Cs A = Af GL_RGBA C = Cs A = Af C = Cf. Cs A = Af. As C = Cf(1 -As)+Cs. As A = Af 2010 -2학기 가상현실 88

c: GL_TEXTURE_ENV_COLOR l 텍스처의 전사와 블렌딩 함수 (GL_BLEND, GL_ADD) 베이스 내부 형식 GL_BLEND 함수

c: GL_TEXTURE_ENV_COLOR l 텍스처의 전사와 블렌딩 함수 (GL_BLEND, GL_ADD) 베이스 내부 형식 GL_BLEND 함수 GL_ADD 함수 GL_ALPHA C = Ct A = Af. As C = Cf A = Af. As GL_LUMINANCE C=Cf(1 -Cs)+Cc. Cs A = Af C = Cf + Cs A = Af GL_LUMINANCE_A LPHA C=Cf(1 -Cs)+Cc. Cs A = Af. As C = Cf + Cs A = Af. As GL_INTENSITY C=Cf(1 -Cs)+Cc. Cs A=Af(1 -As)+Ac. As C = Cf + Cs A = Af + As GL_RGB C=Cf(1 -Cs)+Cc. Cs A = Af C = Cf + Cs A = Af GL_RGBA C=Cf(1 -Cs)+Cc. Cs A = Af. As C = Cf + Cs A = Af. As 2010 -2학기 가상현실 89

예제: 9 -1에서 gl. Begin(GL_QUADS); gl. Tex. Coord 2 f(0. 0, gl. Tex. Coord

예제: 9 -1에서 gl. Begin(GL_QUADS); gl. Tex. Coord 2 f(0. 0, gl. Tex. Coord 2 f(3. 0, gl. End(); 2010 -2학기 0. 0); 3. 0); 0. 0); gl. Vertex 3 f(-2. 0, -1. 0, 0. 0); gl. Vertex 3 f(-2. 0, 1. 0, 0. 0); gl. Vertex 3 f(0. 0, -1. 0, 0. 0); 3. 0); 0. 0); gl. Vertex 3 f(1. 0, -1. 0, 0. 0); gl. Vertex 3 f(1. 0, 0. 0); gl. Vertex 3 f(2. 41421, 1. 0, -1. 41421); gl. Vertex 3 f(2. 41421, -1. 0, -1. 41421); 가상현실 94

GL_REPEAT 래핑의 결과 gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_S, GL_REPEAT); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_T,

GL_REPEAT 래핑의 결과 gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_S, GL_REPEAT); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_T, GL_REPEAT); 2010 -2학기 가상현실 95

GL_CLAMP 래핑의 결과 gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_S, GL_CLAMP); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_T,

GL_CLAMP 래핑의 결과 gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_S, GL_CLAMP); gl. Tex. Parameteri(GL_TEXTURE_2 D, GL_TEXTURE_WRAP_T, GL_CLAMP); 2010 -2학기 가상현실 96

gl. Tex. Parameter*() 매개변수들 매개변수 변수들 GL_TEXTURE_WRAP_S GL_CLAMP, GL_CLAMP_TO_EDGE, GL_REPEAT GL_TEXTURE_WRAP_T GL_CLAMP, GL_CLAMP_TO_EDGE, GL_REPEAT

gl. Tex. Parameter*() 매개변수들 매개변수 변수들 GL_TEXTURE_WRAP_S GL_CLAMP, GL_CLAMP_TO_EDGE, GL_REPEAT GL_TEXTURE_WRAP_T GL_CLAMP, GL_CLAMP_TO_EDGE, GL_REPEAT GL_TEXTURE_WRAP_R GL_CLAMP, GL_CLAMP_TO_EDGE, GL_REPEAT GL_TEXTURE_MAG_FILTER GL_CLAMP, GL_LINEAR GL_TEXTURE_MIN_FILTER GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GLLINEAR_MIPMAP_NEAREST, GL_LINER_MIPMAP_LINEAR 2010 -2학기 가상현실 97

텍스처 좌표 자동으로 산출하기 모델의 윤곽을 그리거나, 임의의 빛나는 모델의 환경에서 도출되는 반사를 가짜로

텍스처 좌표 자동으로 산출하기 모델의 윤곽을 그리거나, 임의의 빛나는 모델의 환경에서 도출되는 반사를 가짜로 표현하기 위해 텍스처 매핑을 사용 가능 l gl. Texture. Coord*() 보다는 Open. GL이 자동으로 텍스처 좌표를 산출하도록 한다. void gl. Tex. Gen{ifd}(GLenum coord, GLenum pname, TYPE param); void gl. Tex. Gen{idf}v(GLenum coord, GLenum pname, TYPE *param); l l l 첫 번째 매개변수 coord는 텍스처 좌표가 산출되는지를 지시하 기 위해 GL_S, GL_T, GL_R, GL_Q 사용 pname은 GL_TEXTURE_GEN_MODE, GL_OBJECT_PLANE, GL_EYE_PLANE param은 GL_OBJECT_LINEAR, GL_EYE_LINEAR, GL_SPHERE_LINEAR 2010 -2학기 가상현실 99

예제 9 -8 자동 텍스처 좌표 생성: texgen. c #include <GL/glut. h> #include <stdlib.

예제 9 -8 자동 텍스처 좌표 생성: texgen. c #include <GL/glut. h> #include <stdlib. h> #include <stdio. h> #define stripe. Image. Width 32 GLubyte stripe. Image[4*stripe. Image. Width]; #ifdef GL_VERSION_1_1 static GLuint tex. Name; #endif 2010 -2학기 가상현실 103

void make. Stripe. Image(void){ int j; for (j = 0; j < stripe. Image.

void make. Stripe. Image(void){ int j; for (j = 0; j < stripe. Image. Width; j++) { stripe. Image[4*j] = (GLubyte) ((j<=4) ? 255 : 0); stripe. Image[4*j+1] = (GLubyte) ((j>4) ? 255 : 0); stripe. Image[4*j+2] = (GLubyte) 0; stripe. Image[4*j+3] = (GLubyte) 255; } } static GLfloat xequalzero[] = {1. 0, 0. 0}; static GLfloat slanted[] = {1. 0, 0. 0}; static GLfloat *current. Coeff; 2010 -2학기 가상현실 104

static GLenum current. Plane; static GLint current. Gen. Mode; void init(void) { gl. Clear.

static GLenum current. Plane; static GLint current. Gen. Mode; void init(void) { gl. Clear. Color (0. 0, 0. 0); gl. Enable(GL_DEPTH_TEST); gl. Shade. Model(GL_SMOOTH); make. Stripe. Image(); gl. Pixel. Storei(GL_UNPACK_ALIGNMENT, 1); #ifdef GL_VERSION_1_1 gl. Gen. Textures(1, &tex. Name); gl. Bind. Texture(GL_TEXTURE_1 D, tex. Name); 2010 -2학기 가상현실 105

#endif gl. Tex. Parameteri(GL_TEXTURE_1 D, GL_TEXTURE_WRAP_S, GL_REPEAT); gl. Tex. Parameteri(GL_TEXTURE_1 D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl.

#endif gl. Tex. Parameteri(GL_TEXTURE_1 D, GL_TEXTURE_WRAP_S, GL_REPEAT); gl. Tex. Parameteri(GL_TEXTURE_1 D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl. Tex. Parameteri(GL_TEXTURE_1 D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); #ifdef GL_VERSION_1_1 gl. Tex. Image 1 D(GL_TEXTURE_1 D, 0, GL_RGBA, stripe. Image. Width, 0, GL_RGBA, GL_UNSIGNED_BYTE, stripe. Image); #else gl. Tex. Image 1 D(GL_TEXTURE_1 D, 0, 4, stripe. Image. Width, 0, GL_RGBA, GL_UNSIGNED_BYTE, stripe. Image); #endif 2010 -2학기 가상현실 106

gl. Tex. Envf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); current. Coeff = xequalzero; current. Gen. Mode = GL_OBJECT_LINEAR;

gl. Tex. Envf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); current. Coeff = xequalzero; current. Gen. Mode = GL_OBJECT_LINEAR; current. Plane = GL_OBJECT_PLANE; gl. Tex. Geni(GL_S, GL_TEXTURE_GEN_MODE, current. Gen. Mode); gl. Tex. Genfv(GL_S, current. Plane, current. Coeff); gl. Enable(GL_TEXTURE_GEN_S); gl. Enable(GL_TEXTURE_1 D); gl. Enable(GL_CULL_FACE); gl. Enable(GL_LIGHTING); gl. Enable(GL_LIGHT 0); gl. Enable(GL_AUTO_NORMAL); 2010 -2학기 가상현실 107

gl. Enable(GL_NORMALIZE); gl. Front. Face(GL_CW); gl. Cull. Face(GL_BACK); gl. Materialf (GL_FRONT, GL_SHININESS, 64. 0);

gl. Enable(GL_NORMALIZE); gl. Front. Face(GL_CW); gl. Cull. Face(GL_BACK); gl. Materialf (GL_FRONT, GL_SHININESS, 64. 0); } void display(void) { gl. Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gl. Push. Matrix (); gl. Rotatef(45. 0, 0. 0, 1. 0); 2010 -2학기 가상현실 108

#ifdef GL_VERSION_1_1 gl. Bind. Texture(GL_TEXTURE_1 D, tex. Name); #endif glut. Solid. Teapot(2. 0); gl.

#ifdef GL_VERSION_1_1 gl. Bind. Texture(GL_TEXTURE_1 D, tex. Name); #endif glut. Solid. Teapot(2. 0); gl. Pop. Matrix (); gl. Flush(); } void reshape(int w, int h) { gl. Viewport(0, 0, (GLsizei) w, (GLsizei) h); gl. Matrix. Mode(GL_PROJECTION); gl. Load. Identity(); 2010 -2학기 가상현실 109

if (w <= h) gl. Ortho (-3. 5, -3. 5*(GLfloat)h/(GLfloat)w, -3. 5, 3. 5);

if (w <= h) gl. Ortho (-3. 5, -3. 5*(GLfloat)h/(GLfloat)w, -3. 5, 3. 5); else gl. Ortho (-3. 5*(GLfloat)w/(GLfloat)h, -3. 5, 3. 5); gl. Matrix. Mode(GL_MODELVIEW); gl. Load. Identity(); } 2010 -2학기 가상현실 110

void keyboard (unsigned char key, int x, int y) { switch (key) { case

void keyboard (unsigned char key, int x, int y) { switch (key) { case 'e': case 'E': current. Gen. Mode = GL_EYE_LINEAR; current. Plane = GL_EYE_PLANE; gl. Tex. Geni(GL_S, GL_TEXTURE_GEN_MODE, current. Gen. Mode); gl. Tex. Genfv(GL_S, current. Plane, current. Coeff); glut. Post. Redisplay(); break; 2010 -2학기 가상현실 111

case 'o': case 'O': current. Gen. Mode = GL_OBJECT_LINEAR; current. Plane = GL_OBJECT_PLANE; gl.

case 'o': case 'O': current. Gen. Mode = GL_OBJECT_LINEAR; current. Plane = GL_OBJECT_PLANE; gl. Tex. Geni(GL_S, GL_TEXTURE_GEN_MODE, current. Gen. Mode); gl. Tex. Genfv(GL_S, current. Plane, current. Coeff); glut. Post. Redisplay(); break; case 's': case 'S': current. Coeff = slanted; gl. Tex. Genfv(GL_S, current. Plane, current. Coeff); glut. Post. Redisplay(); break; 2010 -2학기 가상현실 112

case 'x': case 'X': current. Coeff = xequalzero; gl. Tex. Genfv(GL_S, current. Plane, current.

case 'x': case 'X': current. Coeff = xequalzero; gl. Tex. Genfv(GL_S, current. Plane, current. Coeff); glut. Post. Redisplay(); break; case 27: exit(0); break; default: break; } } 2010 -2학기 가상현실 113

int main(int argc, char** argv) { glut. Init(&argc, argv); glut. Init. Display. Mode (GLUT_SINGLE

int main(int argc, char** argv) { glut. Init(&argc, argv); glut. Init. Display. Mode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glut. Init. Window. Size(256, 256); glut. Init. Window. Position(100, 100); glut. Create. Window (argv[0]); init (); glut. Display. Func(display); glut. Reshape. Func(reshape); glut. Keyboard. Func(keyboard); glut. Main. Loop(); return 0; } 2010 -2학기 가상현실 114