메뉴 건너뛰기

app

[xcode] openGL을 이용한 계단 그리기

박영식2009.11.16 18:46조회 수 6994댓글 4

  • 5
    • 글자 크기


- (void)draw 

{


glLoadIdentity();


glClearColor(1.0f, 1.0f, 1.0f, 1.0f);

glClear(GL_COLOR_BUFFER_BIT);

CGColorRef color = currentColor.CGColor;

const CGFloat *components = CGColorGetComponents(color);

CGFloat red = components[0];

CGFloat green = components[1];

CGFloat blue = components[2];

glColor4f(red,green, blue, 1.0);

switch (shapeType) {

case kLineShape: {

if (sprite){

[sprite release];

self.sprite = nil;

}

GLfloat vertices[6];

// Convert coordinates

vertices[0] = 60.000000;//firstTouch.x;

vertices[1] = 150.000000;//self.frame.size.height - firstTouch.y;

vertices[2] = 60.000000;//lastTouch.x;

vertices[3] = 300.000000;//self.frame.size.height - lastTouch.y;

vertices[4] = 300.000000;

vertices[5] = 300.000000;

glLineWidth(2.0);

glVertexPointer (2, GL_FLOAT , 0, vertices);

glDrawArrays (GL_LINE_STRIP, 0, 3);

break;

}

case kRectShape:{

if (sprite){

[sprite release];

self.sprite = nil;

}

// Calculate bounding rect and store in vertices

GLfloat vertices[10];

vertices[0] = 50;

vertices[1] = 150;

vertices[2] = 50;

vertices[3] = 200;

vertices[4] = 100;

vertices[5] = 200;

vertices[6] = 100;

vertices[7] = 250;

vertices[8] = 150;

vertices[9] = 250;

glVertexPointer (2, GL_FLOAT , 0, vertices);

glDrawArrays (GL_LINE_STRIP, 0, 5);

break;

}

case kEllipseShape: {

if (sprite){

[sprite release];

self.sprite = nil;

}

// Calculate bounding rect and store in vertices

GLfloat vertices[14];

vertices[0] = 50;

vertices[1] = 150;

vertices[2] = 50;

vertices[3] = 200;

vertices[4] = 100;

vertices[5] = 200;

vertices[6] = 100;

vertices[7] = 250;

vertices[8] = 150;

vertices[9] = 250;

vertices[10] = 150;

vertices[11] = 300;

vertices[12] = 200;

vertices[13] = 300;

glVertexPointer (2, GL_FLOAT , 0, vertices);

glDrawArrays (GL_LINE_STRIP, 0, 7);

break;

}

case kImageShape:

if (sprite == nil) {

[sprite release];

self.sprite = nil;

}

// Calculate bounding rect and store in vertices

GLfloat vertices[18];

vertices[0] = 50;

vertices[1] = 150;

vertices[2] = 50;

vertices[3] = 200;

vertices[4] = 100;

vertices[5] = 200;

vertices[6] = 100;

vertices[7] = 250;

vertices[8] = 150;

vertices[9] = 250;

vertices[10] = 150;

vertices[11] = 300;

vertices[12] = 200;

vertices[13] = 300;

vertices[14] = 200;

vertices[15] = 350;

vertices[16] = 250;

vertices[17] = 350;

glVertexPointer (2, GL_FLOAT , 0, vertices);

glDrawArrays (GL_LINE_STRIP, 0, 9);

break;

}

glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);

[context presentRenderbuffer:GL_RENDERBUFFER_OES];

}

박영식 (비회원)
  • 5
    • 글자 크기
[IOS] IOS 10.3.3 탈옥툴 Meridian(자오선) / Goblin (by lispro06) [oracle] 오라클 설치와 sudoers에 등록하기 (by 박영식)

댓글 달기

댓글 4
suritam9
2013.12.02 조회 3081
lispro06
2014.02.08 조회 3557
lispro06
2013.12.10 조회 2679
suritam9
2019.04.05 조회 109
suritam9
2019.03.07 조회 14
suritam9
2019.03.06 조회 19
이전 1 2 3 4 5 6 7 8 9 10... 14다음
첨부 (5)
1st.jpg
33.6KB / Download 41
4th.jpg
31.6KB / Download 26
3rd.jpg
33.5KB / Download 28
GLfun.zip
541.3KB / Download 51
2nd.jpg
33.2KB / Download 31
위로