Page 1 of 1

OpenGLES2 on RaspBerry Pi 1B

Posted: Tue Jan 15, 2019 8:15 pm
by oliver_mpt
Hello,

I have developped an OpenGL ES program wich works perfectly on a Raspberry Pi 3, and I wanted to port it on a Pi 1.
The relevant part of the code is shown below. In the last line :
success = graphics_get_display_size(0, &state->screen_width, &state->screen_height);
success contains 0 after execution, and subsequent drawing command will fail.

Any idea what's wrong ???

Code: Select all

    static const EGLint attribute_list[] =
    {
      EGL_RED_SIZE, 8,
      EGL_GREEN_SIZE, 8,
      EGL_BLUE_SIZE, 8,
      EGL_ALPHA_SIZE, 8,
      EGL_DEPTH_SIZE, 16,
      EGL_SAMPLE_BUFFERS, 1,
      EGL_SAMPLES, 4,
      EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
      EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
      EGL_NONE
    };

    EGLConfig config;

    // get an EGL display connection
    state->display = eglGetDisplay(EGL_DEFAULT_DISPLAY);

    // initialize the EGL display connection
    result = eglInitialize(state->display, nullptr, nullptr);

    // get an appropriate EGL frame buffer configuration
    result = eglChooseConfig(state->display, attribute_list, &config, 1, &num_config);

    // create an EGL rendering context
    const EGLint context_attrib_list[] = {
           // request a context using Open GL ES 2.0
           EGL_CONTEXT_CLIENT_VERSION, 2,
           EGL_NONE
    };
    state->context = eglCreateContext(state->display, config, nullptr, context_attrib_list);

    // create an EGL window surface
    success = graphics_get_display_size(0, &state->screen_width, &state->screen_height);

Re: OpenGLES2 on RaspBerry Pi 1B

Posted: Tue Jan 15, 2019 11:16 pm
by Paeryn
A non-negative value from graphics_get_display_size() means the function was successful. Though looking at, it returns the value that vc_displaymanx_get_info() returned to it, and that only sets the info struct if the value it is returning is zero.

Have you allocated enough memory to the GPU? AFAIK if it only has 16MB allocated then OpenGLES won't work (I think 32MB should be ok, depending on the size of the window etc.). Did all the egl* calls say they succeeded?

Re: OpenGLES2 on RaspBerry Pi 1B

Posted: Wed Jan 16, 2019 8:46 pm
by oliver_mpt
Hi Paeryn,

Thanks for the prompt answer !
You guessed it right, I had the video memory poorly configured. I have set it now to 64Mo and it works like a charm !

Thanks again for your time and good advice

Olivier

Re: OpenGLES2 on RaspBerry Pi 1B

Posted: Wed Jan 16, 2019 9:07 pm
by Paeryn
No worries, it's an easy thing to overlook.