Commit 79abe77b authored by Mike Gorchak's avatar Mike Gorchak

Continue working on QNX Photon with OpenGL ES support

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403588
parent 173f682e
This diff is collapsed.
......@@ -27,28 +27,78 @@
#ifndef __SDL_PHOTON_H__
#define __SDL_PHOTON_H__
/* GF headers must be included first for the Photon GF functions */
#if defined(SDL_VIDEO_OPENGL_ES)
#include <gf/gf.h>
#include <GLES/egl.h>
#endif /* SDL_VIDEO_OPENGL_ES */
#include "SDL_config.h"
#include "../SDL_sysvideo.h"
#include <Ph.h>
#include <Pt.h>
#include <photon/PkKeyDef.h>
/* Maximum display devices, which can handle SDL Photon driver */
#define SDL_VIDEO_PHOTON_MAX_RIDS 16
typedef struct SDL_VideoData
{
PhRid_t rid[SDL_VIDEO_PHOTON_MAX_RIDS];
uint32_t avail_rids;
uint32_t current_device_id;
#if defined(SDL_VIDEO_OPENGL_ES)
gf_dev_t gfdev; /* GF device handle */
gf_dev_info_t gfdev_info; /* GF device information */
SDL_bool gfinitialized; /* GF device initialization status */
EGLDisplay egldisplay; /* OpenGL ES display connection */
uint32_t egl_refcount; /* OpenGL ES reference count */
uint32_t swapinterval; /* OpenGL ES default swap interval */
#endif /* SDL_VIDEO_OPENGL_ES */
} SDL_VideoData;
#define SDL_VIDEO_PHOTON_DEVICENAME_MAX 257
/* This is hardcoded value in photon/Pg.h */
#define SDL_VIDEO_PHOTON_DEVICENAME_MAX 41
#define SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE 128
/* Maximum event message size with data payload */
#define SDL_VIDEO_PHOTON_EVENT_SIZE 8192
typedef struct SDL_DisplayData
{
uint32_t device_id;
uint32_t custom_refresh; /* Custom refresh rate for all modes */
SDL_DisplayMode current_mode; /* Current video mode */
uint8_t description[SDL_VIDEO_PHOTON_DEVICENAME_MAX];
/* Device description */
uint32_t caps; /* Device capabilities */
PhCursorDef_t* cursor; /* Global cursor settings */
SDL_bool cursor_visible; /* SDL_TRUE if cursor visible */
uint32_t cursor_size; /* Cursor size in memory w/ structure */
#if defined(SDL_VIDEO_OPENGL_ES)
gf_display_t display; /* GF display handle */
gf_display_info_t display_info; /* GF display information */
#endif /* SDL_VIDEO_OPENGL_ES */
} SDL_DisplayData;
/* Maximum amount of OpenGL ES framebuffer configurations */
#define SDL_VIDEO_GF_OPENGLES_CONFS 32
typedef struct SDL_WindowData
{
SDL_bool uses_gles; /* if true window must support OpenGL ES*/
SDL_bool uses_gles; /* if true window must support OpenGL ES*/
PtWidget_t* window; /* window handle */
#if defined(SDL_VIDEO_OPENGL_ES)
EGLConfig gles_configs[SDL_VIDEO_GF_OPENGLES_CONFS];
/* OpenGL ES framebuffer confs */
EGLint gles_config; /* OpenGL ES configuration index */
EGLContext gles_context; /* OpenGL ES context */
EGLint gles_attributes[256]; /* OpenGL ES attributes for context */
EGLSurface gles_surface; /* OpenGL ES target rendering surface */
gf_surface_t gfsurface; /* OpenGL ES GF's surface */
PdOffscreenContext_t* phsurface; /* OpenGL ES Photon's surface */
#endif /* SDL_VIDEO_OPENGL_ES */
} SDL_WindowData;
/****************************************************************************/
......@@ -62,22 +112,24 @@ typedef struct Photon_DeviceCaps
#define SDL_PHOTON_UNACCELERATED 0x00000000
#define SDL_PHOTON_ACCELERATED 0x00000001
#define SDL_PHOTON_UNACCELERATED_3D 0x00000000
#define SDL_PHOTON_ACCELERATED_3D 0x00000004
/****************************************************************************/
/* SDL_VideoDevice functions declaration */
/****************************************************************************/
/* Display and window functions */
int photon_videoinit(_THIS);
int photon_videoinit(_THIS);
void photon_videoquit(_THIS);
void photon_getdisplaymodes(_THIS);
int photon_setdisplaymode(_THIS, SDL_DisplayMode* mode);
int photon_setdisplaypalette(_THIS, SDL_Palette* palette);
int photon_getdisplaypalette(_THIS, SDL_Palette* palette);
int photon_setdisplaygammaramp(_THIS, Uint16* ramp);
int photon_getdisplaygammaramp(_THIS, Uint16* ramp);
int photon_createwindow(_THIS, SDL_Window* window);
int photon_createwindowfrom(_THIS, SDL_Window* window, const void* data);
int photon_setdisplaymode(_THIS, SDL_DisplayMode* mode);
int photon_setdisplaypalette(_THIS, SDL_Palette* palette);
int photon_getdisplaypalette(_THIS, SDL_Palette* palette);
int photon_setdisplaygammaramp(_THIS, Uint16* ramp);
int photon_getdisplaygammaramp(_THIS, Uint16* ramp);
int photon_createwindow(_THIS, SDL_Window* window);
int photon_createwindowfrom(_THIS, SDL_Window* window, const void* data);
void photon_setwindowtitle(_THIS, SDL_Window* window);
void photon_setwindowicon(_THIS, SDL_Window* window, SDL_Surface* icon);
void photon_setwindowposition(_THIS, SDL_Window* window);
......
This diff is collapsed.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
QNX Photon GUI SDL driver
Copyright (C) 2009 Mike Gorchak
(mike@malva.ua, lestat@i.com.ua)
*/
#ifndef __SDL_PHOTON_INPUT_H__
#define __SDL_PHOTON_INPUT_H__
#include "SDL_config.h"
#include "SDL_video.h"
#include "../SDL_sysvideo.h"
#include "SDL_photon.h"
typedef struct SDL_MouseData
{
SDL_DisplayData* didata;
} SDL_MouseData;
int32_t photon_addinputdevices(_THIS);
int32_t photon_delinputdevices(_THIS);
#define SDL_PHOTON_MOUSE_COLOR_BLACK 0xFF000000
#define SDL_PHOTON_MOUSE_COLOR_WHITE 0xFFFFFFFF
#define SDL_PHOTON_MOUSE_COLOR_TRANS 0x00000000
SDL_scancode photon_to_sdl_keymap(uint32_t key);
#endif /* __SDL_GF_INPUT_H__ */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
QNX Photon GUI SDL driver
Copyright (C) 2009 Mike Gorchak
(mike@malva.ua, lestat@i.com.ua)
*/
#ifndef __SDL_PHOTON_KEYCODES_H__
#define __SDL_PHOTON_KEYCODES_H__
#define PHOTON_SCANCODE_ESCAPE 0x01
#define PHOTON_SCANCODE_F1 0x3B
#define PHOTON_SCANCODE_F2 0x3C
#define PHOTON_SCANCODE_F3 0x3D
#define PHOTON_SCANCODE_F4 0x3E
#define PHOTON_SCANCODE_F5 0x3F
#define PHOTON_SCANCODE_F6 0x40
#define PHOTON_SCANCODE_F7 0x41
#define PHOTON_SCANCODE_F8 0x42
#define PHOTON_SCANCODE_F9 0x43
#define PHOTON_SCANCODE_F10 0x44
#define PHOTON_SCANCODE_F11 0x57
#define PHOTON_SCANCODE_F12 0x58
#define PHOTON_SCANCODE_BACKQOUTE 0x29
#define PHOTON_SCANCODE_1 0x02
#define PHOTON_SCANCODE_2 0x03
#define PHOTON_SCANCODE_3 0x04
#define PHOTON_SCANCODE_4 0x05
#define PHOTON_SCANCODE_5 0x06
#define PHOTON_SCANCODE_6 0x07
#define PHOTON_SCANCODE_7 0x08
#define PHOTON_SCANCODE_8 0x09
#define PHOTON_SCANCODE_9 0x0A
#define PHOTON_SCANCODE_0 0x0B
#define PHOTON_SCANCODE_MINUS 0x0C
#define PHOTON_SCANCODE_EQUAL 0x0D
#define PHOTON_SCANCODE_BACKSPACE 0x0E
#define PHOTON_SCANCODE_TAB 0x0F
#define PHOTON_SCANCODE_Q 0x10
#define PHOTON_SCANCODE_W 0x11
#define PHOTON_SCANCODE_E 0x12
#define PHOTON_SCANCODE_R 0x13
#define PHOTON_SCANCODE_T 0x14
#define PHOTON_SCANCODE_Y 0x15
#define PHOTON_SCANCODE_U 0x16
#define PHOTON_SCANCODE_I 0x17
#define PHOTON_SCANCODE_O 0x18
#define PHOTON_SCANCODE_P 0x19
#define PHOTON_SCANCODE_LEFT_SQ_BR 0x1A
#define PHOTON_SCANCODE_RIGHT_SQ_BR 0x1B
#define PHOTON_SCANCODE_ENTER 0x1C
#define PHOTON_SCANCODE_CAPSLOCK 0x3A
#define PHOTON_SCANCODE_A 0x1E
#define PHOTON_SCANCODE_S 0x1F
#define PHOTON_SCANCODE_D 0x20
#define PHOTON_SCANCODE_F 0x21
#define PHOTON_SCANCODE_G 0x22
#define PHOTON_SCANCODE_H 0x23
#define PHOTON_SCANCODE_J 0x24
#define PHOTON_SCANCODE_K 0x25
#define PHOTON_SCANCODE_L 0x26
#define PHOTON_SCANCODE_SEMICOLON 0x27
#define PHOTON_SCANCODE_QUOTE 0x28
#define PHOTON_SCANCODE_BACKSLASH 0x2B
#define PHOTON_SCANCODE_LEFT_SHIFT 0x2A
#define PHOTON_SCANCODE_Z 0x2C
#define PHOTON_SCANCODE_X 0x2D
#define PHOTON_SCANCODE_C 0x2E
#define PHOTON_SCANCODE_V 0x2F
#define PHOTON_SCANCODE_B 0x30
#define PHOTON_SCANCODE_N 0x31
#define PHOTON_SCANCODE_M 0x32
#define PHOTON_SCANCODE_COMMA 0x33
#define PHOTON_SCANCODE_POINT 0x34
#define PHOTON_SCANCODE_SLASH 0x35
#define PHOTON_SCANCODE_RIGHT_SHIFT 0x36
#define PHOTON_SCANCODE_CTRL 0x1D
#define PHOTON_SCANCODE_WFLAG 0x5B
#define PHOTON_SCANCODE_ALT 0x38
#define PHOTON_SCANCODE_SPACE 0x39
#define PHOTON_SCANCODE_MENU 0x5D
#define PHOTON_SCANCODE_PRNSCR 0x54 /* only key pressed event, no release */
#define PHOTON_SCANCODE_SCROLLLOCK 0x46
/* #define PHOTON_SCANCODE_PAUSE 0x?? */ /* pause doesn't generates a scancode */
#define PHOTON_SCANCODE_INSERT 0x52
#define PHOTON_SCANCODE_HOME 0x47
#define PHOTON_SCANCODE_PAGEUP 0x49
#define PHOTON_SCANCODE_DELETE 0x53
#define PHOTON_SCANCODE_END 0x4F
#define PHOTON_SCANCODE_PAGEDOWN 0x51
#define PHOTON_SCANCODE_UP 0x48
#define PHOTON_SCANCODE_DOWN 0x50
#define PHOTON_SCANCODE_LEFT 0x4B
#define PHOTON_SCANCODE_RIGHT 0x4D
#define PHOTON_SCANCODE_NUMLOCK 0x45
#endif /* __SDL_PHOTON_KEYCODES_H__ */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
QNX Photon GUI SDL driver
Copyright (C) 2009 Mike Gorchak
(mike@malva.ua, lestat@i.com.ua)
*/
#include "SDL_photon_pixelfmt.h"
uint32_t photon_bits_to_sdl_pixelformat(uint32_t pixelfmt)
{
switch(pixelfmt)
{
case 8:
{
return SDL_PIXELFORMAT_INDEX8;
}
break;
case 15:
{
return SDL_PIXELFORMAT_ARGB1555;
}
break;
case 16:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case 24:
{
return SDL_PIXELFORMAT_RGB888;
}
break;
case 32:
{
return SDL_PIXELFORMAT_ARGB8888;
}
break;
}
}
uint32_t photon_sdl_to_bits_pixelformat(uint32_t pixelfmt)
{
switch(pixelfmt)
{
case SDL_PIXELFORMAT_INDEX8:
{
return 8;
}
break;
case SDL_PIXELFORMAT_ARGB1555:
{
return 15;
}
break;
case SDL_PIXELFORMAT_ABGR1555:
{
return 15;
}
break;
case SDL_PIXELFORMAT_RGB565:
{
return 16;
}
break;
case SDL_PIXELFORMAT_RGB888:
{
return 24;
}
break;
case SDL_PIXELFORMAT_BGRA8888:
{
return 32;
}
break;
case SDL_PIXELFORMAT_ARGB8888:
{
return 32;
}
break;
case SDL_PIXELFORMAT_YV12:
{
return 8;
}
break;
case SDL_PIXELFORMAT_YUY2:
{
return 16;
}
break;
case SDL_PIXELFORMAT_UYVY:
{
return 16;
}
break;
case SDL_PIXELFORMAT_YVYU:
{
return 16;
}
break;
}
return 0;
}
uint32_t photon_image_to_sdl_pixelformat(uint32_t pixelfmt)
{
switch(pixelfmt)
{
case Pg_IMAGE_PALETTE_BYTE:
{
return SDL_PIXELFORMAT_INDEX8;
}
break;
case Pg_IMAGE_DIRECT_8888:
{
return SDL_PIXELFORMAT_BGRA8888;
}
break;
case Pg_IMAGE_DIRECT_888:
{
return SDL_PIXELFORMAT_RGB888;
}
break;
case Pg_IMAGE_DIRECT_565:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case Pg_IMAGE_DIRECT_555:
{
return SDL_PIXELFORMAT_RGB555;
}
break;
case Pg_IMAGE_DIRECT_1555:
{
return SDL_PIXELFORMAT_ARGB1555;
}
break;
}
return 0;
}
uint32_t photon_sdl_to_image_pixelformat(uint32_t pixelfmt)
{
switch(pixelfmt)
{
case SDL_PIXELFORMAT_INDEX8:
{
return Pg_IMAGE_PALETTE_BYTE;
}
break;
case SDL_PIXELFORMAT_BGRA8888:
{
return Pg_IMAGE_DIRECT_8888;
}
break;
case SDL_PIXELFORMAT_RGB888:
{
return Pg_IMAGE_DIRECT_888;
}
break;
case SDL_PIXELFORMAT_RGB565:
{
return Pg_IMAGE_DIRECT_565;
}
break;
case SDL_PIXELFORMAT_ARGB1555:
{
return Pg_IMAGE_DIRECT_1555;
}
break;
}
return 0;
}
/* vi: set ts=4 sw=4 expandtab: */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2009 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
QNX Photon GUI SDL driver
Copyright (C) 2009 Mike Gorchak
(mike@malva.ua, lestat@i.com.ua)
*/
#include "SDL_config.h"
#include "../SDL_sysvideo.h"
#include <Ph.h>
#ifndef __SDL_PHOTON_PIXELFMT_H__
#define __SDL_PHOTON_PIXELFMT_H__
uint32_t photon_bits_to_sdl_pixelformat(uint32_t pixelfmt);
uint32_t photon_sdl_to_bits_pixelformat(uint32_t pixelfmt);
uint32_t photon_image_to_sdl_pixelformat(uint32_t pixelfmt);
uint32_t photon_sdl_to_image_pixelformat(uint32_t pixelfmt);
#endif /* __SDL_PHOTON_PIXELFMT_H__ */
/* vi: set ts=4 sw=4 expandtab: */
......@@ -35,24 +35,24 @@
#include "SDL_photon.h"
static SDL_Renderer* photon_createrenderer(SDL_Window* window, Uint32 flags);
static int photon_displaymodechanged(SDL_Renderer* renderer);
static int photon_activaterenderer(SDL_Renderer* renderer);
static int photon_createtexture(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_querytexturepixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch);
static int photon_settexturepalette(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Color* colors, int firstcolor, int ncolors);
static int photon_gettexturepalette(SDL_Renderer* renderer, SDL_Texture* texture, SDL_Color* colors, int firstcolor, int ncolors);
static int photon_settexturecolormod(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_settexturealphamod(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_settextureblendmode(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_settexturescalemode(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_updatetexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch);
static int photon_locktexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int markDirty, void** pixels, int* pitch);
static int photon_displaymodechanged(SDL_Renderer* renderer);
static int photon_activaterenderer(SDL_Renderer* renderer);
static int photon_createtexture(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_querytexturepixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch);
static int photon_settexturepalette(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Color* colors, int firstcolor, int ncolors);
static int photon_gettexturepalette(SDL_Renderer* renderer, SDL_Texture* texture, SDL_Color* colors, int firstcolor, int ncolors);
static int photon_settexturecolormod(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_settexturealphamod(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_settextureblendmode(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_settexturescalemode(SDL_Renderer* renderer, SDL_Texture* texture);
static int photon_updatetexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch);
static int photon_locktexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int markDirty, void** pixels, int* pitch);
static void photon_unlocktexture(SDL_Renderer* renderer, SDL_Texture* texture);
static void photon_dirtytexture(SDL_Renderer* renderer, SDL_Texture* texture, int numrects, const SDL_Rect* rects);
static int photon_renderpoint(SDL_Renderer* renderer, int x, int y);
static int photon_renderline(SDL_Renderer* renderer, int x1, int y1, int x2, int y2);
static int photon_renderfill(SDL_Renderer* renderer, const SDL_Rect* rect);
static int photon_rendercopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srcrect, const SDL_Rect* dstrect);
static int photon_renderpoint(SDL_Renderer* renderer, int x, int y);
static int photon_renderline(SDL_Renderer* renderer, int x1, int y1, int x2, int y2);
static int photon_renderfill(SDL_Renderer* renderer, const SDL_Rect* rect);
static int photon_rendercopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srcrect, const SDL_Rect* dstrect);
static void photon_renderpresent(SDL_Renderer* renderer);
static void photon_destroytexture(SDL_Renderer* renderer, SDL_Texture* texture);
static void photon_destroyrenderer(SDL_Renderer* renderer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment