Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: OpenGL ES not rendering vectors in IOS

  1. #1
    Newbie Newbie
    Join Date
    May 2013
    Posts
    2

    OpenGL ES not rendering vectors in IOS

    I am fairly new to IOS, however, I am trying to port a native OpenGL ES triangle example I did on Android. Info on the details of my problem can be found here (Well it won't let me add a url so I will copy my post).

    It only let me post a "little" of the code so here are the main parts in question, I am pretty sure the shader compiles.

    viewController.m

    Code :
    #import "game-gl.h"
    ....
    - (void)glkView:(GLKView *)view drawInRect:(CGRect)rect
    {
      renderFrameLine();
    }

    game-gl.c

    Code :
    GLbyte vShaderStr[] =
    "attribute vec4 vPosition;   \n"
    "void main()                 \n"
    "{                           \n"
    "     gl_Position = vPosition; \n"
    "}                           \n";
     
    GLbyte fShaderStr[] = "precision mediump float;"
    "void main()                                \n"
    "{                                          \n"
    "  gl_FragColor = vec4 (0.0, 1.0, 0.0, 1.0); \n"
    "}                                          \n";
    GLuint LoadShader(GLenum type, const char *shaderSrc) {
    #ifdef __APPLE__
        printf("Compiling Shader \n");
    #endif
    	GLuint shader;
    	GLint compiled;
    	// Create the shader object
    	shader = glCreateShader(type);
    //	if (shader == 0){
    //#ifdef __APPLE__
    //        printf("Shader Failed %d\n", type);
    //#endif
    //        return 0;
    //    }
     
    	// Load the shader source
    	glShaderSource(shader, 1, &shaderSrc, NULL);
     
    	// Compile the shader
    	glCompileShader(shader);
     
    	// Check the compile status
    	glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
    	if (!compiled) {
    #ifdef __APPLE__
            printf("Shader Failed \n");
    #endif
    		GLint infoLen = 0;
     
    		glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
     
    		glDeleteShader(shader);
    		return 0;
    	}
        else{
    #ifdef __APPLE__
            printf("Shader Created \n");
    #endif
        }
    	return shader;
     
    }
    ....
            vertexShader = LoadShader(GL_VERTEX_SHADER, vShaderStr);
    	fragmentShader = LoadShader(GL_FRAGMENT_SHADER, fShaderStr);
    ....
    float s = 0.5F;
    void renderFrameLine() {
    #ifdef __APPLE__
        //printf("Inside Render Line \n");
        if(f>1.0f){
            f = 0.0f;
        }
        else{
            f = f+.01;
        }
        glClearColor(0.25f, 0.8f, f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    #else
        glClear(GL_COLOR_BUFFER_BIT);
    #endif
    	GLfloat vVertices[] = { s, s, 0.0f, s, -s, 0.0f, -s, s,
            0.0f};
    	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, vVertices);
    	glEnableVertexAttribArray(0);
    	glDrawArrays(GL_TRIANGLES, 0, 3);
    }


    I am beating my head against the wall here, the code works fine on Android, but on ios I see the background changing but not the triangle. Any ideas?
    Last edited by partyk1d24; 05-30-2013 at 05:57 AM.

  2. #2
    Newbie Newbie
    Join Date
    May 2013
    Posts
    2
    A little update...

    I added the following to my initialize...

    Code :
    GLint linked;
        glGetProgramiv(programObject, GL_LINK_STATUS, &linked);
     
        if (!linked) {
            printf("Error linking program:\n");
            GLint infoLen = 0;
            glGetProgramiv(programObject, GL_INFO_LOG_LENGTH, &infoLen);
            if (infoLen > 1) {
                char* infoLog = (char*)malloc(sizeof(char)*infoLen);
                glGetProgramInfoLog(programObject, infoLen, NULL, infoLog);
                printf("%s\n",infoLog);
                free(infoLog);
            }
            else{
                printf("No more information\n");
            }
            glDeleteProgram(programObject);
        }
        else{
            printf("No linker error \n");
        }

    And I get...

    Shader Created
    Linking programProgram linking completed
    Error linking program:
    No more information
    Initialization Complete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •