2010-12-08 4 views
1

新しいアプリケーションにはGLPaintの例が使用されています。 少数のオブジェクトを描画する方法をユーザーに実証したいと考えています。 りんごGLPaintには、図面のポイントのデータを再生する方法の例があります。GLPaintで逆さまに描かれたCGPoint

私たちは独自のデータを提供することができました。それは、それが逆さまになるという問題の横に大きな効果があります。

供給ポイントはそのためのものです -

alt text

それは

alt text

は、そのための簡単な解決策があることを描くのだろうか? OpenGLはデカルトシステムを使用しながら、iPhone座標系を

おかげで、シャニー

+0

を助けることを願っていますか? – genpfault

答えて

2

は、ダウンまでを読み込みます。したがって、openGLのすべての図面はiPhone上に上下逆さまに表示されます。レンダリング時に画像を上下逆さまにしてみてください。

0

ありがとうございましたGinamin

ありがとうございました。 座標を反転させるために何らかのビルドを作成する必要があると聞こえます。

私はそれをしました - 1. y座標の最高点と最低点を見つけてください。 2.各y点に-1を掛け、最も高い+最低点をそれに加えます。画像は正しく描画されます。

これは誰にとっても役立つコードです。

//points array for example 
points = [[NSArray alloc] initWithObjects: 
       [NSValue valueWithCGPoint:CGPointMake(0, 0)], 
       [NSValue valueWithCGPoint:CGPointMake(0, 90)], 
       [NSValue valueWithCGPoint:CGPointMake(100, 90)], 
       [NSValue valueWithCGPoint:CGPointMake(100, 0)], 
       [NSValue valueWithCGPoint:CGPointMake(0, 0], 
       nil]; 


    CGPoint point; 
    NSValue *val; 
    NSDictionary * dict; 
    NSMutableArray *yPoints =[[NSMutableArray alloc] initWithCapacity:[points count]]; 

    for (int i=0; i<[points count]; ++i) { 
    val = [points objectAtIndex:i]; 
    point = [val CGPointValue]; 
    dict = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:point.y] forKey:@"y"]; 
    [yPoints addObject:dict]; 

    } 

      //sort the array by the y value 
    NSSortDescriptor * yDescriptor = 
    [[NSSortDescriptor alloc] initWithKey:@"y" 
    ascending:YES]; 

    NSArray * descriptors = 
    [NSArray arrayWithObjects:yDescriptor, nil]; 
    NSArray * sortedArray = 
    [yPoints sortedArrayUsingDescriptors:descriptors]; 

      //get the first and last points from the sorted array 

    yFactorHighest = [[[sortedArray lastObject] objectForKey:@"y"] intValue]; 
    yFactorlowst = [[[sortedArray objectAtIndex:0] objectForKey:@"y"] intValue]; 

    [yDescriptor release]; 
    [yPoints release]; 

と描画機能 -

- (void) playback:(NSString*)letter 
{ 

    NSUInteger pointsCount = [points count]-1; 


    // Render the current path 


    val1 = [points objectAtIndex:p]; 
    point1 = [val1 CGPointValue]; 
    point1.y=-(p1.y)+yFactorHighest+yFactorlowst; 

    val2 = [points objectAtIndex:p+1]; 
    point2 = [val2 CGPointValue]; 
    point2.y=-(p2.y)+yFactorHighest+yFactorlowst; 

    [self renderLineFromPoint:point1 toPoint:point2]; 
    p++;  

    if(p<pointsCount) 
     [self performSelector:@selector(playback:) withObject:@"a" afterDelay:0.1]; 

} 

プログラミングイム新しいので、私は私のコードに問題がない願っています。 はそれだけで逆さまに、または上下逆さまにして後方描かれているように

シャニー

関連する問題