Commit ba4c542e authored by Sam Lantinga's avatar Sam Lantinga

Date: Wed, 4 Mar 2009 15:38:22 +0200

From: "Mike Gorchak"
Subject: Re: About QNX support in SDL 1.3

Here is another batch of patches.

1) Makefile.in - added SDL_opengles.h header as header to install.
2) configure.in - Added special define to detect Common Lite OpenGL ES
library in case if Common library is not installed. Added check for
clock_gettime in libc (in QNX it is in libc).
3) SDL_config.h.in - Added SDL_VIDEO_RENDER_OPENGL_ES and
SDL_VIDEO_OPENGL_ES declarations for configure script autodetection.
4) SDL_opengles.h - Added GL_API definition if it is not defined. Added
extension GL_OES_draw_texture because OpenGL ES Renderer uses it without
declaration. Added GL_OES_vertex_buffer_object extension, which is supported
under QNX OpenGL ES. Added GL_OES_single_precision extension.
5) To the test directory I've added building OpenGL ES test applications
through the autotools suite. Was support for iPhone IDE building only.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403553
parent 7c0777a9
......@@ -42,7 +42,7 @@ SDLMAIN_OBJECTS = @SDLMAIN_OBJECTS@
DIST = acinclude.m4 autogen.sh Borland.html Borland.zip BUGS build-scripts configure configure.in COPYING CREDITS docs docs.html include INSTALL Makefile.dc Makefile.minimal Makefile.in README* sdl-config.in sdl.m4 sdl.pc.in SDL.qpg.in SDL.spec SDL.spec.in src test TODO VisualC.html VisualC VisualCE Watcom-OS2.zip Watcom-Win32.zip WhatsNew Xcode
HDRS = SDL.h SDL_audio.h SDL_cdrom.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_pixels.h SDL_platform.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
HDRS = SDL.h SDL_audio.h SDL_cdrom.h SDL_compat.h SDL_cpuinfo.h SDL_endian.h SDL_error.h SDL_events.h SDL_haptic.h SDL_joystick.h SDL_keyboard.h SDL_keysym.h SDL_loadso.h SDL_main.h SDL_mouse.h SDL_mutex.h SDL_name.h SDL_opengl.h SDL_opengles.h SDL_pixels.h SDL_platform.h SDL_quit.h SDL_rect.h SDL_revision.h SDL_rwops.h SDL_scancode.h SDL_stdinc.h SDL_surface.h SDL_syswm.h SDL_thread.h SDL_timer.h SDL_types.h SDL_version.h SDL_video.h begin_code.h close_code.h
LT_AGE = @LT_AGE@
LT_CURRENT = @LT_CURRENT@
......
......@@ -1705,12 +1705,12 @@ CheckOpenGLESQNX()
AC_MSG_RESULT($video_opengl)
if test x$video_opengl = xyes; then
AC_DEFINE(SDL_VIDEO_OPENGL_ES)
AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES)
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGLES_CM"
else
AC_MSG_CHECKING(for QNX OpenGL ES (CL) support)
video_opengl=no
AC_TRY_COMPILE([
#define COMMON_LITE
#include <GLES/egl.h>
],[
],[
......@@ -1719,7 +1719,6 @@ CheckOpenGLESQNX()
AC_MSG_RESULT($video_opengl)
if test x$video_opengl = xyes; then
AC_DEFINE(SDL_VIDEO_OPENGL_ES)
AC_DEFINE(SDL_VIDEO_RENDER_OGL_ES)
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGLES_CL"
fi
fi
......@@ -2295,6 +2294,12 @@ AC_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettime
if test x$have_clock_gettime = xyes; then
AC_DEFINE(HAVE_CLOCK_GETTIME)
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
else
AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
if test x$have_clock_gettime = xyes; then
AC_DEFINE(HAVE_CLOCK_GETTIME)
EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
fi
fi
fi
}
......
......@@ -310,10 +310,12 @@
#undef SDL_VIDEO_RENDER_D3D
#undef SDL_VIDEO_RENDER_GDI
#undef SDL_VIDEO_RENDER_OGL
#undef SDL_VIDEO_RENDER_OGL_ES
#undef SDL_VIDEO_RENDER_X11
/* Enable OpenGL support */
#undef SDL_VIDEO_OPENGL
#undef SDL_VIDEO_OPENGL_ES
#undef SDL_VIDEO_OPENGL_BGL
#undef SDL_VIDEO_OPENGL_CGL
#undef SDL_VIDEO_OPENGL_GLX
......
......@@ -40,10 +40,6 @@ extern "C"
#include <OpenGLES/ES1/gl.h> /* Header File For The OpenGL ES Library */
#endif
#if defined(__QNXNTO__) && defined(SDL_VIDEO_OPENGL_ES)
#include <GLES/egl.h>
#endif
#ifndef APIENTRY
#define APIENTRY
#endif
......@@ -52,6 +48,9 @@ extern "C"
#define GL_APIENTRY
#endif
#ifndef GL_API
#define GL_API
#endif /* GL_API */
/*
** License Applicability. Except to the extent portions of this file are
......@@ -659,6 +658,29 @@ extern "C"
#define GL_COORD_REPLACE_OES 0x8862
#endif
/* GL_OES_draw_texture */
#ifndef GL_OES_draw_texture
#define GL_TEXTURE_CROP_RECT_OES 0x8B9D
#endif /* GL_OES_draw_texture */
/* GL_OES_vertex_buffer_object */
#ifndef GL_OES_vertex_buffer_object
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
#define GL_STATIC_DRAW 0x88E4
#define GL_DYNAMIC_DRAW 0x88E8
#define GL_WRITE_ONLY 0x88B9
#define GL_BUFFER_SIZE 0x8764
#define GL_BUFFER_USAGE 0x8765
#define GL_BUFFER_ACCESS 0x88BB
#endif /* GL_OES_vertex_buffer_object */
/*************************************************************/
/* Available only in Common profile */
......@@ -945,6 +967,42 @@ extern "C"
#define GL_OES_point_sprite 1
#endif
/* GL_OES_draw_texture */
#ifndef GL_OES_draw_texture
#define GL_OES_draw_texture 1
GL_API void GL_APIENTRY glDrawTexsOES (GLshort x, GLshort y, GLshort z, GLshort width, GLshort height);
GL_API void GL_APIENTRY glDrawTexiOES (GLint x, GLint y, GLint z, GLint width, GLint height);
GL_API void GL_APIENTRY glDrawTexxOES (GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height);
GL_API void GL_APIENTRY glDrawTexsvOES (const GLshort *coords);
GL_API void GL_APIENTRY glDrawTexivOES (const GLint *coords);
GL_API void GL_APIENTRY glDrawTexxvOES (const GLfixed *coords);
GL_API void GL_APIENTRY glDrawTexfOES (GLfloat x, GLfloat y, GLfloat z, GLfloat width, GLfloat height);
GL_API void GL_APIENTRY glDrawTexfvOES (const GLfloat *coords);
#endif /* GL_OES_draw_texture */
/* GL_OES_single_precision */
#ifndef GL_OES_single_precision
#define GL_OES_single_precision 1
GL_API void GL_APIENTRY glDepthRangefOES (GLclampf zNear, GLclampf zFar);
GL_API void GL_APIENTRY glFrustumfOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glOrthofOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar);
GL_API void GL_APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation);
GL_API void GL_APIENTRY glGetClipPlanefOES (GLenum pname, GLfloat eqn[4]);
GL_API void GL_APIENTRY glClearDepthfOES (GLclampf depth);
#endif /* GL_OES_single_precision */
/* GL_OES_vertex_buffer_object */
#ifndef GL_OES_vertex_buffer_object
#define GL_OES_vertex_buffer_object 1
GL_API void APIENTRY glBindBufferOES(GLenum, GLuint);
GL_API void APIENTRY glDeleteBuffersOES(GLsizei, const GLuint *);
GL_API void APIENTRY glGenBuffersOES(GLsizei, GLuint *);
GL_API GLboolean APIENTRY glIsBufferOES(GLuint);
GL_API void APIENTRY glBufferDataOES(GLenum, GLsizeiptr, const GLvoid *, GLenum);
GL_API void APIENTRY glBufferSubDataOES(GLenum, GLintptr, GLsizeiptr, const GLvoid *);
GL_API void APIENTRY glGetBufferParameterivOES(GLenum, GLenum, GLint *);
#endif /* GL_OES_vertex_buffer_object */
#ifdef __cplusplus
}
#endif
......
......@@ -169,7 +169,7 @@ struct SDL_SysWMinfo
int window; /* The RISC OS display window */
};
#elif defined(SDL_VIDEO_DRIVER_PHOTON)
#elif defined(SDL_VIDEO_DRIVER_PHOTON) || defined(SDL_VIDEO_DRIVER_QNXGF)
#include <sys/neutrino.h>
#include <Ph.h>
......@@ -180,7 +180,7 @@ struct SDL_SysWMmsg
int data;
};
/* The QNX custom window manager information structure */
/* The QNX Photon custom window manager information structure */
struct SDL_SysWMinfo
{
SDL_version version;
......
/*
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
*/
#include "SDL_config.h"
#include "../SDL_sysvideo.h"
static SDL_bool photon_initialized=SDL_FALSE;
static int photon_available(void)
{
int status;
/* Check if Photon was initialized before */
if (photon_initialized==SDL_FALSE)
{
/* Initialize Photon widget library and open channel to Photon */
status=PtInit(NULL);
if (status==0)
{
photon_initialized=SDL_TRUE;
return 1;
}
else
{
photon_initialized=SDL_FALSE;
return 0;
}
}
return 1;
}
static void photon_destroy(SDL_VideoDevice* device)
{
}
static SDL_VideoDevice* photon_create(int devindex)
{
}
VideoBootStrap photon_bootstrap=
{
"photon",
"SDL Photon video driver",
photon_available,
photon_create
};
/* 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
*/
#include "SDL_config.h"
#include "SDL_gf_pixelfmt.h"
gf_format_t qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt)
{
switch(pixelfmt)
{
case SDL_PIXELFORMAT_INDEX8:
{
return GF_FORMAT_PAL8;
}
break;
case SDL_PIXELFORMAT_ARGB1555:
{
return GF_FORMAT_PACK_ARGB1555;
}
break;
case SDL_PIXELFORMAT_ABGR1555:
{
return GF_FORMAT_PACK_ARGB1555;
}
break;
case SDL_PIXELFORMAT_RGB565:
{
return GF_FORMAT_PACK_RGB565;
}
break;
case SDL_PIXELFORMAT_RGB888:
{
return GF_FORMAT_BGR888;
}
break;
case SDL_PIXELFORMAT_BGRA8888:
{
return GF_FORMAT_BGRA8888;
}
break;
case SDL_PIXELFORMAT_ARGB8888:
{
return GF_FORMAT_ARGB8888;
}
break;
case SDL_PIXELFORMAT_YV12:
{
return GF_FORMAT_PLANAR_YUV_YV12;
}
break;
case SDL_PIXELFORMAT_YUY2:
{
return GF_FORMAT_PACK_YUV_YUY2;
}
break;
case SDL_PIXELFORMAT_UYVY:
{
return GF_FORMAT_PACK_YUV_UYVY;
}
break;
case SDL_PIXELFORMAT_YVYU:
{
return GF_FORMAT_PACK_YUV_YVYU;
}
break;
}
return GF_FORMAT_INVALID;
}
uint32_t qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt)
{
switch(pixelfmt)
{
case GF_FORMAT_PAL8:
{
return SDL_PIXELFORMAT_INDEX8;
}
break;
case GF_FORMAT_PKLE_ARGB1555:
{
return SDL_PIXELFORMAT_ARGB1555;
}
break;
case GF_FORMAT_PACK_ARGB1555:
{
return SDL_PIXELFORMAT_ARGB1555;
}
break;
case GF_FORMAT_PKBE_ARGB1555:
{
return SDL_PIXELFORMAT_ABGR1555;
}
break;
case GF_FORMAT_PKBE_RGB565:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case GF_FORMAT_PKLE_RGB565:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case GF_FORMAT_PACK_RGB565:
{
return SDL_PIXELFORMAT_RGB565;
}
break;
case GF_FORMAT_BGR888:
{
return SDL_PIXELFORMAT_RGB888;
}
break;
case GF_FORMAT_BGRA8888:
{
return SDL_PIXELFORMAT_BGRA8888;
}
break;
case GF_FORMAT_ARGB8888:
{
return SDL_PIXELFORMAT_ARGB8888;
}
break;
case GF_FORMAT_PLANAR_YUV_YV12:
{
return SDL_PIXELFORMAT_YV12;
}
break;
case GF_FORMAT_PACK_YUV_YUY2:
{
return SDL_PIXELFORMAT_YUY2;
}
break;
case GF_FORMAT_PACK_YUV_UYVY:
{
return SDL_PIXELFORMAT_UYVY;
}
break;
case GF_FORMAT_PACK_YUV_YVYU:
{
return SDL_PIXELFORMAT_YVYU;
}
break;
}
return SDL_PIXELFORMAT_UNKNOWN;
}
/*
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
*/
#ifndef __SDL_GF_PIXELFMT_H__
#define __SDL_GF_PIXELFMT_H__
#include "../SDL_sysvideo.h"
#include <gf/gf.h>
gf_format_t qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt);
uint32_t qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt);
#endif /* __SDL_GF_PIXELFMT_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
*/
#include "SDL_config.h"
#include "../SDL_pixels_c.h"
#include "../SDL_yuv_sw_c.h"
#include "SDL_video.h"
#include "SDL_gf_render.h"
static SDL_Renderer* GF_CreateRenderer(SDL_Window* window, Uint32 flags)
{
}
SDL_RenderDriver GF_RenderDriver=
{
GF_CreateRenderer,
{
"qnxgf",
(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC |
SDL_RENDERER_ACCELERATED),
(SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
SDL_TEXTUREMODULATE_ALPHA),
(SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
(SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_SLOW),
13,
{
SDL_PIXELFORMAT_INDEX8,
SDL_PIXELFORMAT_RGB555,
SDL_PIXELFORMAT_RGB565,
SDL_PIXELFORMAT_RGB888,
SDL_PIXELFORMAT_BGR888,
SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_RGBA8888,
SDL_PIXELFORMAT_ABGR8888,
SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_YV12,
SDL_PIXELFORMAT_YUY2,
SDL_PIXELFORMAT_UYVY,
SDL_PIXELFORMAT_YVYU
},
0,
0
}
};
/*
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
*/
#ifndef __SDL_GF_RENDER_H__
#define __SDL_GF_RENDER_H__
#include "../SDL_sysvideo.h"
#include <gf/gf.h>
#endif /* __SDL_GF_RENDER_H__ */
......@@ -23,13 +23,543 @@
#include "SDL_config.h"
#include "../SDL_sysvideo.h"
#include "SDL_version.h"
#include "SDL_syswm.h"
/* Include QNX Graphics Framework declarations */
#include <gf/gf.h>
#include "SDL_qnxgf.h"
#include "SDL_gf_pixelfmt.h"
/******************************************************************************/
/* SDL Generic video modes, which could provide GF */
/* This is real pain in the ass. GF is just wrapper around a selected driver */
/* some drivers could support double scan modes, like 320x200, 512x384, etc */
/* but some drivers are not. Later we can distinguish one driver from another */
/* Feel free to add any new custom graphics mode */
/******************************************************************************/
static SDL_DisplayMode generic_mode[]=
{
{0, 320, 200, 70, NULL}, /* 320x200 modes are 70Hz and 85Hz */
{0, 320, 200, 85, NULL},
{0, 320, 240, 70, NULL}, /* 320x240 modes are 70Hz and 85Hz */
{0, 320, 240, 85, NULL},
{0, 512, 384, 60, NULL}, /* 512x384 modes are 60Hz and 70Hz */
{0, 512, 384, 70, NULL},
{0, 640, 480, 60, NULL}, /* 640x480 modes are 60Hz, 75Hz, 85Hz */
{0, 640, 480, 75, NULL},
{0, 640, 480, 85, NULL},
{0, 800, 600, 60, NULL}, /* 800x600 modes are 60Hz, 75Hz, 85Hz */
{0, 800, 600, 75, NULL},
{0, 800, 600, 85, NULL},
{0, 800, 480, 60, NULL}, /* 800x480 mode is 60Hz only */
{0, 1024, 640, 60, NULL}, /* 1024x640 mode is 60Hz only */
{0, 1024, 768, 60, NULL}, /* 1024x768 modes are 60Hz, 70Hz, 75Hz */
{0, 1024, 768, 70, NULL},
{0, 1024, 768, 75, NULL},
{0, 1280, 720, 60, NULL}, /* 1280x720 mode is 60Hz only */
{0, 1280, 768, 60, NULL}, /* 1280x768 mode is 60Hz only */
{0, 1280, 800, 60, NULL}, /* 1280x800 mode is 60Hz only */
{0, 1280, 960, 60, NULL}, /* 1280x960 mode is 60Hz only */
{0, 1280, 1024, 60, NULL}, /* 1280x1024 mode is 60Hz only */
{0, 1400, 1050, 60, NULL}, /* 1400x1050 mode is 60Hz only */
{0, 1440, 900, 60, NULL}, /* 1440x900 mode is 60Hz only */
{0, 1440, 960, 60, NULL}, /* 1440x960 mode is 60Hz only */
{0, 1600, 1200, 60, NULL}, /* 1600x1200 mode is 60Hz only */
{0, 1680, 1050, 60, NULL}, /* 1680x1050 mode is 60Hz only */
{0, 1920, 1080, 60, NULL}, /* 1920x1080 mode is 60Hz only */
{0, 1920, 1200, 60, NULL}, /* 1920x1200 mode is 60Hz only */
{0, 2048, 1536, 60, NULL}, /* 2048x1536 mode is 60Hz only */
{0, 2048, 1080, 60, NULL}, /* 2048x1080 mode is 60Hz only */
{0, 0, 0, 0, NULL} /* End of generic mode list */
};
/*****************************************************************************/
/* SDL Video Device initialization functions */
/*****************************************************************************/
static int qnxgf_available(void)
{
gf_dev_t gfdev;
gf_dev_info_t gfdev_info;
int status;
/* Try to attach to graphics device driver */
status=gf_dev_attach(&gfdev, GF_DEVICE_INDEX(0), &gfdev_info);
if (status!=GF_ERR_OK)
{
return 0;
}
/* Detach from graphics device driver for now */
gf_dev_detach(gfdev);
return 1;
}
static void qnxgf_destroy(SDL_VideoDevice* device)
{
SDL_VideoData* gfdata=(SDL_VideoData*) device->driverdata;
/* Detach from graphics device driver, if it was initialized */
if (gfdata->gfinitialized!=SDL_FALSE)
{
gf_dev_detach(gfdata->gfdev);
}
if (device->driverdata!=NULL)
{
SDL_free(device->driverdata);
device->driverdata=NULL;
}
SDL_free(device);
}
static SDL_VideoDevice* qnxgf_create(int devindex)
{
SDL_VideoDevice* device;
SDL_VideoData* gfdata;
int status;
/* Initialize SDL_VideoDevice structure */
device = (SDL_VideoDevice*)SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device==NULL)
{
SDL_OutOfMemory();
return NULL;
}
/* Initialize internal GF specific data */
gfdata = (SDL_VideoData*)SDL_calloc(1, sizeof(SDL_VideoData));
if (gfdata==NULL)
{
SDL_OutOfMemory();
SDL_free(device);
return NULL;
}
device->driverdata=gfdata;
/* Try to attach to graphics device driver */
status=gf_dev_attach(&gfdata->gfdev, GF_DEVICE_INDEX(devindex), &gfdata->gfdev_info);
if (status!=GF_ERR_OK)
{
SDL_OutOfMemory();
SDL_free(gfdata);
SDL_free(device);
return NULL;
}
/* Setup amount of available displays and current display */
device->num_displays=0;
device->current_display=0;
/* Setup device shutdown function */
gfdata->gfinitialized=SDL_TRUE;
device->free=qnxgf_destroy;
/* Setup all functions which we can handle */
device->VideoInit=qnxgf_videoinit;
device->VideoQuit=qnxgf_videoquit;
device->GetDisplayModes=qnxgf_getdisplaymodes;
device->SetDisplayMode=qnxgf_setdisplaymode;
device->SetDisplayPalette=qnxgf_setdisplaypalette;
device->GetDisplayPalette=qnxgf_getdisplaypalette;
device->SetDisplayGammaRamp=qnxgf_setdisplaygammaramp;
device->GetDisplayGammaRamp=qnxgf_getdisplaygammaramp;
device->CreateWindow=qnxgf_createwindow;
device->CreateWindowFrom=qnxgf_createwindowfrom;
device->SetWindowTitle=qnxgf_setwindowtitle;
device->SetWindowIcon=qnxgf_setwindowicon;
device->SetWindowPosition=qnxgf_setwindowposition;
device->SetWindowSize=qnxgf_setwindowsize;
device->ShowWindow=qnxgf_showwindow;
device->HideWindow=qnxgf_hidewindow;
device->RaiseWindow=qnxgf_raisewindow;
device->MaximizeWindow=qnxgf_maximizewindow;
device->MinimizeWindow=qnxgf_minimizewindow;
device->RestoreWindow=qnxgf_restorewindow;
device->SetWindowGrab=qnxgf_setwindowgrab;
device->DestroyWindow=qnxgf_destroywindow;
device->GetWindowWMInfo=qnxgf_getwindowwminfo;
device->GL_LoadLibrary=qnxgf_gl_loadlibrary;
device->GL_GetProcAddress=qnxgf_gl_getprocaddres;
device->GL_UnloadLibrary=qnxgf_gl_unloadlibrary;
device->GL_CreateContext=qnxgf_gl_createcontext;
device->GL_MakeCurrent=qnxgf_gl_makecurrent;
device->GL_SetSwapInterval=qnxgf_gl_setswapinterval;
device->GL_GetSwapInterval=qnxgf_gl_getswapinterval;
device->GL_SwapWindow=qnxgf_gl_swapwindow;
device->GL_DeleteContext=qnxgf_gl_deletecontext;
device->PumpEvents=qnxgf_pumpevents;
device->SuspendScreenSaver=qnxgf_suspendscreensaver;
return device;
}
VideoBootStrap qnxgf_bootstrap=
{
"QNXGF",
"QNX Graphics Framework",
NULL,
NULL
"qnxgf",
"SDL QNX Graphics Framework (GF) video driver",
qnxgf_available,
qnxgf_create
};
/*****************************************************************************/
/* SDL Video and Display initialization/handling functions */
/*****************************************************************************/
int qnxgf_videoinit(_THIS)
{
SDL_VideoData* gfdata=(SDL_VideoData*)_this->driverdata;
uint32_t it;
/* Add each detected output to SDL */
for (it=0; it<gfdata->gfdev_info.ndisplays; it++)
{
SDL_VideoDisplay display;
SDL_DisplayMode current_mode;
SDL_DisplayData* didata;
int status;
didata=(SDL_DisplayData*)SDL_calloc(1, sizeof(SDL_DisplayData));
if (didata==NULL)
{
/* memory allocation problem */
SDL_OutOfMemory();
return -1;
}
status=gf_display_query(gfdata->gfdev, it, &didata->display_info);
if (status==GF_ERR_OK)
{
SDL_zero(current_mode);
current_mode.w=didata->display_info.xres;
current_mode.h=didata->display_info.yres;
current_mode.refresh_rate=didata->display_info.refresh;
current_mode.format=qnxgf_gf_to_sdl_pixelformat(didata->display_info.format);
current_mode.driverdata=NULL;
}
else
{
/* video initialization problem */
SDL_free(didata);
SDL_SetError("Display query failed");
return -1;
}
/* Attach GF to selected display */
status=gf_display_attach(&didata->display, gfdata->gfdev, it, NULL);
if (status!=GF_ERR_OK)
{
/* video initialization problem */
SDL_free(didata);
SDL_SetError("Couldn't not attach to display");
return -1;
}
SDL_zero(display);
display.desktop_mode = current_mode;
display.current_mode = current_mode;
display.driverdata = didata;
SDL_AddVideoDisplay(&display);
}
/* video has been initialized successfully */
return 1;
}
void qnxgf_videoquit(_THIS)
{
SDL_DisplayData* didata;
uint32_t it;
for(it=0; it<_this->num_displays; it++)
{
didata=_this->displays[it].driverdata;
/* Detach from selected display */
gf_display_detach(didata->display);
}
}
void qnxgf_getdisplaymodes(_THIS)
{
SDL_DisplayData* didata = (SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
SDL_DisplayMode mode;
gf_modeinfo_t modeinfo;
uint32_t it=0;
uint32_t jt=0;
uint32_t kt=0;
int status;
do {
status=gf_display_query_mode(didata->display, it, &modeinfo);
if (status==GF_ERR_OK)
{
/* Parsing current mode */
if ((modeinfo.flags & GF_MODE_GENERIC)==GF_MODE_GENERIC)
{
/* This mode is generic, so we can add to SDL our resolutions */
/* Only pixel format is fixed, refresh rate could be any */
jt=0;
do {
if (generic_mode[jt].w==0)
{
break;
}
mode.w=generic_mode[jt].w;
mode.h=generic_mode[jt].h;
mode.refresh_rate=generic_mode[jt].refresh_rate;
mode.format=qnxgf_gf_to_sdl_pixelformat(modeinfo.primary_format);
mode.driverdata=NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
jt++;
} while(1);
}
else
{
/* Add this display mode as is in case if it is non-generic */
/* But go through the each refresh rate, supported by gf */
jt=0;
do {
if (modeinfo.refresh[jt]!=0)
{
mode.w=modeinfo.xres;
mode.h=modeinfo.yres;
mode.refresh_rate=modeinfo.refresh[jt];
mode.format=qnxgf_gf_to_sdl_pixelformat(modeinfo.primary_format);
mode.driverdata=NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
jt++;
}
else
{
break;
}
} while(1);
}
}
else
{
if (status==GF_ERR_PARM)
{
/* out of available modes, all are listed */
break;
}
/* Error occured during mode listing */
break;
}
it++;
} while(1);
}
int qnxgf_setdisplaymode(_THIS, SDL_DisplayMode* mode)
{
SDL_DisplayData* didata = (SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
int result;
result=gf_display_set_mode(didata->display, mode->w, mode->h, mode->refresh_rate,
qnxgf_sdl_to_gf_pixelformat(mode->format), 0);
if (result!=GF_ERR_OK)
{
/* Display mode/resolution switch has been failed */
SDL_SetError("Mode is not supported by qnxgf driver");
return -1;
}
return 0;
}
int qnxgf_setdisplaypalette(_THIS, SDL_Palette* palette)
{
/* Palette must be set through the QNXGF renderer */
/* It connected to surface, part of it */
/* Setting display palette operation has been failed */
return -1;
}
int qnxgf_getdisplaypalette(_THIS, SDL_Palette* palette)
{
/* We can give to upper level palette, which it set before */
/* Getting display palette operation has been failed */
return -1;
}
int qnxgf_setdisplaygammaramp(_THIS, Uint16* ramp)
{
SDL_DisplayData* didata = (SDL_DisplayData*)SDL_CurrentDisplay.driverdata;
int status;
/* GF can set Color LUT independently for each color channel, but SDL */
/* uses combined gamma ramp, set it to each channel */
status=gf_display_set_color_lut16(didata->display, (uint16_t*)ramp, (uint16_t*)ramp, (uint16_t*)ramp);
if (status!=GF_ERR_OK)
{
/* Setting display gamma ramp operation has been failed */
return -1;
}
return 0;
}
int qnxgf_getdisplaygammaramp(_THIS, Uint16* ramp)
{
/* We need to return previous gamma set */
/* Getting display gamma ramp operation has been failed */
return -1;
}
int qnxgf_createwindow(_THIS, SDL_Window* window)
{
/* Failed to create new window */
return -1;
}
int qnxgf_createwindowfrom(_THIS, SDL_Window* window, const void* data)
{
/* Failed to create window from another window */
return -1;
}
void qnxgf_setwindowtitle(_THIS, SDL_Window* window)
{
}
void qnxgf_setwindowicon(_THIS, SDL_Window* window, SDL_Surface* icon)
{
}
void qnxgf_setwindowposition(_THIS, SDL_Window* window)
{
}
void qnxgf_setwindowsize(_THIS, SDL_Window* window)
{
}
void qnxgf_showwindow(_THIS, SDL_Window* window)
{
}
void qnxgf_hidewindow(_THIS, SDL_Window* window)
{
}
void qnxgf_raisewindow(_THIS, SDL_Window* window)
{
}
void qnxgf_maximizewindow(_THIS, SDL_Window* window)
{
}
void qnxgf_minimizewindow(_THIS, SDL_Window* window)
{
}
void qnxgf_restorewindow(_THIS, SDL_Window* window)
{
}
void qnxgf_setwindowgrab(_THIS, SDL_Window* window)
{
}
void qnxgf_destroywindow(_THIS, SDL_Window* window)
{
printf("qnxgf_destroywindow()\n");
}
/*****************************************************************************/
/* SDL Window Manager function */
/*****************************************************************************/
SDL_bool qnxgf_getwindowwminfo(_THIS, SDL_Window* window, struct SDL_SysWMinfo* info)
{
if (info->version.major <= SDL_MAJOR_VERSION)
{
return SDL_TRUE;
}
else
{
SDL_SetError("Application not compiled with SDL %d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
return SDL_FALSE;
}
/* Failed to get window manager information */
return SDL_FALSE;
}
/*****************************************************************************/
/* SDL OpenGL/OpenGL ES functions */
/*****************************************************************************/
int qnxgf_gl_loadlibrary(_THIS, const char* path)
{
/* Failed to load new GL library */
return -1;
}
void* qnxgf_gl_getprocaddres(_THIS, const char* proc)
{
/* Failed to get GL function address pointer */
return NULL;
}
void qnxgf_gl_unloadlibrary(_THIS)
{
}
SDL_GLContext qnxgf_gl_createcontext(_THIS, SDL_Window* window)
{
/* Failed to create GL context */
return NULL;
}
int qnxgf_gl_makecurrent(_THIS, SDL_Window* window, SDL_GLContext context)
{
/* Failed to set current GL context */
return -1;
}
int qnxgf_gl_setswapinterval(_THIS, int interval)
{
/* Failed to set swap interval */
return -1;
}
int qnxgf_gl_getswapinterval(_THIS)
{
/* Failed to get default swap interval */
return -1;
}
void qnxgf_gl_swapwindow(_THIS, SDL_Window* window)
{
}
void qnxgf_gl_deletecontext(_THIS, SDL_GLContext context)
{
}
/*****************************************************************************/
/* SDL Event handling function */
/*****************************************************************************/
void qnxgf_pumpevents(_THIS)
{
}
/*****************************************************************************/
/* SDL screen saver related functions */
/*****************************************************************************/
void qnxgf_suspendscreensaver(_THIS)
{
/* There is no screensaver in pure console, it may exist when running */
/* GF under Photon, but I do not know, how to disable screensaver */
}
/* 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
*/
#ifndef __SDL_QNXGF_H__
#define __SDL_QNXGF_H__
#include "../SDL_sysvideo.h"
#include <gf/gf.h>
typedef struct SDL_VideoData
{
gf_dev_t gfdev; /* GF device handle */
gf_dev_info_t gfdev_info; /* GF device information */
SDL_bool gfinitialized; /* GF device initialization status */
} SDL_VideoData;
typedef struct SDL_DisplayData
{
gf_display_info_t display_info; /* GF display information */
gf_display_t display; /* GF display handle */
} SDL_DisplayData;
/****************************************************************************/
/* SDL_VideoDevice functions declaration */
/****************************************************************************/
/* Display and window functions */
int qnxgf_videoinit(_THIS);
void qnxgf_videoquit(_THIS);
void qnxgf_getdisplaymodes(_THIS);
int qnxgf_setdisplaymode(_THIS, SDL_DisplayMode* mode);
int qnxgf_setdisplaypalette(_THIS, SDL_Palette* palette);
int qnxgf_getdisplaypalette(_THIS, SDL_Palette* palette);
int qnxgf_setdisplaygammaramp(_THIS, Uint16* ramp);
int qnxgf_getdisplaygammaramp(_THIS, Uint16* ramp);
int qnxgf_createwindow(_THIS, SDL_Window* window);
int qnxgf_createwindowfrom(_THIS, SDL_Window* window, const void* data);
void qnxgf_setwindowtitle(_THIS, SDL_Window* window);
void qnxgf_setwindowicon(_THIS, SDL_Window* window, SDL_Surface* icon);
void qnxgf_setwindowposition(_THIS, SDL_Window* window);
void qnxgf_setwindowsize(_THIS, SDL_Window* window);
void qnxgf_showwindow(_THIS, SDL_Window* window);
void qnxgf_hidewindow(_THIS, SDL_Window* window);
void qnxgf_raisewindow(_THIS, SDL_Window* window);
void qnxgf_maximizewindow(_THIS, SDL_Window* window);
void qnxgf_minimizewindow(_THIS, SDL_Window* window);
void qnxgf_restorewindow(_THIS, SDL_Window* window);
void qnxgf_setwindowgrab(_THIS, SDL_Window* window);
void qnxgf_destroywindow(_THIS, SDL_Window* window);
/* Window manager function */
SDL_bool qnxgf_getwindowwminfo(_THIS, SDL_Window* window, struct SDL_SysWMinfo* info);
/* OpenGL/OpenGL ES functions */
int qnxgf_gl_loadlibrary(_THIS, const char* path);
void* qnxgf_gl_getprocaddres(_THIS, const char* proc);
void qnxgf_gl_unloadlibrary(_THIS);
SDL_GLContext qnxgf_gl_createcontext(_THIS, SDL_Window* window);
int qnxgf_gl_makecurrent(_THIS, SDL_Window* window, SDL_GLContext context);
int qnxgf_gl_setswapinterval(_THIS, int interval);
int qnxgf_gl_getswapinterval(_THIS);
void qnxgf_gl_swapwindow(_THIS, SDL_Window* window);
void qnxgf_gl_deletecontext(_THIS, SDL_GLContext context);
/* Event handling function */
void qnxgf_pumpevents(_THIS);
/* Screen saver related function */
void qnxgf_suspendscreensaver(_THIS);
#endif /* __SDL_QNXGF_H__ */
......@@ -7,7 +7,7 @@ EXE = @EXE@
CFLAGS = @CFLAGS@
LIBS = @LIBS@
TARGETS = checkkeys$(EXE) graywin$(EXE) loopwave$(EXE) testresample$(EXE) testaudioinfo$(EXE) testmultiaudio$(EXE) testalpha$(EXE) testbitmap$(EXE) testblitspeed$(EXE) testcdrom$(EXE) testcursor$(EXE) testintersections$(EXE) testdraw2$(EXE) testdyngl$(EXE) testerror$(EXE) testfile$(EXE) testgamma$(EXE) testgl$(EXE) testgl2$(EXE) testhread$(EXE) testiconv$(EXE) testjoystick$(EXE) testkeys$(EXE) testlock$(EXE) testoverlay2$(EXE) testoverlay$(EXE) testpalette$(EXE) testplatform$(EXE) testsem$(EXE) testsprite$(EXE) testsprite2$(EXE) testtimer$(EXE) testver$(EXE) testvidinfo$(EXE) testwin$(EXE) testwm$(EXE) testwm2$(EXE) threadwin$(EXE) torturethread$(EXE) testloadso$(EXE) testhaptic$(EXE) testmmousetablet$(EXE)
TARGETS = checkkeys$(EXE) graywin$(EXE) loopwave$(EXE) testresample$(EXE) testaudioinfo$(EXE) testmultiaudio$(EXE) testalpha$(EXE) testbitmap$(EXE) testblitspeed$(EXE) testcdrom$(EXE) testcursor$(EXE) testintersections$(EXE) testdraw2$(EXE) testdyngl$(EXE) testdyngles$(EXE) testerror$(EXE) testfile$(EXE) testgamma$(EXE) testgl$(EXE) testgl2$(EXE) testgles$(EXE) testhread$(EXE) testiconv$(EXE) testjoystick$(EXE) testkeys$(EXE) testlock$(EXE) testoverlay2$(EXE) testoverlay$(EXE) testpalette$(EXE) testplatform$(EXE) testsem$(EXE) testsprite$(EXE) testsprite2$(EXE) testtimer$(EXE) testver$(EXE) testvidinfo$(EXE) testwin$(EXE) testwm$(EXE) testwm2$(EXE) threadwin$(EXE) torturethread$(EXE) testloadso$(EXE) testhaptic$(EXE) testmmousetablet$(EXE)
all: Makefile $(TARGETS)
......@@ -56,6 +56,9 @@ testdraw2$(EXE): $(srcdir)/testdraw2.c $(srcdir)/common.c
testdyngl$(EXE): $(srcdir)/testdyngl.c
$(CC) -o $@ $? $(CFLAGS) $(LIBS)
testdyngles$(EXE): $(srcdir)/testdyngles.c
$(CC) -o $@ $? $(CFLAGS) $(LIBS)
testerror$(EXE): $(srcdir)/testerror.c
$(CC) -o $@ $? $(CFLAGS) $(LIBS)
......@@ -71,6 +74,9 @@ testgl$(EXE): $(srcdir)/testgl.c
testgl2$(EXE): $(srcdir)/testgl2.c $(srcdir)/common.c
$(CC) -o $@ $(srcdir)/testgl2.c $(srcdir)/common.c $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
testgles$(EXE): $(srcdir)/testgles.c $(srcdir)/common.c
$(CC) -o $@ $(srcdir)/testgles.c $(srcdir)/common.c $(CFLAGS) $(LIBS) @GLLIB@ @MATHLIB@
testhread$(EXE): $(srcdir)/testhread.c
$(CC) -o $@ $? $(CFLAGS) $(LIBS)
......
......@@ -49,7 +49,12 @@ case "$host" in
else
SYS_GL_LIBS="-lOSMesa"
fi
;;
;;
*-*-qnx*)
EXE=""
MATHLIB=""
SYS_GL_LIBS="-lGLES_CM"
;;
*)
EXE=""
MATHLIB="-lm"
......@@ -99,6 +104,30 @@ if test x$have_opengl = xyes; then
else
GLLIB=""
fi
dnl Check for OpenGL ES
AC_MSG_CHECKING(for OpenGL ES support)
have_opengles=no
AC_TRY_COMPILE([
#if defined (__QNXNTO__)
#include <GLES/gl.h>
#elif defined (__IPHONEOS__)
#include <OpenGLES/ES1/gl.h>
#else
#error "No OpenGL ES support"
#endif /* __QNXNTO__ */
],[
],[
have_opengles=yes
])
AC_MSG_RESULT($have_opengles)
if test x$have_opengles = xyes; then
CFLAGS="$CFLAGS -DHAVE_OPENGLES"
GLLIB="$XPATH $SYS_GL_LIBS"
else
GLLIB=""
fi
AC_SUBST(GLLIB)
dnl Finally create all the generated files
......
......@@ -129,7 +129,7 @@ main(int argc, char *argv[])
}
if (SDL_GL_LoadLibrary(gl_library) < 0) {
printf("Unable to dynamically open GL lib : %s\n", SDL_GetError());
printf("Unable to dynamically open GL ES lib : %s\n", SDL_GetError());
quit(1);
}
......@@ -139,7 +139,7 @@ main(int argc, char *argv[])
}
/* Set the window manager title bar */
SDL_WM_SetCaption("SDL Dynamic OpenGL Loading Test", "testdyngl");
SDL_WM_SetCaption("SDL Dynamic OpenGL ES Loading Test", "testdyngles");
init_glfuncs(&f);
......@@ -206,7 +206,7 @@ main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
printf("No OpenGL support on this system\n");
printf("No OpenGL ES support on this system\n");
return 1;
}
......
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