/** * main */ int main(int argc, const char **argv) { // Our main data storage vessel.. RASPISTILL_STATE state; MMAL_STATUS_T status = MMAL_SUCCESS; MMAL_PORT_T *camera_preview_port = NULL; MMAL_PORT_T *camera_video_port = NULL; MMAL_PORT_T *camera_still_port = NULL; MMAL_PORT_T *preview_input_port = NULL; MMAL_PORT_T *encoder_input_port = NULL; MMAL_PORT_T *encoder_output_port = NULL; bcm_host_init(); // Register our application with the logging system vcos_log_register("RaspiStill", VCOS_LOG_CATEGORY); signal(SIGINT, signal_handler); default_status(&state); // Do we have any parameters if (argc == 1) { fprintf(stderr, "\%s Camera App %s\n\n", basename(argv[0]), VERSION_STRING); display_valid_parameters(basename(argv[0])); exit(0); }
/** * @brief Initialization of OpenMAX and structures. * @param ctx Application context to initialize. */ static void initAppOMX(AppOMXContext* ctx) { bcm_host_init() ; log_printer("Initialization...") ; { OMX_ERRORTYPE error = OMX_Init() ; if (error != OMX_ErrorNone) { omx_die(error, "OMX initialization failed...") ; return ; } } // Initialize the application context for video capture AppOMXContext_Memset(ctx, 0, sizeof(*ctx)) ; if (vcos_semaphore_create(ctx -> getHandlerLock(ctx), "handler_lock", 1) != VCOS_SUCCESS) die("Failed to create handler lock semaphore...\n") ; // Initialize component handles OMX_CALLBACKTYPE callbacks ; AppOMXContext_Memset(ctx, 0, sizeof(callbacks)) ; callbacks.EventHandler = event_handler ; callbacks.FillBufferDone = fill_output_buffer_done_handler ; init_component_handle("camera", ctx -> getCamera(ctx) , ctx, &callbacks) ; init_component_handle("video_encode", ctx -> getEncoder(ctx) , ctx, &callbacks) ; init_component_handle("null_sink", ctx -> getNullSink(ctx) , ctx, &callbacks) ; }
// init sets the system to its initial state void init(int *w, int *h) { bcm_host_init(); memset(state, 0, sizeof(*state)); oglinit(state, 8); *w = state->screen_width; *h = state->screen_height; }
int main(int argc, char *argv[]) { OPENMAX_JPEG_DECODER *pDecoder; char *sourceImage; size_t imageSize; int s; if (argc < 2) { printf("Usage: %s <filename>\n", argv[0]); return -1; } FILE *fp = fopen(argv[1], "rb"); if (!fp) { printf("File %s not found.\n", argv[1]); } fseek(fp, 0L, SEEK_END); imageSize = ftell(fp); fseek(fp, 0L, SEEK_SET); sourceImage = malloc(imageSize); assert(sourceImage != NULL); s = fread(sourceImage, 1, imageSize, fp); assert(s == imageSize); fclose(fp); bcm_host_init(); s = setupOpenMaxJpegDecoder(&pDecoder); assert(s == 0); s = decodeImage(pDecoder, sourceImage, imageSize); assert(s == 0); cleanup(pDecoder); free(sourceImage); return 0; }
ViewBackend::ViewBackend(struct wpe_view_backend* backend) : backend(backend) { ipcHost.initialize(*this); bcm_host_init(); displayHandle = vc_dispmanx_display_open(0); graphics_get_display_size(DISPMANX_ID_HDMI, &width, &height); updateFd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); if (updateFd == -1) { fprintf(stderr, "ViewBackend: failed to create the update eventfd\n"); return; } updateSource = g_source_new(&UpdateSource::sourceFuncs, sizeof(UpdateSource)); auto& source = *reinterpret_cast<UpdateSource*>(updateSource); source.backend = this; source.pfd.fd = updateFd; source.pfd.events = G_IO_IN | G_IO_ERR | G_IO_HUP; source.pfd.revents = 0; g_source_add_poll(updateSource, &source.pfd); g_source_set_name(updateSource, "[WPE] BCMRPi update"); g_source_set_priority(updateSource, G_PRIORITY_HIGH + 30); g_source_set_can_recurse(updateSource, TRUE); g_source_attach(updateSource, g_main_context_get_thread_default()); }
bool NativeStateDispmanx::init_display() { bcm_host_init(); return true; }
// init sets the system to its initial state void init(int *w, int *h) { bcm_host_init(); memset(state, 0, sizeof(*state)); oglinit(state); SansTypeface = loadfont(DejaVuSans_glyphPoints, DejaVuSans_glyphPointIndices, DejaVuSans_glyphInstructions, DejaVuSans_glyphInstructionIndices, DejaVuSans_glyphInstructionCounts, DejaVuSans_glyphAdvances, DejaVuSans_characterMap, DejaVuSans_glyphCount); SerifTypeface = loadfont(DejaVuSerif_glyphPoints, DejaVuSerif_glyphPointIndices, DejaVuSerif_glyphInstructions, DejaVuSerif_glyphInstructionIndices, DejaVuSerif_glyphInstructionCounts, DejaVuSerif_glyphAdvances, DejaVuSerif_characterMap, DejaVuSerif_glyphCount); MonoTypeface = loadfont(DejaVuSansMono_glyphPoints, DejaVuSansMono_glyphPointIndices, DejaVuSansMono_glyphInstructions, DejaVuSansMono_glyphInstructionIndices, DejaVuSansMono_glyphInstructionCounts, DejaVuSansMono_glyphAdvances, DejaVuSansMono_characterMap, DejaVuSansMono_glyphCount); *w = state->screen_width; *h = state->screen_height; }
static void frontend_init(void) { uint32_t display_width=0, display_height=0; VC_RECT_T dst_rect; VC_RECT_T src_rect; bcm_host_init(); //initialise dispmanx display and resources fe_screen=(unsigned short *) calloc(1, 640*480*2); graphics_get_display_size(0 /* LCD */, &display_width, &display_height); fe_display = vc_dispmanx_display_open( 0 ); //Create two surfaces for flipping between //Make sure bitmap type matches the source for better performance uint32_t crap; fe_resource = vc_dispmanx_resource_create(VC_IMAGE_RGB565, 640, 480, &crap); vc_dispmanx_rect_set( &dst_rect, 0, 0, display_width, display_height); vc_dispmanx_rect_set( &src_rect, 0, 0, 640 << 16, 480 << 16); //Make sure mame and background overlay the menu program fe_update = vc_dispmanx_update_start( 0 ); // create the 'window' element - based on the first buffer resource (resource0) fe_element = vc_dispmanx_element_add( fe_update, fe_display, 1, &dst_rect, fe_resource, &src_rect, DISPMANX_PROTECTION_NONE, 0, 0, (DISPMANX_TRANSFORM_T) 0 ); vc_dispmanx_update_submit_sync( fe_update ); }
int main (int argc, char *argv[]) { bcm_host_init(); // Clear application state memset( state, 0, sizeof( *state ) ); setup_user_options(argc, argv); // Start OGLES init_egl(); init_textures(); build_gears(); // setup the scene based on rendering mode if (state->useGLES2) { init_scene_GLES2(); // Setup the model projection/world init_model_projGLES2(); } else { // using gles1 init_scene_GLES1(); // Setup the model projection/world init_model_projGLES1(); } // animate the gears run_gears(); exit_func(); return 0; }
int _initDevice(){ atexit( bbEGLExit ); bcm_host_init(); _hosting=1; display=eglGetDisplay(EGL_DEFAULT_DISPLAY); printf("initializing display %d\n",display); EGLBoolean result=eglInitialize(display,&major,&minor); assert(result==EGL_TRUE); printf("egl success version %d.%d\n"); static const EGLint configAttribs[]={ EGL_CONFORMANT,EGL_OPENGL_ES2_BIT, EGL_RED_SIZE,8, EGL_GREEN_SIZE,8, EGL_BLUE_SIZE,8, EGL_SURFACE_TYPE,EGL_WINDOW_BIT, EGL_NONE}; EGLint num_config=0; eglChooseConfig(display,configAttribs,&config,1,&num_config); printf("got %d configs\n",num_config); }
static void open_ogl (void) { TRACE_VC_MEMORY ("state 0"); #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_EGL) bcm_host_init (); TRACE_VC_MEMORY ("after bcm_host_init"); #endif /* Start OpenGLES */ init_ogl (state); TRACE_VC_MEMORY ("after init_ogl"); /* Wrap the EGL display */ state->gst_display = gst_egl_display_new (state->display, NULL); /* Setup the model world */ init_model_proj (state); TRACE_VC_MEMORY ("after init_model_proj"); /* initialize the OGLES texture(s) */ init_textures (state); TRACE_VC_MEMORY ("after init_textures"); }
// init_ogl sets the display, OpenGL|ES context and screen information // state holds the OGLES model information void OpenDisplay() { int32_t success = 0; // raspberry pi specific initialization function bcm_host_init(); // get an EGL display connection eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); // initialize the EGL display connection eglInitialize(eglDisplay, NULL, NULL); // bind OpenVG API eglBindAPI(EGL_OPENVG_API); // get an appropriate EGL frame buffer configuration eglChooseConfig(eglDisplay, eglAttrib_list, &eglConfig, 1, &eglNum_config); // create an EGL rendering context eglContext = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, NULL); // set the context eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglContext); // save the display width graphics_get_display_size(0 /* LCD */, &displayWidth, &displayHeight); }
int main () { bcm_host_init(); printf("Note: ensure you have sufficient gpu_mem configured\n"); // Clear application state memset( state, 0, sizeof( *state ) ); // Start OGLES init_ogl(state); // Setup the model world init_model_proj(state); // initialise the OGLES texture(s) init_textures(state); while (!terminate) { update_model(state); redraw_scene(state); } exit_func(); return 0; }
qboolean RPI_Init (rendererstate_t *info, unsigned char *palette) { static EGL_DISPMANX_WINDOW_T nativewindow; DISPMANX_ELEMENT_HANDLE_T dispman_element; DISPMANX_DISPLAY_HANDLE_T dispman_display; DISPMANX_UPDATE_HANDLE_T dispman_update; VC_RECT_T dst_rect; VC_RECT_T src_rect; int rw, rh; if (!EGL_LoadLibrary(info->subrenderer)) { Con_Printf("couldn't load EGL library\n"); return false; } bcm_host_init(); graphics_get_display_size(0 /* LCD */, &rw, &rh); Con_Printf("Screen size is actually %i*%i\n", rw, rh); if (info->width < 64 || info->height < 64) { info->width = rw; info->height = rh; } dispman_display = vc_dispmanx_display_open(0 /* LCD */); dispman_update = vc_dispmanx_update_start(0); dst_rect.x = 0; dst_rect.y = 0; dst_rect.width = info->width; dst_rect.height = info->height; src_rect.x = 0; src_rect.y = 0; src_rect.width = info->width << 16; src_rect.height = info->height << 16; vid.pixelwidth = info->width; vid.pixelheight = info->height; dispman_element = vc_dispmanx_element_add(dispman_update, dispman_display, 0/*layer*/, &dst_rect, 0/*src*/, &src_rect, DISPMANX_PROTECTION_NONE, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/); nativewindow.element = dispman_element; nativewindow.width = info->width; nativewindow.height = info->height; vc_dispmanx_update_submit_sync(dispman_update); if (!EGL_Init(info, palette, &nativewindow, EGL_DEFAULT_DISPLAY)) { Con_Printf("couldn't initialise EGL context\n"); return false; } GL_Init(&EGL_Proc); return true; }
int init_SDL(void) { joy[0]=0; joy[1]=0; joy[2]=0; joy[3]=0; if (SDL_Init(SDL_INIT_JOYSTICK) < 0) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError()); return(0); } sdlscreen = SDL_SetVideoMode(0,0, 16, SDL_SWSURFACE); //We handle up to four joysticks if(SDL_NumJoysticks()) { int i; SDL_JoystickEventState(SDL_ENABLE); for(i=0;i<SDL_NumJoysticks();i++) { joy[i]=SDL_JoystickOpen(i); //Check for valid joystick, some keyboards //aren't SDL compatible if(joy[i]) { if (SDL_JoystickNumAxes(joy[i]) > 28) { SDL_JoystickClose(joy[i]); joy[i]=0; logoutput("Error detected invalid joystick/keyboard\n"); } else joyCount++; } } if(joy[0]) logoutput("Found %d joysticks\n",joyCount); } else joyCount=1; //sq frig number of players for keyboard //joyCount=2; SDL_EventState(SDL_ACTIVEEVENT,SDL_IGNORE); SDL_EventState(SDL_SYSWMEVENT,SDL_IGNORE); SDL_EventState(SDL_VIDEORESIZE,SDL_IGNORE); SDL_EventState(SDL_USEREVENT,SDL_IGNORE); SDL_ShowCursor(SDL_DISABLE); //Initialise dispmanx bcm_host_init(); //Clean exits, hopefully! atexit(exitfunc); return(1); }
int Initialize() { fbfd = 0; fbp = 0; setlogmask(LOG_UPTO(LOG_DEBUG)); openlog("fbcp", LOG_NDELAY | LOG_PID, LOG_USER); bcm_host_init(); display = vc_dispmanx_display_open(0); if (!display) { syslog(LOG_ERR, "Unable to open primary display"); return -1; } ret = vc_dispmanx_display_get_info(display, &display_info); if (ret) { syslog(LOG_ERR, "Unable to get primary display information"); return -1; } syslog(LOG_INFO, "Primary display is %d x %d", display_info.width, display_info.height); fbfd = open("/dev/fb1", O_RDWR); if (!fbfd) { syslog(LOG_ERR, "Unable to open secondary display"); return -1; } if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) { syslog(LOG_ERR, "Unable to get secondary display information"); return -1; } if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { syslog(LOG_ERR, "Unable to get secondary display information"); return -1; } syslog(LOG_INFO, "Second display is %d x %d %dbps\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel); screen_resource = vc_dispmanx_resource_create(VC_IMAGE_RGB565, vinfo.xres, vinfo.yres, &image_prt); if (!screen_resource) { syslog(LOG_ERR, "Unable to create screen buffer"); close(fbfd); vc_dispmanx_display_close(display); return -1; } fbp = (char*) mmap(0, finfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); if (fbp <= 0) { syslog(LOG_ERR, "Unable to create mamory mapping"); close(fbfd); ret = vc_dispmanx_resource_delete(screen_resource); vc_dispmanx_display_close(display); return -1; } vc_dispmanx_rect_set(&rect1, 0, 0, vinfo.xres, vinfo.yres); return 1; }
JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_initIDs (JNIEnv *env, jclass clazz) { bcm_host_init(); // TODO: bcm_host_deinit(); DBG_PRINT( "BCM.Display initIDs ok\n" ); return JNI_TRUE; }
ViewBackendBCMRPi::ViewBackendBCMRPi() : m_elementHandle(DISPMANX_NO_HANDLE) , m_width(0) , m_height(0) { bcm_host_init(); m_displayHandle = vc_dispmanx_display_open(0); }
void ofxRaspicam::setup() { MMAL_STATUS_T status = MMAL_SUCCESS; bcm_host_init(); create_camera_component(); create_encoder_component(); camera_still_port = photo.camera->output[MMAL_CAMERA_CAPTURE_PORT]; encoder_input_port = photo.encoder_component->input[0]; encoder_output_port = photo.encoder_component->output[0]; VCOS_STATUS_T vcos_status; ofLogVerbose() << "Connecting camera stills port to encoder input port"; // Now connect the camera to the encoder status = connect_ports(camera_still_port, encoder_input_port, &photo.encoder_connection); if (status != MMAL_SUCCESS) { ofLogVerbose() << "connect camera video port to encoder input FAIL"; }else { ofLogVerbose() << "connect camera video port to encoder input PASS"; } // Set up our userdata - this is passed though to the callback where we need the information. // Null until we open our filename callback_data.file_handle = NULL; callback_data.photo = &photo; vcos_status = vcos_semaphore_create(&callback_data.complete_semaphore, "RaspiStill-sem", 0); vcos_assert(vcos_status == VCOS_SUCCESS); encoder_output_port->userdata = (struct MMAL_PORT_USERDATA_T *)&callback_data; ofLogVerbose() << "Enabling encoder output port"; // Enable the encoder output port and tell it its callback function status = mmal_port_enable(encoder_output_port, encoder_buffer_callback); if (status != MMAL_SUCCESS) { ofLogVerbose() << "Setup encoder output FAIL, error: " << status; }else { ofLogVerbose() << "Setup encoder output PASS"; } }
void init(void) { signal(SIGINT, sig_handler); signal(SIGPIPE, sig_handler); g_stop = 0; bcm_host_init(); bzero((void *)&g_data, sizeof (g_data)); fprintf(stderr, "starting program with %ix%i %ifps\n", WIDTH, HEIGHT, FPS); }
int main (int argc, char **argv) { if (argc < 2) { printf("Usage: %s <filename>\n", argv[0]); exit(1); } bcm_host_init(); return video_decode_test(argv[1]); }
int graphics_setup (void) { #ifdef PICASSO96 picasso_InitResolutions(); InitPicasso96(); #endif bcm_host_init(); return 1; }
int32_t ilctts_initialize() { OMX_ERRORTYPE omx_err; bcm_host_init(); omx_err = OMX_Init(); if (omx_err != OMX_ErrorNone) { ERROR("OMX_Init returned error in ilctts_initialize: %d", omx_err); } return (omx_err == OMX_ErrorNone ? 0 : -1); } // end ilctts_initialize
bool PlatformRPI::Init() { bool bRes = false; bcm_host_init(); bRes = true; return bRes; }
int main () { char vertex_shader[512]; char fragment_shader[512]; char geometry_shader[512]; int terminate = 0; GLfloat cx, cy; bcm_host_init(); // Clear application state memset( state, 0, sizeof( *state ) ); // Start OGLES init_ogl(state); glm::vec3 resolution((float)state->screen_width,(float)state->screen_height,0.0f); cx = state->screen_width/2; cy = state->screen_height/2; state->verbose=1; Shader shader(vertex_shader, fragment_shader,geometry_shader); init_shaders(state); //glBindAttribLocation (shader.Program, 0 , "position"); shader.linkProg(); shader.Use(); state->program=shader.Program; GLint resLoc = glGetUniformLocation(shader.Program, "iResolution"); glUniform3f(resLoc,resolution.x,resolution.y,resolution.z); GLfloat currentTime = 0.0f; GLint timeLoc = glGetUniformLocation(shader.Program, "time"); glUniform1f(timeLoc,currentTime); //draw_mandelbrot_to_texture(state, cx, cy, 0.003); while (!terminate) { int x, y, b; currentTime=currentTime+0.02; timeLoc = glGetUniformLocation(shader.Program, "time"); glUniform1f(timeLoc,currentTime); b = get_mouse(state, &x, &y); if (b) break; draw_triangles(state, cx, cy, 0.003, x, y); } return 0; }
/// // esInitContext() // // Initialize ES utility context. This must be called before calling any other // functions. // void ESUTIL_API esInitContext ( ESContext *esContext ) { #ifdef RPI_NO_X bcm_host_init(); #endif if ( esContext != NULL ) { memset( esContext, 0, sizeof( ESContext) ); } }
int main() { bcm_host_init(); memset(g, 0, sizeof(*g)); start(); while (!g->done) { update(); } stop(); return 0; }
DISPMANX_DISPLAY_HANDLE_T getBCMDisplay(const SDL_SysWMinfo* pSDLWMInfo) { bcm_host_init(); DISPMANX_DISPLAY_HANDLE_T display = vc_dispmanx_display_open(DISPMANX_ID_MAIN_LCD); if (display == DISPMANX_NO_HANDLE) { throw Exception(AVG_ERR_VIDEO_GENERAL, "No BCM display available."); } return display; }
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengles_EGL_neglCreateWindowSurface(JNIEnv *env, jclass clazz, jlong dpy_ptr, jlong config_ptr, jlong win, jlong attrib_list) { EGLDisplay dpy = (EGLDisplay)(intptr_t)dpy_ptr; EGLConfig config = (EGLConfig)(intptr_t)config_ptr; const EGLint *attrib_list_address = (EGLint *)(intptr_t)attrib_list; //@@spsn int32_t success = 0; EGLBoolean result; EGLint num_config; EGLint screen_width; EGLint screen_height; static EGL_DISPMANX_WINDOW_T nativewindow; DISPMANX_ELEMENT_HANDLE_T dispman_element; DISPMANX_DISPLAY_HANDLE_T dispman_display; DISPMANX_UPDATE_HANDLE_T dispman_update; VC_RECT_T dst_rect; VC_RECT_T src_rect; bcm_host_init(); // create an EGL window surface success = graphics_get_display_size(0 /* LCD */, &screen_width, &screen_height); dst_rect.x = 0; dst_rect.y = 0; dst_rect.width = screen_width; dst_rect.height = screen_height; src_rect.x = 0; src_rect.y = 0; src_rect.width = screen_width << 16; src_rect.height = screen_height << 16; VC_DISPMANX_ALPHA_T alpha; alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS; alpha.opacity = 255; alpha.mask = 0; dispman_display = vc_dispmanx_display_open( 0 /* LCD */); dispman_update = vc_dispmanx_update_start( 0 ); dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display, 0/*layer*/, &dst_rect, 0/*src*/, &src_rect, DISPMANX_PROTECTION_NONE, &alpha/*alpha*/, 0/*clamp*/, 0/*transform*/); nativewindow.element = dispman_element; nativewindow.width = screen_width; nativewindow.height = screen_height; vc_dispmanx_update_submit_sync( dispman_update ); // return (intptr_t)eglCreateWindowSurface(dpy, config, (EGLNativeWindowType)(intptr_t)win, attrib_list_address); return (intptr_t)eglCreateWindowSurface(dpy, config, (EGLNativeWindowType)(intptr_t)&nativewindow, attrib_list_address); }
int main(int argc, char *argv[]) { int width, height; unsigned int orientation; struct timeval t1, t2; struct timezone tz; float deltatime; unsigned char *image; GL_STATE_T state, *p_state = &state; //image = esLoadTGA("jan.tga", &width, &height); gettimeofday ( &t1 , &tz ); if (argc < 2) { printf("Usage: %s <filename>\n", argv[0]); return -1; } image = loadJPEG(argv[1], 1920, 1080, &width, &height, &orientation); if (image == NULL) { fprintf(stderr, "No such image\n"); exit(1); } fprintf(stderr, "Image is %d x %d\n", width, height); gettimeofday(&t2, &tz); deltatime = (float)(t2.tv_sec - t1.tv_sec + (t2.tv_usec - t1.tv_usec) * 1e-6); printf("Image loaded in %1.4f seconds\n", deltatime); bcm_host_init(); gl_display_init(p_state); #if 1 if(!gl_image_init(p_state, image, width, height, orientation)) return 0; gl_display_register_draw_func(p_state, gl_image_draw); #endif #if 0 if (!gl_rect_init(p_state, width, height, 1.0f, 0.0f, 0.0f)) return 0; gl_display_register_draw_func(p_state, gl_rect_draw); #endif eglSwapBuffers(p_state->display, p_state->surface); esMainLoop(p_state); return 0; // not reached }