보관물

Archive for the ‘openGL ES’ Category

openGL

2월 17, 2011 댓글 남기기

2D graphics

  • Bitmaps : pixel에 대응하는 RGBA값으로 표현
    (확대/축소시 quality에 변화가 생김)
  • Vector : point와의 관계를 line, curve 등으로 표현
    (확대/축소시 quality에 변화가 상대적으로 적음)

Bitmaps

화면크기는 320 * 480 (iPhone 3GS기준)
320 * 480 bitmap image는 320 * 480 * 4(RGBA) = 614,400 byte를 사용 (비압축시)
참고로 iPad의 경우 화면크기가 768*1024 이므로 3,145,728 byte를 사용하게 됨

GL Function Naming Convention

“library” + “command” + “number of args” + “type of arg”
“library” + “command” +” type of arg”
“library” + “command”

ex) glColor3f (..)

gl : openGL library
Color : command
3 : number of args
f : type of arg

ex) glRectf (..)

gl : openGL library
Rect : command
f : type of arg

ex) glFlush ()

gl : openGL library
Flush : command

Draw Point

점 A1 (x1, y1, z1)을 그림.

glBegin (GL_POINTS);
glVertex3f (x1, y1, z1);
glEnd();

Draw Lines

점  A1 (x1, y1, z1)과 점 A2 (x2, y2, z2)를 끝점으로 하는 line을 그림.
또한 점 A3와 점 A4를 끝점으로 하는 line을 그림.

glBegin(GL_LINES);
glVertex3f (x1, y1, z1);
glVertex3f (x2, y2, z2);
glVertex3f (x3, y3, z3);
glVertex3f (x4, y4, z4);
glEnd();

그렇다면 선 A1A2, 선 A2A3, 선 A3A4를 연속으로 그리려면?

glBegin (GL_LINE_STRIP);

위의 예에서 GL_LINES를 GL_LINE_STRIP으로 변경하면 됨.

<<To be continued…>>

참조자료

Introduction to OpenGL and 3D Graphics

카테고리:openGL ES 태그:,