... How to start OpenGL for Raspberry Pi 4 .... I couldn't start OpenGL.
I am see Example and Excute but that messaging "RPI4 not Support"
Re: How to start OpenGL for RPI4
We aren't mind readers !
You need to tell us much more info about what you are trying to do.
Where is the example you are using ?
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Re: How to start OpenGL for RPI4
// I am typing this code ... It's a raspberrypi2 code ..
// I know .. may be changed someone......
// but I don't konw ... help me.
// Compile Option .. Command
// pi@raspberrypi ~ $ gcc -o hello_egl hello_egl.c -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads/ -I/opt/vc/include/interface/vmcs_host/linux -L/opt/vc/lib -lbcm_host -lEGL -lGLESv1_CM
// I know .. may be changed someone......
// but I don't konw ... help me.
Code: Select all
#include < stdio.h>
#include < unistd.h>
#include < bcm_host.h> /*for BCM GPU */
#include < EGL/egl.h> /*for EGL */
#include < EGL/eglext.h>
#include < GLES/gl.h> /* for OpenGL ES */
int main(int argc, const char **argv) {
/* var for screen */
uint32_t screenWidth, screenHeight;
/*var for EGL */
EGLDisplay gDisplay;
EGLSurface gSurface;
EGLContext gContext;
EGLConfig gConfig;
EGLBoolean result;
EGLint numConfig;
int32_t success = 0;
/*for put printing screen on raspberrypi */
static EGL_DISPMANX_WINDOW_T nativeWindow;
DISPMANX_ELEMENT_HANDLE_T dispmanElement;
DISPMANX_DISPLAY_HANDLE_T dispmanDisplay;
DISPMANX_UPDATE_HANDLE_T dispmanUpdate;
VC_RECT_T dst_rect, src_rect;
/* for eglChooseConfig( ) fucntion */
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, /* It's needed for color depth buffering . */
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_NONE
};
/* for eglCreateContext( ) function */
static const EGLint context_attributes[] = {
EGL_CONTEXT_CLIENT_VERSION, 1, /* OpenGL ES 1.x는 1, OpenGL ES 2는 2 */
EGL_NONE
};
bcm_host_init(); /* BCM GPU Init */
/*object for connecting EGL display */
gDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
/* EGLDisplay Init */
result = eglInitialize(gDisplay, NULL, NULL);
/* an object for setting a EGL FrameBuffer */
result = eglChooseConfig(gDisplay, attribute_list, &gConfig, 1, &numConfig);
/* for using OpenGL ES on EGL */
result = eglBindAPI(EGL_OPENGL_ES_API);
/* a contextt for randering */
gContext = eglCreateContext(gDisplay, gConfig, EGL_NO_CONTEXT, context_attributes);
/* getting full screen size */
success = graphics_get_display_size(0 /* LCD */, &screenWidth, &screenHeight);
dst_rect.x = 0;
dst_rect.y = 0;
dst_rect.width = screenWidth;
dst_rect.height = screenHeight;
src_rect.x = 0;
src_rect.y = 0;
src_rect.width = screenWidth < < 16;
src_rect.height = screenHeight < < 16;
dispmanDisplay = vc_dispmanx_display_open(0 /* LCD */);
dispmanUpdate = vc_dispmanx_update_start(0);
dispmanElement = vc_dispmanx_element_add(dispmanUpdate, dispmanDisplay,
0/*layer*/, &dst_rect, 0/*src*/,
&src_rect, DISPMANX_PROTECTION_NONE,
0 /*alpha*/, 0/*clamp*/, (DISPMANX_TRANSFORM_T)0/*transform*/);
nativeWindow.element = dispmanElement;
nativeWindow.width = screenWidth;
nativeWindow.height = screenHeight;
vc_dispmanx_update_submit_sync(dispmanUpdate);
gSurface = eglCreateWindowSurface(gDisplay, gConfig, &nativeWindow, NULL);
result = eglMakeCurrent(gDisplay, gSurface, gSurface, gContext);
glClearColor(0.15f, 0.25f, 0.35f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, screenWidth, screenHeight);
eglSwapBuffers(gDisplay, gSurface);
getchar();
bcm_host_deinit();
return 0;
}
// pi@raspberrypi ~ $ gcc -o hello_egl hello_egl.c -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads/ -I/opt/vc/include/interface/vmcs_host/linux -L/opt/vc/lib -lbcm_host -lEGL -lGLESv1_CM
Re: How to start OpenGL for RPI4
The Pi4 no longer supports the closed source Broadcom GL driver. You'll have to rewrite that to either use DRM to create a surface or X. There's examples and links in the OpenGL subforum for both ways.
info-beamer hosted - A user and programmer friendly digital signage platform for the Pi: https://info-beamer.com/hosted
Re: How to start OpenGL for RPI4
Most of the mesa demos work now
https://www.mesa3d.org/download.html
Some will work on Pi3B's if you use Gentoo64 which uses the OpenGL drivers.
Have not tried them on 3B+/Buster.
I have also got OpenGL working with Go and Free Pascal.
Pi4 and OpenGl are pretty mainstream now, have a look at Linux OpenGL tutorials.
https://www.mesa3d.org/download.html
Some will work on Pi3B's if you use Gentoo64 which uses the OpenGL drivers.
Have not tried them on 3B+/Buster.
I have also got OpenGL working with Go and Free Pascal.
Pi4 and OpenGl are pretty mainstream now, have a look at Linux OpenGL tutorials.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges
Raspberries are not Apples or Oranges