mehmooda
Posts: 2
Joined: Tue Jun 12, 2012 8:48 pm

graphics_get_display_size wrong?

Tue Jun 12, 2012 9:04 pm

I'm trying to get the display size from within a GL program.

graphics_get_display_size is returning 1920x1080 ... no matter what resolution I am actually in. This is noticeable in the hello_triangle demo ... By which the cube is only partially visible.

Is this the intended behaviour of graphics_get_display_size or is it supposed to return 1280x720 in this situation

The code I'm using to test this:

Code: Select all

#include "bcm_host.h"
#include "GLES/gl.h"
#include "EGL/egl.h"
#include <stdio.h>
#include <assert.h>
EGLDisplay display;
EGLConfig config;
EGLContext context;
uint32_t screen_width;
uint32_t screen_height;

int main(){
	EGLBoolean result;
	EGLint num_config;

	bcm_host_init();
	static const EGLint attribute_list[] =
	{
		EGL_RED_SIZE, 8,
		EGL_GREEN_SIZE, 8,
		EGL_BLUE_SIZE, 8,
		EGL_ALPHA_SIZE, 8,
		EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
		EGL_NONE
	};	
	
	display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
	assert(display!=EGL_NO_DISPLAY);
	result = eglInitialize(display, NULL, NULL);
	assert(result!=EGL_FALSE);
	result = eglChooseConfig(display, attribute_list, &config, 1, &num_config);
	assert(result!=EGL_FALSE);
	context = eglCreateContext(display, config, EGL_NO_CONTEXT, NULL);
	assert(context!=EGL_NO_CONTEXT);
	graphics_get_display_size(0 /* LCD */, &screen_width, &screen_height);

	
	printf("%ux%u\n",screen_width,screen_height);
}
TVService:

Code: Select all

[email protected]:~$ /opt/vc/bin/tvservice -m CEA
Group CEA has 9 modes:
           mode 1: 640x480 @ 60Hz, progressive
           mode 2: 720x480 @ 60Hz, progressive
           mode 3: 720x480 @ 60Hz, progressive
  (native) mode 4: 1280x720 @ 60Hz, progressive
           mode 5: 1920x1080 @ 60Hz, interlaced
  (native) mode 17: 720x576 @ 50Hz, progressive
           mode 18: 720x576 @ 50Hz, progressive
           mode 19: 1280x720 @ 50Hz, progressive
           mode 20: 1920x1080 @ 50Hz, interlaced
[email protected]:~$ /opt/vc/bin/tvservice -s
state 0x12001a, 1280x720 @ 60Hz, progressive

Oh and I have to force CEA mode 4 otherwise it defaults to mode 17

finnw
Posts: 24
Joined: Wed May 16, 2012 7:05 pm

Re: graphics_get_display_size wrong?

Tue Jun 12, 2012 9:06 pm

I think this is a bug in an early version of the firmware.

rpi-update fixed it for me.

mehmooda
Posts: 2
Joined: Tue Jun 12, 2012 8:48 pm

Re: graphics_get_display_size wrong?

Tue Jun 12, 2012 9:35 pm

I stand corrected ...

rpi-update did fix the graphics_get_display_size issue ... Although the CEA 17 default problem is still there

User avatar
RichardUK
Posts: 224
Joined: Fri Jun 01, 2012 5:12 pm

Re: graphics_get_display_size wrong?

Tue Jun 19, 2012 10:08 pm

I have run my RPi on three different monitors, all 1080p, two were at work. One of the work ones displayed the image at a lower res but the RPi thought it was running at 1080p just as you have seen. The display was off centre as if half the screen of off to the right.

zephyr5415
Posts: 6
Joined: Tue Jan 08, 2019 7:39 am

Re: graphics_get_display_size wrong?

Tue Jan 08, 2019 7:43 am

I got the same issue on my rpi-stretch-Lite (uname -a = kernel 4.14.90-v7+ #1183) and set the boot config to hdmi_safe=1
where I'd like to run my application with SDL2 and is failed with SDL_Init().
I get the SDL driver number = 2.
driver name "RPI" and "dummy".
I cannot init video driver:RPI because the function
graphics_get_display_size() return the value less than 0.

I did some test by tvservice and got weird result:

tvservice -m DMT
Group DMT has 0 modes:

tvservice -m CEA
Group CEA has 0 modes:

tvservice -s
state 0x120009 [HDMI DMT (4) RGB FULL 4:3], 640X480 @ 60.00Hz, progressive

tvservice -d dell.dat
Written 256 bytes to dell.dat

Return to “OpenGLES”