void test_refcount( Result **result ) { AQObj *obj = aqinit( aqalloc( &AQObjType )); ok( obj->type == &AQObjType, "is AQObjType" ); ok( obj->refCount == 1, "refCount is 1" ); aqfree( obj ); ok( 1, "aqfree exectued" ); obj = aqretain( aqinit( aqalloc( &AQObjType ))); ok( obj->refCount == 2, "refCount is 2" ); ok( aqrelease( aqrelease( obj )) == NULL, "returned NULL" ); }
void test_autorelease( Result **result ) { AQReleasePool *pool = aqinit( aqalloc( &AQReleasePoolType )); ok( pool != NULL, "pool created" ); AQObj *obj = aqretain( aqinit( aqalloc( &AQObjType ))); ok( aqautorelease( obj ) == obj, "returned obj" ); ok( aqrelease( pool ) == NULL, "freed pool" ); ok( obj->refCount == 1, "freed obj" ); aqrelease( obj ); AQReleasePool *toppool = aqinit( aqalloc( &AQReleasePoolType )); pool = AQReleasePool_create(); obj = aqretain( aqcreate( &AQObjType )); ok( aqrelease( toppool ) == NULL, "freed top pool" ); ok( obj->refCount == 1, "freed obj" ); aqrelease( obj ); }
SLAsteroidGroupView * SLAsteroidGroupView_init( SLAsteroidGroupView *self ) { memset( &self->asteroids, 0, sizeof(SLAsteroidGroupView) - sizeof(AQObj) ); self->asteroids = aqinit( aqalloc( &AQListType )); glGenBuffers( 1, &self->buffer ); return self; }
audioQueue::audioQueue() { aqinit(); }
void initWaterTest() { AQReleasePool *pool = aqinit( aqalloc( &AQReleasePoolType )); world = aqinit( aqalloc( &AQWorldType )); aqvec2 viewportSize = (aqvec2) { VIEWPORT_WIDTH_HEIGHT }; AQWorld_setAabb( world, (aqaabb) { viewportSize.y, viewportSize.x, 0, 0 }); gravity = (aqvec2) { 0, -0.01 / kFrameStep / kFrameStep }; printf( "gravity %f %f\n", gravity.x, gravity.y ); AQInput_setWorldFrame( viewportSize.y, viewportSize.x, 0, 0 ); // aq_input_setscreentoworld((aqbox){ 640, 640, 0, 0 }); for ( int i = 0; i < particle_count; ++i ) { AQParticle *particle = aqcreate( &AQParticleType ); particle->friction = 0.01; particle->correction = 0.5 + (float) rand() / RAND_MAX / 2.5; particle->position = (aqvec2) { rand() % (int) world->aabb.right, rand() % (int) world->aabb.top / 3 * 2 }; particle->lastPosition = particle->position; particle->radius = kParticleBaseSize + (float) rand() / RAND_MAX * kParticleSizeRange; particle->mass = M_PI * particle->radius * particle->radius; if ( rand() > RAND_MAX * 0.99 ) { // particle->radius += 10; particle->mass *= 1000; } AQWorld_addParticle( world, particle ); } flowLine = aqinit( aqalloc( &AQFlowLineType )); flowLine->radius = 20; flowLine->minPointDistance = 10; flowLine->force = 2.5 / kFrameStep / kFrameStep; AQFlowLine_addPoint( flowLine, (aqvec2) { 320, 80 }); AQFlowLine_addPoint( flowLine, (aqvec2) { 320, 100 }); AQFlowLine_addPoint( flowLine, (aqvec2) { 320, 120 }); AQFlowLine_createParticles( flowLine, world ); AQFlowLine_clearPoints( flowLine ); printf( "%p %p\n", flowLine->particles, AQList_at( flowLine->particles, 0 )); glClearColor(0, 0, 0, 0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); shader_program = glCreateProgram(); GLuint fragment = glCreateShader(GL_FRAGMENT_SHADER); compileShader(fragment, shader_fragment_text); glAttachShader(shader_program, fragment); GLuint vertex = glCreateShader(GL_VERTEX_SHADER); compileShader(vertex, shader_vertex_text); glAttachShader(shader_program, vertex); glLinkProgram(shader_program); GLint programStatus; glGetProgramiv(shader_program, GL_LINK_STATUS, &programStatus); if (programStatus == GL_FALSE) { printf("program failed compilation\n"); } glUseProgram(shader_program); positionAttribute = glGetAttribLocation(shader_program, "a_position"); glEnableVertexAttribArray(positionAttribute); colorAttribute = glGetAttribLocation(shader_program, "a_color"); glEnableVertexAttribArray(colorAttribute); GLint modelview_projection = glGetUniformLocation(shader_program, "modelview_projection"); matrixtAttribute = modelview_projection; GLfloat identity[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; glUniformMatrix4fv(modelview_projection, 1, GL_TRUE, identity); printf("%d %d %d %d\n", (int) sizeof(AQParticle), shader_program, positionAttribute, modelview_projection); glGenBuffers(1, &buffer); aqfree( pool ); }