oliver_mpt
Posts: 14
Joined: Tue Dec 06, 2016 2:41 pm

OpenGLES2 on RaspBerry Pi 1B

Tue Jan 15, 2019 8:15 pm

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);

User avatar
Paeryn
Posts: 2512
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: OpenGLES2 on RaspBerry Pi 1B

Tue Jan 15, 2019 11:16 pm

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?
She who travels light — forgot something.

oliver_mpt
Posts: 14
Joined: Tue Dec 06, 2016 2:41 pm

Re: OpenGLES2 on RaspBerry Pi 1B

Wed Jan 16, 2019 8:46 pm

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

User avatar
Paeryn
Posts: 2512
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: OpenGLES2 on RaspBerry Pi 1B

Wed Jan 16, 2019 9:07 pm

No worries, it's an easy thing to overlook.
She who travels light — forgot something.

Return to “OpenGLES”