Created
September 21, 2011 19:37
-
-
Save jarodl/1233071 to your computer and use it in GitHub Desktop.
CCDrawingPrimitives+ccDrawFillCircle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CCDrawingPrimitives+ccDrawFillCircle.h | |
// MindSnacks | |
// | |
// Created by Jarod L on 9/20/11. | |
// Copyright (c) 2011 MindSnacks. All rights reserved. | |
// | |
#import "CCDrawingPrimitives.h" | |
void ccDrawFillCircle( CGPoint center, float radius, float angle, NSUInteger segments); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CCDrawingPrimitives+ccDrawFillCircle.m | |
// MindSnacks | |
// | |
// Created by Jarod L on 9/20/11. | |
// Copyright (c) 2011 MindSnacks. All rights reserved. | |
// | |
#import "CCDrawingPrimitives+ccDrawFillCircle.h" | |
#import "ccTypes.h" | |
#import "ccMacros.h" | |
//#import "Platforms/CCGL.h" | |
void ccDrawFillCircle( CGPoint center, float radius, float angle, NSUInteger segments) | |
{ | |
const float coef = 2.0f * (float)M_PI/segments; | |
GLfloat *vertices = calloc( sizeof(GLfloat)*2*(segments+2), 1); | |
if( ! vertices ) | |
return; | |
for(NSUInteger i=0;i<=segments;i++) | |
{ | |
float rads = i*coef; | |
GLfloat j = radius * cosf(rads + angle) + center.x; | |
GLfloat k = radius * sinf(rads + angle) + center.y; | |
vertices[i*2] = j * CC_CONTENT_SCALE_FACTOR(); | |
vertices[i*2+1] =k * CC_CONTENT_SCALE_FACTOR(); | |
} | |
vertices[(segments+1)*2] = center.x * CC_CONTENT_SCALE_FACTOR(); | |
vertices[(segments+1)*2+1] = center.y * CC_CONTENT_SCALE_FACTOR(); | |
glDisableClientState(GL_TEXTURE_COORD_ARRAY); | |
glDisableClientState(GL_COLOR_ARRAY); | |
glDisable(GL_TEXTURE_2D); | |
glVertexPointer(2, GL_FLOAT, 0, vertices); | |
glBlendFunc(GL_ONE, GL_ZERO); | |
glDrawArrays(GL_TRIANGLE_FAN, 0, segments); | |
// restore default GL state | |
glEnableClientState(GL_TEXTURE_COORD_ARRAY); | |
glEnableClientState(GL_COLOR_ARRAY); | |
glEnable(GL_TEXTURE_2D); | |
} |
Weird. In the edit view they are all named the same thing (the filename without the +). When I changed them all to have + the extra two disappeared :S
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, I saw that. They're named different though,
CCDrawingPrimitives+ccDrawFillCircle
andCCDrawingPrimitivesccDrawFillCircle
might have something to do with it?