Not able to see the display of OpenGLES with EGL

Q: I am trying to bind a texture and display the same using egl. I am not able to see the display,
could any one let me know if I am doing something wrong here.
I use the vincent 3D implementation of OpenGL ES

<code>
#include <GLES/gl.h>
#include <GLES/glext.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <assert.h>
#include <string.h>
#include <unistd.h>

#include “egl.h”

/* Declaration */

EGLDisplay egldisplay;
EGLConfig eglconfig;
EGLSurface eglsurface;
EGLContext eglcontext;
EGLint numconfigs;

//Main function call of the application

int main(void)
{

static const EGLint s_configAttribs[] =
{
    EGL_RED_SIZE,        8,
    EGL_GREEN_SIZE,      8,
    EGL_BLUE_SIZE,       8,
    EGL_ALPHA_SIZE,      0,
    EGL_LUMINANCE_SIZE,  EGL_DONT_CARE,
    EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
    EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
    EGL_NONE
};
        
unsigned int * raw_bitmap;
int height = 320;
int width = 240;
int depth = 4;
char *file_name = "redhand.png";
    EGLint numconfigs;
    structNativePixmapI natpix;
 FILE *file;
  if ((file = fopen(file_name, "rb"))==NULL)
   {
    printf("File Not Found : %s/n",file_name);
    exit (1);
   }
   raw_bitmap = (unsigned int *)malloc(width * height * depth * (sizeof(unsigned int)));

   if (raw_bitmap == NULL)
   {
    printf ("Cannot allocate memory for texture/n");
      fclose (file);
      exit (1);
   }
  fread (raw_bitmap , width * height * depth, 1 , file);
  fclose (file); 

    printf("Bind API of GLES is called 

");
eglBindAPI(EGL_OPENGL_ES_API);

egldisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);

eglInitialize(egldisplay, NULL, NULL);

eglChooseConfig(egldisplay, s_configAttribs, &eglconfig, 1, &numconfigs);

eglsurface = eglCreateWindowSurface(egldisplay, eglconfig,0, NULL);
eglcontext = eglCreateContext(egldisplay, eglconfig, NULL, NULL);

eglMakeCurrent(egldisplay, eglsurface, eglsurface, eglcontext);
    printf("GLES operation started  

“);
int handle;
glEnable( GL_TEXTURE_2D );
glGenTextures (1, &handle);
glBindTexture (GL_TEXTURE_2D, handle);
printf (” handle %d
",handle);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);

glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);//GL_NEAREST_MIPMAP_NEAREST GL_LINEAR_MIPMAP_NEAREST
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA,
256,512, 0, GL_RGBA, GL_UNSIGNED_BYTE, raw_bitmap);
eglSwapBuffers(egldisplay, eglsurface);

//De Associating the context

eglMakeCurrent(egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);

eglDestroySurface(egldisplay,eglsurface);

eglTerminate(egldisplay);
}

Assuming some of your code isn’t just pseudo, for starters you can’t read from a PNG file like that, here’s a link to the PNG spec:

http://www.libpng.org/pub/png/spec/1.2/ … tents.html

You could probably also google source for a PNG loader.

The sequence of your EGL calls appears to be correct enough. Perhaps try checking the return values to confirm the functions are not failing?

Note, that you’re sequence of gl calls simple load the texture data into video memory, and will not be displayed in anyway till you make the appropriate function calls.

Glancing over the code, I am 99% certain that numConfigs is 0 after eglChooseConfig.
Also, the old Vincent code does not implement API binding nor provide any interoperability with any OpenVG implementation.

  • HM

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.