메뉴 건너뛰기

app

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

박영식2009.11.16 18:46조회 수 7069댓글 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
    • 글자 크기
[jsp] 한글 인코딩 처리 (by 박영식) [xcode] 한글 사용하기 NSUTF8StringEncoding (by 박영식)

댓글 달기

댓글 4
박영식
2011.02.18 조회 2373
박영식
2010.09.29 조회 4525
박영식
2010.09.09 조회 4604
박영식
2010.05.25 조회 3841
박영식
2010.01.14 조회 4748
이전 1 ... 3 4 5 6 7 8 9 10 11 12... 14다음
첨부 (5)
1st.jpg
33.6KB / Download 80
4th.jpg
31.6KB / Download 66
3rd.jpg
33.5KB / Download 71
GLfun.zip
541.3KB / Download 94
2nd.jpg
33.2KB / Download 71
위로