简体   繁体   English

应用程序在模拟器上运行,但不在ipad上..!

[英]app running on simulator but not in ipad..!

A'm stucked with a very strange problem.....really cant get how to come out with that..!! 卡住了一个非常奇怪的问题.....真的不知道该如何解决.. !!

I am developing iPad application in which I am drawing a 3d cube with openGL programming for ipad....Everything is fine....I drawn the cube and also colored it with different colors....This all things I have tested on simulator, everything is great. 我正在开发iPad应用程序,在其中我正在使用针对ipad的openGL编程绘制3d立方体。在模拟器上,一切都很棒。 But when I tried to test on iPad, my cube is being drawn but coloring part is not working...!!! 但是,当我尝试在iPad上进行测试时,正在绘制我的立方体,但是着色部分无法正常工作!!!!!!

Thanks in advance for help..!! 在此先感谢您的帮助..!

UPDATE : My sample code 更新 :我的示例代码

MyViewController.h MyViewController.h

    CubeView *cubeView;

MyViewController.m MyViewController.m

    cubeView = [[CubeView alloc] initWithFrame:CGRectMake(250, 60, 450, 600)];
    cubeView.multipleTouchEnabled = YES;
    cubeView.backgroundColor = [UIColor clearColor];

    [self.view addSubview:cubeView];

CubeView.m 多维数据集查看器

- (id)initWithCoder:(NSCoder*)coder
{    
    if ((self = [super initWithCoder:coder]))
    {

        // Get the layer
        CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;

        eaglLayer.opaque = TRUE;
        eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                        [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];

        [self setMultipleTouchEnabled:YES];
//      self.frame = CGRectMake(20, 30, 500, 500);
        renderer = nil;
        if (!renderer)
        {
            renderer = [[CubeRenderer alloc] init];

            if (!renderer)
            {
                [self release];
                return nil;
            }
        }

    }

    return self;
}

- (id)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
        // Get the layer
        CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;

        eaglLayer.opaque = TRUE;
        eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                        [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
        [self setMultipleTouchEnabled:YES];
        renderer = nil;
        if (!renderer)
        {
            renderer = [[CubeRenderer alloc] init];

            if (!renderer)
            {
                [self release];
                return nil;
            }
        }

    }   
    return self;
}

CubeRenderer.m 立方体渲染器

- (id)init
{
    if ((self = [super init]))
    {
        context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];

        if (!context || ![EAGLContext setCurrentContext:context])
        {
            [self release];
            return nil;
        }

        currentCalculatedMatrix = CATransform3DIdentity;

        // Create default framebuffer object. The backing will be allocated for the current layer in -resizeFromLayer
        glGenFramebuffersOES(1, &defaultFramebuffer);
        glGenRenderbuffersOES(1, &colorRenderbuffer);
        glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);
        glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
        glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, colorRenderbuffer);

    }

    return self;
}

    static const GLfloat cubeVertices[] = {

        -1.0, -1.0, 1.0,
        1.0, -1.0, 1.0,
        1.0, 1.0, 1.0,
        -1.0, 1.0, 1.0,

        -1.0, -1.0, -1.0,
        1.0, -1.0, -1.0,
        1.0, 1.0, -1.0,
        -1.0, 1.0, -1.0,
    };

    static const GLushort cubeIndicesFaceFront[] = {
        0, 1, 2, 3, 0
    };

    static const GLushort cubeIndicesFaceBack[] = {
        4, 5, 6, 7, 4
    };

    static const GLushort cubeIndicesFaceLeft[] = {
        0, 4, 7, 3, 0
    };

    static const GLushort cubeIndicesFaceRight[] = {
        1, 5, 6, 2, 1
    };

    static const GLushort cubeIndicesFaceTop[] = {
        3, 2, 6, 7, 3
    };

    static const GLushort cubeIndicesFaceBottom[] = {
        0, 1, 5, 4, 0
    };


    [EAGLContext setCurrentContext:context];


    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
        glOrthof(-2.0, 2.0, -2.0 * 480.0 / 320.0, 2.0 * 480.0 / 320.0, -3.0, 3.0);


        glMatrixMode(GL_MODELVIEW);

    glClear(GL_COLOR_BUFFER_BIT);

    glVertexPointer(3, GL_FLOAT, 0, cubeVertices);
    glEnableClientState(GL_VERTEX_ARRAY);


        glColorPointer(4, GL_UNSIGNED_BYTE, 0, cubeColorsBlueFace);
    glEnableClientState(GL_COLOR_ARRAY);
        glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceFront);
        //glDrawElements(GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceFront);

        glColorPointer(4, GL_UNSIGNED_BYTE, 0, cubeFillColorsFaceBack);
    glEnableClientState(GL_COLOR_ARRAY);
        glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceBack);
        //glDrawElements(GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceBack);

        glColorPointer(4, GL_UNSIGNED_BYTE, 0, cubeFillColorsFaceLeft);
    glEnableClientState(GL_COLOR_ARRAY);
        glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceLeft);
        //glDrawElements(GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceLeft);

        glColorPointer(4, GL_UNSIGNED_BYTE, 0, cubeFillColorsFaceRight);
    glEnableClientState(GL_COLOR_ARRAY);
        glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceRight);
        //glDrawElements(GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceRight);

        glColorPointer(4, GL_UNSIGNED_BYTE, 0, cubeFillColorsFaceTop);
    glEnableClientState(GL_COLOR_ARRAY);
        glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceTop);
        //glDrawElements(GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceTop);

        glColorPointer(4, GL_UNSIGNED_BYTE, 0, cubeFillColorsFaceBottom);
    glEnableClientState(GL_COLOR_ARRAY);
        glDrawElements(GL_TRIANGLE_FAN, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceBottom);
        //glDrawElements(GL_TRIANGLE_STRIP, 5, GL_UNSIGNED_SHORT, cubeIndicesFaceBottom);

        glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
        [context presentRenderbuffer:GL_RENDERBUFFER_OES];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM