21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_PANDORA 26 #include "../SDL_sysvideo.h" 31 #include "../../events/SDL_mouse_c.h" 32 #include "../../events/SDL_keyboard_c.h" 41 static NativeWindowType hNativeWnd = 0;
68 status = PND_available();
98 device->
free = PND_destroy;
139 "SDL Wiz Video Driver",
142 "SDL Pandora Video Driver",
159 current_mode.
w = 320;
160 current_mode.
h = 240;
162 current_mode.
w = 800;
163 current_mode.
h = 480;
216 EGLBoolean initstatus;
223 phdata->
egl_display = eglGetDisplay((NativeDisplayType) 0);
225 return SDL_SetError(
"PND: Can't get connection to OpenGL ES");
229 if (initstatus != EGL_TRUE) {
230 return SDL_SetError(
"PND: Can't init OpenGL ES library");
307 SDL_SetError(
"application not compiled with SDL %d.%d\n",
335 path =
"/lib/libopengles_lite.so";
337 path =
"/usr/lib/libGLES_CM.so";
345 return SDL_SetError(
"PND: Failed to locate OpenGL ES library");
359 void *function_address;
362 function_address = eglGetProcAddress(proc);
363 if (function_address !=
NULL) {
364 return function_address;
371 if (function_address !=
NULL) {
372 return function_address;
377 SDL_SetError(
"PND: Cannot locate OpenGL ES function name");
393 SDL_SetError(
"PND: GF initialization failed, no OpenGL ES support");
410 SDL_SetError(
"PND: EGL initialization failed, no OpenGL ES support");
416 wdata->gles_attributes[attr_pos++] = EGL_SURFACE_TYPE;
417 wdata->gles_attributes[attr_pos++] = EGL_WINDOW_BIT;
418 wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE;
420 wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE;
422 wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE;
424 wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE;
430 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
435 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE;
438 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE;
439 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
443 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
448 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
451 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
452 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
457 wdata->gles_attributes[attr_pos++] = EGL_SAMPLES;
458 wdata->gles_attributes[attr_pos++] =
464 wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS;
465 wdata->gles_attributes[attr_pos++] =
470 wdata->gles_attributes[attr_pos] = EGL_NONE;
473 status = eglChooseConfig(phdata->
egl_display, wdata->gles_attributes,
474 wdata->gles_configs, 1, &configs);
475 if (status != EGL_TRUE) {
476 SDL_SetError(
"PND: Can't find closest configuration for OpenGL ES");
484 GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE };
486 for (it = 0; it < 4; it++) {
487 for (jt = 16; jt >= 0; jt--) {
491 wdata->gles_attributes[attr_pos++] = EGL_SURFACE_TYPE;
492 wdata->gles_attributes[attr_pos++] = EGL_WINDOW_BIT;
493 wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE;
494 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
495 wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE;
496 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
497 wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE;
498 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
499 wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE;
500 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
501 wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE;
502 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
506 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
507 wdata->gles_attributes[attr_pos++] = depthbits[it];
509 wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE;
510 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
514 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
515 wdata->gles_attributes[attr_pos++] = jt;
517 wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE;
518 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
521 wdata->gles_attributes[attr_pos++] = EGL_SAMPLES;
522 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
523 wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS;
524 wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE;
525 wdata->gles_attributes[attr_pos] = EGL_NONE;
530 wdata->gles_attributes,
531 wdata->gles_configs, 1, &configs);
533 if (status != EGL_TRUE) {
535 (
"PND: Can't find closest configuration for OpenGL ES");
549 SDL_SetError(
"PND: Can't find any configuration for OpenGL ES");
555 wdata->gles_config = 0;
558 for (cit = 0; cit < configs; cit++) {
568 wdata->gles_configs[cit], EGL_STENCIL_SIZE,
570 if (status == EGL_TRUE) {
571 if (attr_value != 0) {
582 wdata->gles_configs[cit], EGL_DEPTH_SIZE,
584 if (status == EGL_TRUE) {
585 if (attr_value != 0) {
594 if ((depth_found != 0) && (stencil_found != 0)) {
600 if (cit == configs) {
603 wdata->gles_config = cit;
606 wdata->gles_context =
608 wdata->gles_configs[wdata->gles_config],
NULL,
NULL);
609 if (wdata->gles_context == EGL_NO_CONTEXT) {
610 SDL_SetError(
"PND: OpenGL ES context creation has been failed");
616 hNativeWnd = (NativeWindowType)
malloc(16*1024);
619 printf(
"Error: Wiz framebuffer allocatation failed\n" );
621 printf(
"SDL: Wiz framebuffer allocated: %X\n", hNativeWnd );
624 printf(
"SDL: Wiz framebuffer already allocated: %X\n", hNativeWnd );
627 wdata->gles_surface =
629 wdata->gles_configs[wdata->gles_config],
632 wdata->gles_surface =
634 wdata->gles_configs[wdata->gles_config],
635 (NativeWindowType) 0,
NULL);
639 if (wdata->gles_surface == 0) {
640 SDL_SetError(
"Error : eglCreateWindowSurface failed;\n");
646 eglMakeCurrent(phdata->
egl_display, wdata->gles_surface,
647 wdata->gles_surface, wdata->gles_context);
648 if (status != EGL_TRUE) {
650 eglDestroySurface(phdata->
egl_display, wdata->gles_surface);
651 eglDestroyContext(phdata->
egl_display, wdata->gles_context);
652 wdata->gles_context = EGL_NO_CONTEXT;
653 SDL_SetError(
"PND: Can't set OpenGL ES context on creation");
666 wdata->gles_configs[wdata->gles_config],
667 EGL_SAMPLES, &attr_value);
668 if (status == EGL_TRUE) {
673 wdata->gles_configs[wdata->gles_config],
674 EGL_SAMPLE_BUFFERS, &attr_value);
675 if (status == EGL_TRUE) {
682 wdata->gles_configs[wdata->gles_config],
683 EGL_DEPTH_SIZE, &attr_value);
684 if (status == EGL_TRUE) {
689 wdata->gles_configs[wdata->gles_config],
690 EGL_STENCIL_SIZE, &attr_value);
691 if (status == EGL_TRUE) {
699 return wdata->gles_context;
710 return SDL_SetError(
"PND: GF initialization failed, no OpenGL ES support");
713 if ((window ==
NULL) && (context ==
NULL)) {
715 eglMakeCurrent(phdata->
egl_display, EGL_NO_SURFACE,
716 EGL_NO_SURFACE, EGL_NO_CONTEXT);
717 if (status != EGL_TRUE) {
719 return SDL_SetError(
"PND: Can't set OpenGL ES context");
723 if (wdata->gles_surface == EGL_NO_SURFACE) {
725 (
"PND: OpenGL ES surface is not initialized for this window");
727 if (wdata->gles_context == EGL_NO_CONTEXT) {
729 (
"PND: OpenGL ES context is not initialized for this window");
731 if (wdata->gles_context != context) {
733 (
"PND: OpenGL ES context is not belong to this window");
736 eglMakeCurrent(phdata->
egl_display, wdata->gles_surface,
737 wdata->gles_surface, wdata->gles_context);
738 if (status != EGL_TRUE) {
740 return SDL_SetError(
"PND: Can't set OpenGL ES context");
753 return SDL_SetError(
"PND: EGL initialization failed, no OpenGL ES support");
759 status = eglSwapInterval(phdata->
egl_display, interval);
760 if (status == EGL_TRUE) {
784 SDL_SetError(
"PND: GLES initialization failed, no OpenGL ES support");
794 eglSwapBuffers(phdata->
egl_display, wdata->gles_surface);
804 SDL_SetError(
"PND: GLES initialization failed, no OpenGL ES support");
810 if (context != EGL_NO_CONTEXT) {
811 status = eglDestroyContext(phdata->
egl_display, context);
812 if (status != EGL_TRUE) {
821 if( hNativeWnd != 0 )
825 printf(
"SDL: Wiz framebuffer released\n" );
void PND_gl_swapwindow(_THIS, SDL_Window *window)
#define SDL_MINOR_VERSION
void(* RestoreWindow)(_THIS, SDL_Window *window)
int PND_gl_setswapinterval(_THIS, int interval)
void PND_raisewindow(_THIS, SDL_Window *window)
#define SDL_MAJOR_VERSION
int(* CreateWindowFrom)(_THIS, SDL_Window *window, const void *data)
static SDL_Window * window
void PND_restorewindow(_THIS, SDL_Window *window)
void PND_gl_deletecontext(_THIS, SDL_GLContext context)
void PND_destroywindow(_THIS, SDL_Window *window)
int PND_createwindowfrom(_THIS, SDL_Window *window, const void *data)
A collection of pixels used in software blitting.
GLAPI void GLAPIENTRY glFinish(void)
int(* GL_SetSwapInterval)(_THIS, int interval)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void PND_gl_unloadlibrary(_THIS)
void(* ShowWindow)(_THIS, SDL_Window *window)
The structure that defines a display mode.
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
void(* SetWindowSize)(_THIS, SDL_Window *window)
int PND_createwindow(_THIS, SDL_Window *window)
void(* GL_SwapWindow)(_THIS, SDL_Window *window)
int PND_gl_getswapinterval(_THIS)
void PND_getdisplaymodes(_THIS, SDL_VideoDisplay *display)
int SDL_AddVideoDisplay(const SDL_VideoDisplay *display)
int(* GL_LoadLibrary)(_THIS, const char *path)
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
static SDL_VideoDevice * _this
void PND_maximizewindow(_THIS, SDL_Window *window)
void(* HideWindow)(_THIS, SDL_Window *window)
void PND_setwindowsize(_THIS, SDL_Window *window)
void PND_setwindowgrab(_THIS, SDL_Window *window, SDL_bool grabbed)
void(* RaiseWindow)(_THIS, SDL_Window *window)
void * SDL_calloc(size_t nmemb, size_t size)
void * SDL_GLContext
An opaque handle to an OpenGL context.
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
void PND_setwindowicon(_THIS, SDL_Window *window, SDL_Surface *icon)
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
void PND_videoquit(_THIS)
void PND_hidewindow(_THIS, SDL_Window *window)
SDL_DisplayMode current_mode
void(* DestroyWindow)(_THIS, SDL_Window *window)
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
int PND_gl_loadlibrary(_THIS, const char *path)
void(* GL_UnloadLibrary)(_THIS)
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
#define SDL_OutOfMemory()
SDL_DisplayMode desktop_mode
int PND_setdisplaymode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
void PND_PumpEvents(_THIS)
void(* SetWindowPosition)(_THIS, SDL_Window *window)
int PND_gl_makecurrent(_THIS, SDL_Window *window, SDL_GLContext context)
int(* CreateWindow)(_THIS, SDL_Window *window)
The type used to identify a window.
void PND_setwindowtitle(_THIS, SDL_Window *window)
void(* MinimizeWindow)(_THIS, SDL_Window *window)
struct SDL_VideoDevice::@28 gl_config
#define SDL_arraysize(array)
SDL_GLContext PND_gl_createcontext(_THIS, SDL_Window *window)
GLsizei const GLchar *const * path
void * SDL_LoadFunction(void *handle, const char *name)
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
SDL_bool PND_getwindowwminfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
void(* SetWindowTitle)(_THIS, SDL_Window *window)
int(* GL_GetSwapInterval)(_THIS)
void(* MaximizeWindow)(_THIS, SDL_Window *window)
void PND_showwindow(_THIS, SDL_Window *window)
void * PND_gl_getprocaddres(_THIS, const char *proc)
void(* SetWindowGrab)(_THIS, SDL_Window *window, SDL_bool grabbed)
void *(* GL_GetProcAddress)(_THIS, const char *proc)
void PND_minimizewindow(_THIS, SDL_Window *window)
void(* PumpEvents)(_THIS)
void PND_setwindowposition(_THIS, SDL_Window *window)