2013-04-27 1 views
0

(NGLView 유형의)보기의 배경 이미지를 설정하려고하는데 올바르게 작동하지 않습니다.iOS에서 NivevehGL보기의 배경 이미지 설정

@interface ViewController : UIViewController <NGLViewDelegate> 
{ 
@private 
    NGLMesh *_mesh; 
    NGLCamera *_camera; 

} 
@property (strong,nonatomic) NSString *fileName; 

-(void)screenBtnClicked:(id)sender; 

@end 

하는 .m

#import "ViewController.h" 

//Tags 
#define kBackButtonTag 100 

#pragma mark - 
#pragma mark Constants 
#pragma mark - 
//********************************************************************************************************** 
// 
// Constants 
// 
//********************************************************************************************************** 

#pragma mark - 
#pragma mark Private Interface 
#pragma mark - 
//********************************************************************************************************** 
// 
// Private Interface 
// 
//********************************************************************************************************** 

#pragma mark - 
#pragma mark Public Interface 
#pragma mark - 
//********************************************************************************************************** 
// 
// Public Interface 
// 
//********************************************************************************************************** 

@implementation ViewController 

@synthesize fileName; 

#pragma mark - 
#pragma mark Properties 
//************************************************** 
// Properties 
//************************************************** 

#pragma mark - 
#pragma mark Constructors 
//************************************************** 
// Constructors 
//************************************************** 

#pragma mark - 
#pragma mark Private Methods 
//************************************************** 
// Private Methods 
//************************************************** 

#pragma mark - 
#pragma mark Self Public Methods 
//************************************************** 
// Self Public Methods 
//************************************************** 

- (void) drawView 
{ 
// _mesh.rotateY += 2.0f; 
// _mesh.rotateX -= 0.5f; 

    [_camera drawCamera]; 
} 

#pragma mark - 
#pragma mark Override Public Methods 
//************************************************** 
// Override Public Methods 
//************************************************** 

- (void) viewDidLoad 
{ 
    // Must call super to agree with the UIKit rules. 
    [super viewDidLoad]; 
    // Setting the loading process parameters. To take advantage of the NGL Binary feature, 
    // remove the line "kNGLMeshOriginalYes, kNGLMeshKeyOriginal,". Your mesh will be loaded 950% faster. 
    NSDictionary *settings = [NSDictionary dictionaryWithObjectsAndKeys: 
           kNGLMeshOriginalYes, kNGLMeshKeyOriginal, 
           kNGLMeshCentralizeYes, kNGLMeshKeyCentralize, 
           @"0.7", kNGLMeshKeyNormalize, 
           nil]; 



    _mesh = [[NGLMesh alloc] initWithFile:fileName settings:settings delegate:nil]; 

    _camera = [[NGLCamera alloc] initWithMeshes:_mesh, nil]; 
    [_camera autoAdjustAspectRatio:NO animated:YES]; 

    // Starts the debug monitor. 
// [[NGLDebug debugMonitor] startWithView:(NGLView *)self.view mesh:_mesh]; 


    UIButton *closeButton = [[UIButton alloc] init]; 
    closeButton.frame = CGRectMake(5, 5, 40, 40); 
    closeButton.tag = 100; 
    [closeButton setBackgroundImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal]; 
    [closeButton addTarget:self action:@selector(screenBtnClicked:) forControlEvents:UIControlEventTouchUpInside]; 
    [self.view addSubview:closeButton]; 

//try this... not working 
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bg.png"]]; 
    [self.view sendSubviewToBack:imageView]; 

//tried this not working either.. 
    UIColor *patternColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]]; 
    UIView *patternView = [[UIView alloc] initWithFrame:self.view.frame]; 
    [patternView setBackgroundColor:patternColor]; 
    [self.view sendSubviewToBack:patternView]; 


} 

- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    // Super call, must be called if we have no plans to override all touch methods, it's an UIKit rule. 
    [super touchesMoved:touches withEvent:event]; 

    UITouch *touch; 
    CGPoint pointA, pointB; 

    // Pan gesture. 
    if ([touches count] == 1) 
    { 
     touch = [[touches allObjects] objectAtIndex:0]; 
     pointA = [touch locationInView:self.view]; 
     pointB = [touch previousLocationInView:self.view]; 

     _mesh.rotateY += (pointA.x - pointB.x) * 0.5f; 
     _mesh.rotateX += (pointA.y - pointB.y) * 0.5f; 

    } 
} 

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 
{ 
    return YES; 
} 

- (void) dealloc 
{ 
    [_mesh release]; 
    [_camera release]; 

    [super dealloc]; 
} 

-(void)screenBtnClicked:(UIButton*)sender 
{ 
    switch (sender.tag) { 
     case kBackButtonTag: 
     { 
      [self dismissModalViewControllerAnimated:YES]; 
      break; 
     } 
     default: 
      break; 
    } 
} 

가 XIB 파일에 이미지 뷰를 설정하고 배경 이미지를 변경 시도 .H

,하지만 작동하지 않습니다 :

는 코드는 다음과 같습니다 어느 쪽이든 ...

답변

0
self.view.backgroundColor = [UIColor clearColor]; 
nglGlobalColorFormat(NGLColorFormatRGBA); 
nglGlobalFlush(); 

이 세 줄을 사용하면 투명한 배경을 설정할 수 있습니다.