Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //THIS IS THE DRAW METHOD, THIS IS CALLED ABOUT 60 TIMES A SECOND
- - (void)drawView:(OpenGLCoreView*)view
- {
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- glLoadIdentity();
- float tempX = [glView xCoord];
- float tempY = [glView yCoord];
- if ([glView touchDown])
- {
- [self moveBallToTouchCoordinates:tempX :tempY];
- }
- else
- {
- allowDrag = NO;
- }
- [self drawBall:ballXCoord :ballYCoord];
- [self drawGLLine:200 :100 :200 :200: 1.0: 0.0: 0.0: 1.0];
- }
- //This method draws a ball to the screen
- -(void)drawBall: (float)xCoordinate: (float)yCoordinate
- {
- glTranslatef(xCoordinate, yCoordinate, 0.0);
- glVertexPointer(2, GL_FLOAT, 0, ballVerticies);
- glTexCoordPointer(2, GL_FLOAT, 0, ballTextureCoordinates);
- glBindTexture(GL_TEXTURE_2D, ballImageTexture);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- }
- //This method draws a line to the screen with X,Y,X2, and Y2 coordinates, and R G B A for color
- -(void)drawGLLine:(float)x:(float)y:(float)x2:(float)y2:(float)red:(float)green:(float)blue:(float)alpha
- {
- glLoadIdentity();
- glDisable(GL_TEXTURE_2D);
- GLfloat line[] = {
- x, y,
- x2, y2,
- };
- glColor4f(red,green,blue,alpha); //line color
- glVertexPointer(2, GL_FLOAT, 0, line);
- glEnableClientState(GL_VERTEX_ARRAY);
- glDrawArrays(GL_LINES, 0, 2);
- glEnable(GL_TEXTURE_2D);
- glColor4f(1.0f,1.0f,1.0f,1.0f); //line color
- }
Add Comment
Please, Sign In to add comment