Esempio n. 1
0
/**
 * Returns the screen dimension rect to be used
 * @return The screen dimension rect to be used
 */
PixelSize
SystemWindowSize()
{
#if defined(WIN32) && !defined(_WIN32_WCE)
  unsigned width = CommandLine::width + 2 * GetSystemMetrics(SM_CXFIXEDFRAME);
  unsigned height = CommandLine::height + 2 * GetSystemMetrics(SM_CYFIXEDFRAME)
    + GetSystemMetrics(SM_CYCAPTION);

  return { width, height };
#else
  #ifdef WIN32
  return { GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) };
#elif defined(ANDROID)
  return { native_view->get_width(), native_view->get_height() };
#elif defined(USE_VIDEOCORE)
  uint32_t width, height;
  return graphics_get_display_size(0, &width, &height) >= 0
    ? PixelSize(width, height)
    : PixelSize(640, 480);
#else
  /// @todo implement this properly for SDL/UNIX
  return { CommandLine::width, CommandLine::height };
  #endif /* !WIN32 */

#endif
}
static gboolean
gst_gl_window_dispmanx_egl_open (GstGLWindow * window, GError ** error)
{
  GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
  gint ret = graphics_get_display_size (0, &window_egl->dp_width,
      &window_egl->dp_height);
  if (ret < 0) {
    GST_ERROR ("Can't open display");
    return FALSE;
  }
  GST_DEBUG ("Got display size: %dx%d\n", window_egl->dp_width,
      window_egl->dp_height);

  window_egl->native.width = 0;
  window_egl->native.height = 0;
  window_egl->display = vc_dispmanx_display_open (0);
  window_egl->native.element = 0;

  window_egl->main_context = g_main_context_new ();
  window_egl->loop = g_main_loop_new (window_egl->main_context, FALSE);

  window_resize (window_egl, 16, 16);

  return TRUE;
}
Esempio n. 3
0
// instrument this a bit like QGLWidget by adding a
// a context so we can choose GL version rgb size etc.
// This can be done with a context object at some stage.
EGLWindow::EGLWindow(EGLconfig *_config)
{
 // toggle we don't yet have an active surface
 m_activeSurface=false;
 // set default to not upscale the screen resolution
 m_upscale=false;

 // set our display values to 0 (not once ported to cx11 will use nullptr but
 // current pi default compiler doesn't support it yet
 m_display=0;
 m_context=0;
 m_surface=0;

 // now find the max display size (we will use this later to assert if the user
 // defined sizes are in the correct bounds
 int32_t success = 0;
 success = graphics_get_display_size(0 , &m_width, &m_height);
 assert( success >= 0 );
 std::cout<<"max width and height "<<m_width<<" "<<m_height<<"\n";
 m_maxWidth=m_width;
 m_maxHeight=m_height;
 // if we have a user defined config we will use that else we need to create one
 if (_config == 0)
 {
 	std::cout<<"making new config\n";
	m_config= new EGLconfig();
 }
 else
 {
		m_config=_config;
 }
 // our client class must now call make surface as we now have a constructed object

}
Esempio n. 4
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;
}
Esempio n. 5
0
///
//  WinCreate() - RaspberryPi, direct surface (No X, Xlib)
//
//      This function initialized the display and window for EGL
//
EGLBoolean WinCreate(ESContext *esContext, const char *title) 
{
   int32_t success = 0;

   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 display_width;
   int display_height;

   // create an EGL window surface, passing context width/height
   success = graphics_get_display_size(0 /* LCD */, &display_width, &display_height);
   if ( success < 0 )
   {
      return EGL_FALSE;
   }
   
   // You can hardcode the resolution here:
   // <JJW> : But I don't want to hardcode resolution!
   // display_width = 640;
   // display_height = 480;

   dst_rect.x = 0;
   dst_rect.y = 0;
   dst_rect.width = display_width;
   dst_rect.height = display_height;
      
   src_rect.x = 0;
   src_rect.y = 0;
   src_rect.width = display_width << 16;
   src_rect.height = display_height << 16;   

   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, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/);
      
   nativewindow.element = dispman_element;
   nativewindow.width = display_width;
   nativewindow.height = display_height;
   vc_dispmanx_update_submit_sync( dispman_update );

   //JJW : save window resolution of LCD moniter in esContext
   esContext->width = display_width;
   esContext->height = display_height;
   
   esContext->hWnd = &nativewindow;

	return EGL_TRUE;
}
EGLNativeWindowType
platform_create_native_window (gint width, gint height, gpointer * window_data)
{
  DISPMANX_ELEMENT_HANDLE_T dispman_element;
  DISPMANX_DISPLAY_HANDLE_T dispman_display;
  DISPMANX_UPDATE_HANDLE_T dispman_update;
  RPIWindowData *data;
  VC_RECT_T dst_rect;
  VC_RECT_T src_rect;
  GstVideoRectangle src, dst, res;

  uint32_t dp_height;
  uint32_t dp_width;

  int ret;

  ret = graphics_get_display_size (0, &dp_width, &dp_height);
  if (ret < 0) {
    GST_ERROR ("Can't open display");
    return (EGLNativeWindowType) 0;
  }
  GST_DEBUG ("Got display size: %dx%d\n", dp_width, dp_height);
  GST_DEBUG ("Source size: %dx%d\n", width, height);

  /* Center width*height frame inside dp_width*dp_height */
  src.w = width;
  src.h = height;
  src.x = src.y = 0;
  dst.w = dp_width;
  dst.h = dp_height;
  dst.x = dst.y = 0;
  gst_video_sink_center_rect (src, dst, &res, TRUE);

  dst_rect.x = res.x;
  dst_rect.y = res.y;
  dst_rect.width = res.w;
  dst_rect.height = res.h;

  src_rect.x = 0;
  src_rect.y = 0;
  src_rect.width = width << 16;
  src_rect.height = height << 16;

  dispman_display = vc_dispmanx_display_open (0);
  dispman_update = vc_dispmanx_update_start (0);
  dispman_element = vc_dispmanx_element_add (dispman_update,
      dispman_display, 0, &dst_rect, 0, &src_rect,
      DISPMANX_PROTECTION_NONE, 0, 0, 0);

  *window_data = data = g_slice_new0 (RPIWindowData);
  data->d = dispman_display;
  data->w.element = dispman_element;
  data->w.width = width;
  data->w.height = height;
  vc_dispmanx_update_submit_sync (dispman_update);

  return (EGLNativeWindowType) data;
}
Esempio n. 7
0
bool
NativeStateDispmanx::create_window(WindowProperties const& properties)
{
    int dispmanx_output = 0; /* LCD */

    if (!properties.fullscreen) {
        Log::error("Error: Dispmanx only supports full screen rendering.\n");
	return false;
    }

    unsigned screen_width, screen_height;
    if (graphics_get_display_size(dispmanx_output,
				  &screen_width, &screen_height) < 0) {
        Log::error("Error: Couldn't get screen width/height.\n");
	return false;
    }

    properties_.fullscreen = properties.fullscreen;
    properties_.visual_id = properties.visual_id;
    properties_.width = screen_width;
    properties_.height = screen_height;

    dispmanx_display = vc_dispmanx_display_open(dispmanx_output);

    VC_RECT_T dst_rect;
    VC_RECT_T src_rect;
    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;

    dispmanx_update = vc_dispmanx_update_start(0);

    dispmanx_element = vc_dispmanx_element_add(dispmanx_update,
					       dispmanx_display,
					       0 /*layer*/,
					       &dst_rect,
					       0 /*src*/,
					       &src_rect,
					       DISPMANX_PROTECTION_NONE,
					       0 /*alpha*/,
					       0 /*clamp*/,
					       DISPMANX_NO_ROTATE);

    egl_dispmanx_window.element = dispmanx_element;
    egl_dispmanx_window.width = dst_rect.width;
    egl_dispmanx_window.height = dst_rect.height;
    vc_dispmanx_update_submit_sync(dispmanx_update);

    return true;
}
Esempio n. 8
0
BBEGLContext *createDisplayContext(){
	EGLContext context;
	EGLSurface surface;

	static const EGLint contextAttribs[]={
		EGL_CONTEXT_CLIENT_VERSION,2,
		EGL_NONE};

	context=eglCreateContext(display,config,EGL_NO_CONTEXT,contextAttribs);
	assert(eglGetError()==EGL_SUCCESS);

	unsigned int width,height;

	graphics_get_display_size(0,&width,&height);
	printf("display size is %dx%d\n",width,height);

	VC_RECT_T dst={0};
	dst.width=width;
	dst.height=height;
	VC_RECT_T src={0};
	src.width=width<<16;
	src.height=height<<16;

	static EGL_DISPMANX_WINDOW_T nativewindow;

	DISPMANX_ELEMENT_HANDLE_T dispman_element;
	DISPMANX_DISPLAY_HANDLE_T dispman_display;
	DISPMANX_UPDATE_HANDLE_T dispman_update;

	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, 0/*src*/,
                                             &src, DISPMANX_PROTECTION_NONE, 0 /*alpha*/,
                                             0/*clamp*/, DISPMANX_NO_ROTATE/*transform*/);

	nativewindow.element = dispman_element;
 	nativewindow.width = width;
	nativewindow.height = height;

	vc_dispmanx_update_submit_sync( dispman_update );

	surface=eglCreateWindowSurface(display,config,&nativewindow,NULL);

	eglMakeCurrent(display,surface,surface,context);

	DeviceContext.width=width;
	DeviceContext.height=height;
	DeviceContext.depth=32;
	DeviceContext.hertz=60;
	DeviceContext.context=context;
	DeviceContext.surface=surface;

	return &DeviceContext;
}
Esempio n. 9
0
void gp2x_frontend_init(void)
{
	int ret;
        
	uint32_t display_width, display_height;
    
	VC_RECT_T dst_rect;
	VC_RECT_T src_rect;
    
	surface_width = 640;
	surface_height = 480;
    
	gp2x_screen8=0;
	gp2x_screen15=(unsigned short *) calloc(1, 640*480*2);
	
	graphics_get_display_size(0 /* LCD */, &display_width, &display_height);
    
	dispman_display = vc_dispmanx_display_open( 0 );
	assert( dispman_display != 0 );
        
	// Add border around bitmap for TV
	display_width -= options.display_border * 2;
	display_height -= options.display_border * 2;
    
	//Create two surfaces for flipping between
	//Make sure bitmap type matches the source for better performance
	uint32_t crap;
	resource0 = vc_dispmanx_resource_create(VC_IMAGE_RGB565, 640, 480, &crap);
	resource1 = vc_dispmanx_resource_create(VC_IMAGE_RGB565, 640, 480, &crap);
    
	vc_dispmanx_rect_set( &dst_rect, options.display_border, options.display_border,
                         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
	dispman_update = vc_dispmanx_update_start( 0 );
    
	// create the 'window' element - based on the first buffer resource (resource0)
	dispman_element = vc_dispmanx_element_add(  dispman_update,
                                              dispman_display,
                                              1,
                                              &dst_rect,
                                              resource0,
                                              &src_rect,
                                              DISPMANX_PROTECTION_NONE,
                                              0,
                                              0,
                                              (DISPMANX_TRANSFORM_T) 0 );
    
	ret = vc_dispmanx_update_submit_sync( dispman_update );
    
	// setup swapping of double buffers
	cur_res = resource1;
	prev_res = resource0;
    
}
Esempio n. 10
0
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);
}
Esempio n. 11
0
void EGLInitializeSubsystemWindow(int requested_width, int requested_height,
int& width, int& height, void *&window) {
    bcm_host_init();

    int success = graphics_get_display_size(0 /* LCD */,
        (uint32_t *)&width, (uint32_t *)&height);
    assert(success >= 0);

    static EGL_DISPMANX_WINDOW_T native_window;
    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;

    dst_rect.x = 0;
    dst_rect.y = 0;
    dst_rect.width = width;
    dst_rect.height = height;

    src_rect.x = 0;
    src_rect.y = 0;
    src_rect.width = width << 16;
    src_rect.height = height << 16;

    dispman_display = vc_dispmanx_display_open(0 /* LCD */);
    dispman_update = vc_dispmanx_update_start(0);

    VC_DISPMANX_ALPHA_T alpha;
    alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS;
    alpha.opacity = 0xFF;
    alpha.mask = DISPMANX_NO_HANDLE;
    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*/,
        (DISPMANX_TRANSFORM_T)0/*transform*/);

//    nativewindow.element = dispman_element;
//    nativewindow.width = width;
//    nativewindow.height = height;

    vc_dispmanx_update_submit_sync(dispman_update);
    check();

    LinuxFBInitializeUI(width, height);

    native_window.element = dispman_element;
    native_window.width = width;
    native_window.height = height;
    window = &native_window;
}
Esempio n. 12
0
JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initNative
  (JNIEnv *env, jobject obj)
{
    uint32_t screen_width;
    uint32_t screen_height;
    int32_t success = 0;

    if( graphics_get_display_size(0 /* LCD */, &screen_width, &screen_height) >= 0 ) {
        DBG_PRINT( "BCM.Screen initNative ok %dx%d\n", screen_width, screen_height );
        (*env)->CallVoidMethod(env, obj, setScreenSizeID, (jint) screen_width, (jint) screen_height);
    } else {
        DBG_PRINT( "BCM.Screen initNative failed\n" );
    }
}
Esempio n. 13
0
//function returns screensize seperated only to make porting easier
//NOTE: super special function only works after bcm_host_init() and possibly others
struct screenSizeStruct returnScreenSize(void)
{
  //currently very broken? check
  struct screenSizeStruct currentScreenSize;
  uint32_t currentScreenWidth = 0;
  uint32_t currentScreenHeight = 0;

  //super special broadcom only function
  graphics_get_display_size(0/*framebuffer 0*/, &currentScreenWidth, &currentScreenHeight);
  currentScreenSize.width = (int)currentScreenWidth;
  currentScreenSize.height = (int)currentScreenHeight;

  return currentScreenSize;
}
Esempio n. 14
0
int
RPI_VideoInit(_THIS)
{
    SDL_VideoDisplay display;
    SDL_DisplayMode current_mode;
    SDL_DisplayData *data;
    uint32_t w,h;

    /* Initialize BCM Host */
    bcm_host_init();

    SDL_zero(current_mode);

    if (graphics_get_display_size( 0, &w, &h) < 0) {
        return -1;
    }

    current_mode.w = w;
    current_mode.h = h;
    /* FIXME: Is there a way to tell the actual refresh rate? */
    current_mode.refresh_rate = 60;
    /* 32 bpp for default */
    current_mode.format = SDL_PIXELFORMAT_ABGR8888;

    current_mode.driverdata = NULL;

    SDL_zero(display);
    display.desktop_mode = current_mode;
    display.current_mode = current_mode;

    /* Allocate display internal data */
    data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
    if (data == NULL) {
        return SDL_OutOfMemory();
    }

    data->dispman_display = vc_dispmanx_display_open( 0 /* LCD */);

    display.driverdata = data;

    SDL_AddVideoDisplay(&display);

#ifdef SDL_INPUT_LINUXEV    
    SDL_EVDEV_Init();
#endif    
    
    RPI_InitMouse(_this);

    return 1;
}
Esempio n. 15
0
VideoMode VideoModeImpl::getDesktopMode()
{
    static bool initialized=false;

    if (!initialized)
    {
        bcm_host_init();
        initialized=true;
    }

    uint32_t width( 0 ), height( 0 );
    graphics_get_display_size( 0 /* LCD */, &width, &height );
    return VideoMode(width, height);
}
int 
pf_re_native_init (EGLNativeDisplayType *display_out, 
		   EGLNativeWindowType *window_out,
		   int w, int h)
{
bcm_host_init();

   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 success;
int screen_width = 800, screen_height = 600;

#if 1
   // create an EGL window surface
   success = graphics_get_display_size(0 /* LCD */, &screen_width, &screen_height);
   if ( success < 0 ) 	
	{
	fprintf (stderr, "Cannot get display size\n");
	exit (1);
}
#endif
   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;

   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, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/);

   nativewindow.element = dispman_element;
   nativewindow.width = screen_width;
   nativewindow.height = screen_height;
   vc_dispmanx_update_submit_sync( dispman_update );


  *display_out = EGL_DEFAULT_DISPLAY;
  *window_out = &nativewindow;
}
Esempio n. 17
0
void osd_init(struct osd_t* osd)
{
  uint32_t display_width, display_height;
  char str[2] = { 0, 0 };
  uint32_t width, height;
  int n;
  int s;

  s = gx_graphics_init(tiresias_pcfont, sizeof(tiresias_pcfont));
  assert(s == 0);

  s = graphics_get_display_size(0, &display_width, &display_height);
  osd->display_width = display_width;
  osd->display_height = display_height;

  printf("osd_init: %d %d\n", display_width, display_height);
  
  assert(s == 0);
  //fprintf(stderr,"Display width=%d, height=%d\n",display_width,display_height);

  /* The main OSD image */
  s = gx_create_window(SCREEN, display_width, display_height, GRAPHICS_RESOURCE_RGBA32, &osd->img);
  assert(s == 0);
  graphics_resource_fill(osd->img, 0, 0, display_width, display_height, GRAPHICS_RGBA32(0,0,0,0));

  graphics_display_resource(osd->img, 0, OSD_LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 1);

  /* A full-screen black image to either remove any left-over console text (BG_LAYER) or to hide the video (FG_LAYER) */
  s = gx_create_window(SCREEN, display_width, display_height, GRAPHICS_RESOURCE_RGBA32, &osd->img_blank);
  assert(s == 0);
  graphics_resource_fill(osd->img_blank, 0, 0, display_width, display_height, GRAPHICS_RGBA32(0,0,0,255));

  graphics_display_resource(osd->img_blank, 0, BG_LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 1);

  osd->video_blanked = 0;
  osd->osd_cleartime = 0.0;
  osd->last_now = time(NULL);
  
  pthread_mutex_init(&osd->osd_mutex,NULL);
   
  // cache font widths since graphics_resource_text_dimensions_ext is kind of slow
  for (n = 32; n < 256; n++) {
    str[0] = n;
    graphics_resource_text_dimensions_ext(osd->img, str, 1, &width, &height, 40); 
    fontWidth[n] = (uint8_t)width;
  }
    
  (void)s; // remove compiler warning
}
Esempio n. 18
0
int main(void)
{
   uint32_t width, height;
   bcm_host_init();
   int s;

   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;

   s = graphics_get_display_size(0 /* LCD */, &width, &height);
   assert( s >= 0 );

   dst_rect.x = 0;
   dst_rect.y = 0;
   dst_rect.width = width;
   dst_rect.height = height;
      
   src_rect.x = 0;
   src_rect.y = 0;
   src_rect.width = width << 16;
   src_rect.height = height << 16;        

   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,
      1/*layer*/, &dst_rect, 0/*src*/,
      &src_rect, DISPMANX_PROTECTION_NONE, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/);
      
   nativewindow.element = dispman_element;
   nativewindow.width = width;
   nativewindow.height = height;
   vc_dispmanx_update_submit_sync( dispman_update );

   init(&nativewindow);

   while (1) {
      render(width, height);
      rotateN += 1.0f;
   }
   deinit();

   return 0;
}
Esempio n. 19
0
int bbEGLGraphicsGraphicsModes( int *imodes,int maxcount ){

	if(_hosting==0) _initDevice();

	unsigned int width,height;

	graphics_get_display_size(0,&width,&height);

	*imodes++=(int)width;
	*imodes++=(int)height;
	*imodes++=24;
	*imodes++=60;

	return 1;
}
void DisplayWindowMupen64plus::_getDisplaySize()
{
#ifdef VC
	if( m_bFullscreen ) {
		// Use VC get_display_size function to get the current screen resolution
		u32 fb_width;
		u32 fb_height;
		if (graphics_get_display_size(0 /* LCD */, &fb_width, &fb_height) < 0)
			printf("ERROR: Failed to get display size\n");
		else {
			m_screenWidth = fb_width;
			m_screenHeight = fb_height;
		}
	}
#endif
}
Esempio n. 21
0
/*!***********************************************************************
 @Function		OsGetNativeWindowType
 @Return		The 'NativeWindowType' for EGL
 @description	Called from InitAPI() to get the NativeWindowType
*************************************************************************/
void *PVRShellInit::OsGetNativeWindowType()
{
	unsigned int iWidth, iHeight;
	if(graphics_get_display_size(0 /* LCD */, &iWidth, &iHeight) < 0)
	{
		m_pShell->PVRShellOutputDebug("ERROR: graphics_get_display_size() failed.\n");
		return 0;
	}

	m_pShell->PVRShellOutputDebug("Creating Pi display with size: %dx%d\n", iWidth, iHeight);

	VC_RECT_T dst_rect;
	VC_RECT_T src_rect;
	DISPMANX_ELEMENT_HANDLE_T dispman_element;
	DISPMANX_DISPLAY_HANDLE_T dispman_display;
	DISPMANX_UPDATE_HANDLE_T dispman_update;
	static EGL_DISPMANX_WINDOW_T nativeWindow;

	dst_rect.x = 0;
	dst_rect.y = 0;
	dst_rect.width 	= iWidth;
	dst_rect.height = iHeight;
	src_rect.x = 0;
	src_rect.y = 0;
	src_rect.width 	= iWidth  << 16;
	src_rect.height = iHeight << 16;

	dispman_display = vc_dispmanx_display_open(0);
	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,
							0, // alpha
							0, // clamp
							DISPMANX_NO_ROTATE);
	nativeWindow.element = dispman_element;
	nativeWindow.width   = iWidth;
	nativeWindow.height  = iHeight;
	vc_dispmanx_update_submit_sync(dispman_update);

	return (void*)&nativeWindow;
}
Esempio n. 22
0
void determineInitialResolution( void )
{
   int displayId;
   uint32_t width, height;

   displayId= DISPMANX_ID_MAIN_LCD;
   int32_t result= graphics_get_display_size( displayId,
                                              &width,
                                              &height );

   if ( result == 0 )
   {
      printf("module: display %dx%d\n", width, height);
      WstCompositorResolutionChangeBegin( compositor );
      WstCompositorResolutionChangeEnd( compositor, width, height );
   }
}
Esempio n. 23
0
int main(void)
{
   GRAPHICS_RESOURCE_HANDLE img;
   uint32_t width, height;
   int LAYER=1;
   bcm_host_init();
   int s;

   s = gx_graphics_init(".");
   assert(s == 0);

   s = graphics_get_display_size(0, &width, &height);
   assert(s == 0);

   s = gx_create_window(0, width, height, GRAPHICS_RESOURCE_RGBA32, &img);
   assert(s == 0);

   // transparent before display to avoid screen flash
   graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0x00));

   graphics_display_resource(img, 0, LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 1);

   uint32_t text_size = 10;
   while (1) {
      const char *text = "The quick brown fox jumps over the lazy dog";
      uint32_t y_offset = height-60+text_size/2;
      graphics_resource_fill(img, 0, 0, width, height, GRAPHICS_RGBA32(0,0,0,0x00));
      // blue, at the top (y=40)
      graphics_resource_fill(img, 0, 40, width, 1, GRAPHICS_RGBA32(0,0,0xff,0xff));

      // green, at the bottom (y=height-40)
      graphics_resource_fill(img, 0, height-40, width, 1, GRAPHICS_RGBA32(0,0xff,0,0xff));

      // draw the subtitle text
      render_subtitle(img, text, 0, text_size,  y_offset);
      graphics_update_displayed_resource(img, 0, 0, 0, 0);
      text_size += 1;
      if (text_size > 50)
         text_size = 10;
   }

   graphics_display_resource(img, 0, LAYER, 0, 0, GRAPHICS_RESOURCE_WIDTH, GRAPHICS_RESOURCE_HEIGHT, VC_DISPMAN_ROT0, 0);
   graphics_delete_resource(img);

   return 0;
}
static gboolean
gst_gl_window_dispmanx_egl_open (GstGLWindow * window, GError ** error)
{
  GstGLWindowDispmanxEGL *window_egl = GST_GL_WINDOW_DISPMANX_EGL (window);
  gint ret = graphics_get_display_size (0, &window_egl->dp_width,
      &window_egl->dp_height);
  if (ret < 0) {
    g_set_error (error, GST_GL_WINDOW_ERROR,
        GST_GL_WINDOW_ERROR_RESOURCE_UNAVAILABLE, "Can't open display");
    return FALSE;
  }
  GST_DEBUG ("Got display size: %dx%d\n", window_egl->dp_width,
      window_egl->dp_height);

  window_egl->native.element = 0;

  return GST_GL_WINDOW_CLASS (parent_class)->open (window, error);
}
Esempio n. 25
0
void SubtitleRenderer::initialize_window(int layer) {
  ENFORCE(graphics_get_display_size(0 /* LCD */, &screen_width_, &screen_height_)
          >= 0);

  VC_RECT_T dst_rect;
  dst_rect.x = 0;
  dst_rect.y = 0;
  dst_rect.width = screen_width_;
  dst_rect.height = screen_height_;
     
  VC_RECT_T src_rect;
  src_rect.x = 0;
  src_rect.y = 0;
  src_rect.width = screen_width_ << 16;
  src_rect.height = screen_height_ << 16;        

  dispman_display_ = vc_dispmanx_display_open(0 /* LCD */);
  ENFORCE(dispman_display_);

  {
    auto dispman_update = vc_dispmanx_update_start(0);
    ENFORCE(dispman_update);
    SCOPE_EXIT {
      ENFORCE(!vc_dispmanx_update_submit_sync(dispman_update));
    };

    dispman_element_ =
        vc_dispmanx_element_add(dispman_update,
                                dispman_display_,
                                layer,
                                &dst_rect,
                                0 /*src*/,
                                &src_rect,
                                DISPMANX_PROTECTION_NONE,
                                0 /*alpha*/,
                                0 /*clamp*/,
                                (DISPMANX_TRANSFORM_T) 0 /*transform*/);
    ENFORCE(dispman_element_);
  }
}
Esempio n. 26
0
EGLBoolean WinCreate(ScreenSettings *sc)
{
  uint32_t success = 0;
  uint32_t width;
  uint32_t height;
  VC_RECT_T dst_rect;
  VC_RECT_T src_rect;
  DISPMANX_ELEMENT_HANDLE_T dispman_element;
  DISPMANX_DISPLAY_HANDLE_T dispman_display;
  DISPMANX_UPDATE_HANDLE_T dispman_update;
  static EGL_DISPMANX_WINDOW_T nativewindow;
  VC_DISPMANX_ALPHA_T alpha = {DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS, 255, 0};

  success = graphics_get_display_size(0, &width, &height);
  if (success < 0) return EGL_FALSE;
  
  if( width > _screen_max_size_ )
	width = _screen_max_size_; 
  if( height > _screen_max_size_ )
	height = _screen_max_size_; 
  
  sc->width = width;
  sc->height = height;

  vc_dispmanx_rect_set(&dst_rect, 0, 0, sc->width, sc->height);
  vc_dispmanx_rect_set(&src_rect, 0, 0, sc->width << 16, sc->height << 16);

  dispman_display = vc_dispmanx_display_open(0);
  dispman_update = vc_dispmanx_update_start(0);
  dispman_element = vc_dispmanx_element_add( dispman_update, dispman_display,
     0, &dst_rect, 0, &src_rect, DISPMANX_PROTECTION_NONE, &alpha, 0, ( DISPMANX_TRANSFORM_T )0);

  vc_dispmanx_update_submit_sync(dispman_update);
  nativewindow.element = dispman_element;
  nativewindow.width = width;
  nativewindow.height = height;
  sc->nativeWin = &nativewindow;
  return EGL_TRUE;
}
Esempio n. 27
0
int rpi_window_startup( xwl_api_provider_t * api )
{
	int success = 0;

	fprintf( stdout, "rpi_window_startup\n" );

	// init the broadcom device
	bcm_host_init();


	// initialize vcos and vchi
//	vcos_init();

	success = graphics_get_display_size( 0 /* LCD */, &window_width, &window_height );
	if ( success < 0 )
	{
		xwl_set_error( "Unable to get the display size!" );
		return 0;
	}

	return 1;
} // rpi_window_startup
Esempio n. 28
0
int omxAutoResize(ILCLIENT_T *client, IMAGE *inImage, IMAGE *outImage, const int display, 
			const int rotation, const char noAspect){
	
	outImage->pData = NULL;
	
	uint32_t sWidth, sHeight;

	if(outImage->height > 0 && outImage->width > 0){
		
		if(noAspect){
			return omxResize(client, inImage, outImage);
		}
		
		sWidth = outImage->width;
		sHeight= outImage->height;
	}else{
		graphics_get_display_size(display, &sWidth, &sHeight);
	}

	if(rotation == 90 || rotation == 270){
		uint32_t rotHeight = sHeight;
		sHeight = sWidth;
		sWidth = rotHeight;
	}
	
	float dAspect = (float) sWidth / sHeight;
	float iAspect = (float) inImage->width / inImage->height;

	if(dAspect > iAspect){
		outImage->height = sHeight;
		outImage->width = ALIGN2((int) (sHeight * iAspect));
	}else{
		outImage->width = sWidth;
		outImage->height = ALIGN2((int) (sWidth / iAspect));
	}
	
	return omxResize(client, inImage, outImage);
}
Esempio n. 29
0
static void *dispmanx_gfx_init(const video_info_t *video,
      const input_driver_t **input, void **input_data)
{
   struct dispmanx_video *_dispvars = calloc(1, sizeof(struct dispmanx_video));

   bcm_host_init();
   _dispvars->display = vc_dispmanx_display_open(0 /* LCD */);
   /* If the console framebuffer has active overscan settings, 
    * the user must have overscan_scale=1 in config.txt to have 
    * the same size for both fb console and dispmanx. */
   graphics_get_display_size(_dispvars->display, &_dispvars->dispmanx_width, &_dispvars->dispmanx_height);

   /* Setup surface parameters */
   _dispvars->vc_image_ptr     = 0;
   _dispvars->pageflip_pending = 0;	
   _dispvars->current_page     = NULL;
   _dispvars->menu_active      = false;
  
   /* Initialize the rest of the mutexes and conditions. */
   _dispvars->vsync_condition  = scond_new();
   _dispvars->vsync_cond_mutex = slock_new();
   _dispvars->pending_mutex    = slock_new();

   dispmanx_surface_init(_dispvars,
      video->rgb32 ? 4 : 2, 
      video->rgb32 ? VC_IMAGE_XRGB8888 : VC_IMAGE_RGB565, 
      0   /* layer */, 
      255 /* alpha */, 
      3,  /* numpages */
      &_dispvars->surfaces[MAIN_SURFACE]);

   if (input && input_data)
      *input = NULL;
  
   dispmanx_blank_console(_dispvars);
 
   return _dispvars;
}
/*	
	Copyright (c) 2012, Broadcom Europe Ltd
	All rights reserved.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions are met:
		* Redistributions of source code must retain the above copyright
		  notice, this list of conditions and the following disclaimer.
		* Redistributions in binary form must reproduce the above copyright
		  notice, this list of conditions and the following disclaimer in the
		  documentation and/or other materials provided with the distribution.
		* Neither the name of the copyright holder nor the
		  names of its contributors may be used to endorse or promote products
		  derived from this software without specific prior written permission.

	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
	ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
	WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
	DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
	DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
	(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
	ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
void RaspberryPiApplicationRunner::createEGLContext( ApplicationContext& applicationContext )
{
	// Don't forget to this at startup otherwise bcm function will fail like graphics_get_display_size 
	bcm_host_init();

	int32_t success = 0;
	EGLBoolean result;
	EGLint num_config;

	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;

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

	static const EGLint context_attributes[] = 
	{
		EGL_CONTEXT_CLIENT_VERSION, 2,
		EGL_NONE
	};
	EGLConfig config;

	// get an EGL display connection
	applicationContext.display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
	assert(applicationContext.display!=EGL_NO_DISPLAY);
	check();

	// initialize the EGL display connection
	result = eglInitialize(applicationContext.display, NULL, NULL);
	assert(EGL_FALSE != result);
	check();

	// get an appropriate EGL frame buffer configuration
	result = eglChooseConfig(applicationContext.display, attribute_list, &config, 1, &num_config);
	assert(EGL_FALSE != result);
	check();

	// get an appropriate EGL frame buffer configuration
	result = eglBindAPI(EGL_OPENGL_ES_API);
	assert(EGL_FALSE != result);
	check();

	// create an EGL rendering context
	applicationContext.context = eglCreateContext(applicationContext.display, config, EGL_NO_CONTEXT, context_attributes);
	assert(applicationContext.context!=EGL_NO_CONTEXT);
	check();

	// create an EGL window surface
	uint32_t width = 0;
	uint32_t height = 0;
	success = graphics_get_display_size(0 /* LCD */, &width, &height );
	assert( success >= 0 );

	applicationContext.width = width;
	applicationContext.height = height;


	dst_rect.x = 0;
	dst_rect.y = 0;
	dst_rect.width = width;
	dst_rect.height = height;

	src_rect.x = 0;
	src_rect.y = 0;
	src_rect.width = width << 16;
	src_rect.height = height << 16;        

	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, 0 /*alpha*/, 0/*clamp*/, 0/*transform*/);

	dispman_element = vc_dispmanx_element_add( dispman_update, dispman_display, 
		0/*layer*/, &dst_rect, 0/*src*/, 
		&src_rect, DISPMANX_PROTECTION_NONE, 0, (DISPMANX_CLAMP_T *)NULL, (DISPMANX_TRANSFORM_T)0 );

	nativewindow.element = dispman_element;
	nativewindow.width = width;
	nativewindow.height = height;
	vc_dispmanx_update_submit_sync( dispman_update );

	check();

	applicationContext.surface = eglCreateWindowSurface( applicationContext.display, config, &nativewindow, NULL );
	assert(applicationContext.surface != EGL_NO_SURFACE);
	check();

	// connect the context to the surface
	result = eglMakeCurrent(applicationContext.display, applicationContext.surface, applicationContext.surface, applicationContext.context);
	assert(EGL_FALSE != result);
	check();

	// Set background color and clear buffers
	glClearColor(0.15f, 0.25f, 0.35f, 1.0f);
	glClear( GL_COLOR_BUFFER_BIT );

	check();
}