Im setting eglMakeCurrent, glBindFramebuffer, glViewPort, glClearColor, glClear and then eglSwapBuffer... Its getting over 60fps but nothing shows on the screen.
I'm using "Soft-float Debian “wheezy”" with Mono C#.
Here is how I create egl:
Code: Select all
//Get DC
RaspberryPi.bcm_host_init();
handle = window.Handle;
dc = EGL.GetDisplay(IntPtr.Zero);
int major, minor;
if (!EGL.Initialize(dc, out major, out minor))
{
Debug.ThrowError("Video", string.Format("Failed to initialize display connection, Error {0}", EGL.GetError()));
}
if (minor != EGL.OPENGL_ES2_BIT) Debug.ThrowError("Video", "GLES2 is not supported");
int[] pixelFormat = new int[]
{
//EGL.RENDERABLE_TYPE, EGL.OPENGL_ES2_BIT,
//EGL.SURFACE_TYPE, EGL.WINDOW_BIT,
EGL.RED_SIZE, 5,
EGL.GREEN_SIZE, 6,
EGL.BLUE_SIZE, 5,
EGL.ALPHA_SIZE, EGL.DONT_CARE,
EGL.DEPTH_SIZE, EGL.DONT_CARE,
EGL.STENCIL_SIZE, EGL.DONT_CARE,
EGL.SAMPLE_BUFFERS, 0,
//EGL.SAMPLES, 0,
//EGL.MIN_SWAP_INTERVAL, 0,
//EGL.MAX_SWAP_INTERVAL, 1,
EGL.NONE,
};
int num_configs;
var configs = new IntPtr();
if (EGL.ChooseConfig(dc, pixelFormat, &configs, 1, &num_configs) == 0 || num_configs == 0)
{
Debug.ThrowError("Video", string.Format("Failed to retrieve GraphicsMode, error {0}", EGL.GetError()));
}
if (EGL.BindAPI(EGL.OPENGL_ES_API) == 0) Debug.ThrowError("Video", "Failed to bind GLES API");;
int[] attrib_list = new int[]
{
EGL.CONTEXT_CLIENT_VERSION, 2,
EGL.NONE
};
ctx = EGL.CreateContext(dc, configs, IntPtr.Zero, attrib_list);
if (ctx == IntPtr.Zero) Debug.ThrowError("Video", "Failed to create context");
const int piDisplay = 0;
uint piWidth = 0, piHeight = 0;
if (RaspberryPi.graphics_get_display_size(piDisplay, &piWidth, &piHeight) < 0) Debug.ThrowError("Video", "Failed to get display size");
piWidth = 640;
piHeight = 480;
Console.WriteLine("piWidth - " + piWidth);
Console.WriteLine("piHeight - " + piHeight);
IntPtr dispman_display = RaspberryPi.vc_dispmanx_display_open(piDisplay);
if (dispman_display == IntPtr.Zero) Debug.ThrowError("Video", "Failed: vc_dispmanx_display_open");
IntPtr dispman_update = RaspberryPi.vc_dispmanx_update_start(0);
if (dispman_update == IntPtr.Zero) Debug.ThrowError("Video", "Failed: vc_dispmanx_update_start");
VC_RECT_T dstRect = new VC_RECT_T()
{
x = 0,
y = 0,
width = (int)piWidth,
height = (int)piHeight
};
VC_RECT_T srcRect = new VC_RECT_T()
{
x = 0,
y = 0,
width = (int)(piWidth << 16),
height = (int)(piHeight << 16)
};
IntPtr dispman_element = RaspberryPi.vc_dispmanx_element_add(dispman_update, dispman_display, 0, &dstRect, IntPtr.Zero, &srcRect, RaspberryPi.DISPMANX_PROTECTION_NONE, IntPtr.Zero, IntPtr.Zero, 0);
if (dispman_element == IntPtr.Zero) Debug.ThrowError("Video", "Failed: vc_dispmanx_element_add");
RaspberryPi.vc_dispmanx_update_submit_sync(dispman_update);
DISPMANX_WINDOW_T nativeWindow = new DISPMANX_WINDOW_T()
{
element = dispman_element,
width = (int)piWidth,
height = (int)piHeight
};
surface = EGL.CreateWindowSurface(dc, configs, new IntPtr(&nativeWindow), null);
//surface = EGL.CreateWindowSurface(dc, configs[0], handle, null);// <<<<<<<<<<<<<<<<<<<<<<<<<<<< used in x11
if (surface == IntPtr.Zero) Debug.ThrowError("Video", "Failed to create window surface");
if (EGL.MakeCurrent(dc, surface, surface, ctx) == 0) Debug.ThrowError("Video", "Failed to make EGL context current");
//if (!EGL.SwapInterval(dc, vSync ? 1 : 0)) Debug.ThrowError("Video", "Failed to set vSync");