Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Loading Image as a Texture

maximusVmaximusV Posts: 1
NerveGear
edited October 2016 in Oculus Go Development
Hello!
I have been trying to load an image and the raw data as a texture to the VrCubeWorld_SurfaceView example in Mobile SDK, but It seems like I am missing something because application crashes when I run it. This is what I have done so far:

Custom function for loading image (raw data, 512*515 8bit image)
GLint loadTexture(char* imagePath) {
    GLint newTexture;
    FILE * file;
    char *data = (char *)malloc( 512*512 * sizeof( char ) );

    file = fopen(imagePath, "rb");
    fread(data, 1, 512*512, file);

    GL( glGenTextures(1, &newTexture));
    GL( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT));
    GL( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT));
    GL( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
    GL( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
    GL( glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 512, 512, 0, GL_RED, GL_UNSIGNED_BYTE, data));
    GL( glGenerateMipmap(GL_TEXTURE_2D));
    GL( glBindTexture(GL_TEXTURE_2D, 0));

    fclose(file);
    return newTexture;
Global Variable
GLint texture1 = loadTexture("/../../assets/lena.raw");
Inside ovrProgram_Create
...
texture1 = glGetUniformLocation( program->Program, "passTexture" );
...
Vertex Shader
...
Fragment Shader
...
"in vec2 TexPosition;\n"
Inside ovrRenderer_RenderFrame
...
Is there something wrong? Any help would be much appreciated! <3
Thank You! 



Sign In or Register to comment.