src/video/photon/SDL_photon.c
author Mike Gorchak <lestat@i.com.ua>
Fri, 20 Nov 2009 14:42:40 +0000
changeset 3465 0cbfec87e4f1
parent 3411 d15a4daa4a58
child 3500 4b594623401b
permissions -rw-r--r--
Support for UTF-8 text input has been added.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
    SDL - Simple DirectMedia Layer
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
    Copyright (C) 1997-2009 Sam Lantinga
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
    This library is free software; you can redistribute it and/or
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    modify it under the terms of the GNU Lesser General Public
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    License as published by the Free Software Foundation; either
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    version 2.1 of the License, or (at your option) any later version.
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
    This library is distributed in the hope that it will be useful,
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    Lesser General Public License for more details.
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    You should have received a copy of the GNU Lesser General Public
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    License along with this library; if not, write to the Free Software
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
    Sam Lantinga
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    slouken@libsdl.org
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
    21
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
    22
    QNX Photon GUI SDL driver
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
    23
    Copyright (C) 2009 Mike Gorchak
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
    24
    (mike@malva.ua, lestat@i.com.ua)
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
*/
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    27
/* SDL internals */
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#include "SDL_config.h"
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#include "../SDL_sysvideo.h"
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
    30
#include "SDL_version.h"
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
    31
#include "SDL_syswm.h"
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    32
#include "SDL_loadso.h"
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    33
#include "SDL_events.h"
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    34
#include "../../events/SDL_mouse_c.h"
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    35
#include "../../events/SDL_keyboard_c.h"
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
    36
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    37
/* Photon declarations */
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    38
#include "SDL_photon.h"
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    39
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    40
/* Pixel format conversion routines */
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    41
#include "SDL_photon_pixelfmt.h"
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    42
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    43
/* Use GF's pixel format functions for OpenGL ES context creation */
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    44
#if defined(SDL_VIDEO_OPENGL_ES)
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    45
#include "../qnxgf/SDL_gf_pixelfmt.h"
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    46
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3193
diff changeset
    47
/* If GF driver is not compiled in, include some of usefull functions */
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    48
#if !defined(SDL_VIDEO_DRIVER_QNXGF)
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    49
#include "../qnxgf/SDL_gf_pixelfmt.c"
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    50
#endif /* SDL_VIDEO_DRIVER_QNXGF */
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    51
#endif /* SDL_VIDEO_OPENGL_ES */
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    52
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    53
/* Use GF's OpenGL ES 1.1 functions emulation */
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    54
#if defined(SDL_VIDEO_OPENGL_ES)
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    55
#include "../qnxgf/SDL_gf_opengles.h"
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    56
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3193
diff changeset
    57
/* If GF driver is not compiled in, include some of usefull functions */
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    58
#if !defined(SDL_VIDEO_DRIVER_QNXGF)
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    59
#include "../qnxgf/SDL_gf_opengles.c"
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    60
#endif /* SDL_VIDEO_DRIVER_QNXGF */
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    61
#endif /* SDL_VIDEO_OPENGL_ES */
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
    62
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
    63
/* Low level device graphics driver names, which they are reporting */
3185
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
    64
static const Photon_DeviceCaps photon_devicename[] = {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    65
    /* ATI Rage 128 graphics driver (devg-ati_rage128)      */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    66
    {"ati_rage128", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    67
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    68
    /* Fujitsu Carmine graphics driver (devg-carmine.so)    */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    69
    {"carmine", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    70
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    71
    /* C&T graphics driver (devg-chips.so)                  */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    72
    {"chips", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    73
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    74
    /* Fujitsu Coral graphics driver (devg-coral.so)        */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    75
    {"coral", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    76
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    77
    /* Intel integrated graphics driver (devg-extreme2.so)  */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    78
    {"extreme2", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    79
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    80
    /* Unaccelerated FB driver (devg-flat.so)               */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    81
    {"flat", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    82
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    83
    /* NS Geode graphics driver (devg-geode.so)             */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    84
    {"geode", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    85
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    86
    /* Geode LX graphics driver (devg-geodelx.so)           */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    87
    {"geodelx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    88
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    89
    /* Intel integrated graphics driver (devg-gma9xx.so)    */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    90
    {"gma", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    91
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    92
    /* Intel integrated graphics driver (devg-i810.so)      */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    93
    {"i810", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    94
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    95
    /* Intel integrated graphics driver (devg-i830.so)      */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    96
    {"i830", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    97
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    98
    /* Geode LX graphics driver (devg-lx800.so)             */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
    99
    {"lx800", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   100
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   101
    /* Matrox Gxx graphics driver (devg-matroxg.so)         */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   102
    {"matroxg", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   103
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   104
    /* Intel Poulsbo graphics driver (devg-poulsbo.so)      */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   105
    {"poulsbo", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   106
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   107
    /* ATI Radeon driver (devg-radeon.so)                   */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   108
    {"radeon", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   109
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   110
    /* ATI Rage driver (devg-rage.so)                       */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   111
    {"rage", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   112
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   113
    /* S3 Savage graphics driver (devg-s3_savage.so)        */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   114
    {"s3_savage", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   115
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   116
    /* SiS630 integrated graphics driver (devg-sis630.so)   */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   117
    {"sis630", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   118
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   119
    /* PowerVR SGX 535 graphics driver (devg-poulsbo.so)    */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   120
    {"sgx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   121
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   122
    /* SM Voyager GX graphics driver (devg-smi5xx.so)       */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   123
    {"smi5xx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   124
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   125
    /* Silicon Motion graphics driver (devg-smi7xx.so)      */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   126
    {"smi7xx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   127
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   128
    /* SVGA unaccelerated gfx driver (devg-svga.so)         */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   129
    {"svga", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   130
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   131
    /* nVidia TNT graphics driver (devg-tnt.so)             */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   132
    {"tnt", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   133
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   134
    /* VIA integrated graphics driver (devg-tvia.so)        */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   135
    {"tvia", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   136
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   137
    /* VIA UniChrome graphics driver (devg-unichrome.so)    */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   138
    {"unichrome", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   139
    ,
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3193
diff changeset
   140
    /* VESA unaccelerated gfx driver (devg-vesabios.so)     */
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   141
    {"vesa", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   142
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   143
    /* VmWare graphics driver (devg-volari.so)              */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   144
    {"vmware", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   145
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   146
    /* XGI XP10 graphics driver (devg-volari.so), OpenGL 1.5 */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   147
    {"volari", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   148
    ,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   149
    /* End of list */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   150
    {NULL, 0x00000000}
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   151
};
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   153
static SDL_bool photon_initialized = SDL_FALSE;
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   155
static int
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   156
photon_available(void)
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
{
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3193
diff changeset
   158
    int32_t status;
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   160
    /* Check if Photon was initialized before */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   161
    if (photon_initialized == SDL_FALSE) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   162
        /* Initialize Photon widget library and open channel to Photon */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   163
        status = PtInit(NULL);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   164
        if (status == 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   165
            photon_initialized = SDL_TRUE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   166
            return 1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   167
        } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   168
            photon_initialized = SDL_FALSE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   169
            return 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   170
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   171
    }
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   173
    return 1;
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
}
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   176
static void
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   177
photon_destroy(SDL_VideoDevice * device)
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   179
    SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   180
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   181
#if defined(SDL_VIDEO_OPENGL_ES)
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   182
    if (phdata->gfinitialized != SDL_FALSE) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   183
        gf_dev_detach(phdata->gfdev);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   184
    }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   185
#endif /* SDL_VIDEO_OPENGL_ES */
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   186
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   187
    if (device->driverdata != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   188
        device->driverdata = NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   189
    }
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
}
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   192
static SDL_VideoDevice *
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   193
photon_create(int devindex)
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   195
    SDL_VideoDevice *device;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   196
    SDL_VideoData *phdata;
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3193
diff changeset
   197
    int32_t status;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   198
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   199
    /* Check if photon could be initialized */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   200
    status = photon_available();
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   201
    if (status == 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   202
        /* Photon could not be used */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   203
        return NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   204
    }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   205
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   206
    /* Photon agregates all video devices to one with multiple heads */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   207
    if (devindex != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   208
        /* devindex could be zero only in Photon SDL driver */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   209
        return NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   210
    }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   211
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   212
    /* Initialize SDL_VideoDevice structure */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   213
    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   214
    if (device == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   215
        SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   216
        return NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   217
    }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   218
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   219
    /* Initialize internal photon specific data */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   220
    phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   221
    if (phdata == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   222
        SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   223
        SDL_free(device);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   224
        return NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   225
    }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   226
    device->driverdata = phdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   227
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   228
    /* Get all photon display devices */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   229
    phdata->avail_rids =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   230
        PdGetDevices(&phdata->rid[0], SDL_VIDEO_PHOTON_MAX_RIDS);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   231
    if (phdata->avail_rids > SDL_VIDEO_PHOTON_MAX_RIDS) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   232
        phdata->avail_rids = SDL_VIDEO_PHOTON_MAX_RIDS;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   233
    }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   234
#if defined(SDL_VIDEO_OPENGL_ES)
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   235
    /* TODO: add real device detection versus multiple heads */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   236
    status =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   237
        gf_dev_attach(&phdata->gfdev, GF_DEVICE_INDEX(0),
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   238
                      &phdata->gfdev_info);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   239
    if (status != GF_ERR_OK) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   240
        /* Do not fail right now, if GF can't be attached */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   241
        phdata->gfinitialized = SDL_FALSE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   242
    } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   243
        phdata->gfinitialized = SDL_TRUE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   244
    }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   245
#endif /* SDL_VIDEO_OPENGL_ES */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   246
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   247
    /* Set default target device */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   248
    status = PdSetTargetDevice(NULL, phdata->rid[0]);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   249
    if (status == -1) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   250
        SDL_SetError("Photon: Can't set default target device");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   251
#if defined(SDL_VIDEO_OPENGL_ES)
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   252
        gf_dev_detach(phdata->gfdev);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   253
#endif /* SDL_VIDEO_OPENGL_ES */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   254
        SDL_free(phdata);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   255
        SDL_free(device);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   256
        return NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   257
    }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   258
    phdata->current_device_id = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   259
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   260
    /* Setup amount of available displays and current display */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   261
    device->num_displays = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   262
    device->current_display = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   263
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   264
    /* Set device free function */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   265
    device->free = photon_destroy;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   266
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   267
    /* Setup all functions which we can handle */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   268
    device->VideoInit = photon_videoinit;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   269
    device->VideoQuit = photon_videoquit;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   270
    device->GetDisplayModes = photon_getdisplaymodes;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   271
    device->SetDisplayMode = photon_setdisplaymode;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   272
    device->SetDisplayPalette = photon_setdisplaypalette;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   273
    device->GetDisplayPalette = photon_getdisplaypalette;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   274
    device->SetDisplayGammaRamp = photon_setdisplaygammaramp;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   275
    device->GetDisplayGammaRamp = photon_getdisplaygammaramp;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   276
    device->CreateWindow = photon_createwindow;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   277
    device->CreateWindowFrom = photon_createwindowfrom;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   278
    device->SetWindowTitle = photon_setwindowtitle;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   279
    device->SetWindowIcon = photon_setwindowicon;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   280
    device->SetWindowPosition = photon_setwindowposition;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   281
    device->SetWindowSize = photon_setwindowsize;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   282
    device->ShowWindow = photon_showwindow;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   283
    device->HideWindow = photon_hidewindow;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   284
    device->RaiseWindow = photon_raisewindow;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   285
    device->MaximizeWindow = photon_maximizewindow;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   286
    device->MinimizeWindow = photon_minimizewindow;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   287
    device->RestoreWindow = photon_restorewindow;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   288
    device->SetWindowGrab = photon_setwindowgrab;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   289
    device->DestroyWindow = photon_destroywindow;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   290
    device->GetWindowWMInfo = photon_getwindowwminfo;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   291
    device->GL_LoadLibrary = photon_gl_loadlibrary;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   292
    device->GL_GetProcAddress = photon_gl_getprocaddres;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   293
    device->GL_UnloadLibrary = photon_gl_unloadlibrary;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   294
    device->GL_CreateContext = photon_gl_createcontext;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   295
    device->GL_MakeCurrent = photon_gl_makecurrent;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   296
    device->GL_SetSwapInterval = photon_gl_setswapinterval;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   297
    device->GL_GetSwapInterval = photon_gl_getswapinterval;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   298
    device->GL_SwapWindow = photon_gl_swapwindow;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   299
    device->GL_DeleteContext = photon_gl_deletecontext;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   300
    device->PumpEvents = photon_pumpevents;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   301
    device->SuspendScreenSaver = photon_suspendscreensaver;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   302
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   303
    return device;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   304
}
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   305
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   306
VideoBootStrap photon_bootstrap = {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   307
    "photon",
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   308
    "SDL QNX Photon video driver",
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   309
    photon_available,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   310
    photon_create
3087
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   311
};
0b6f51c29267 Date: Wed, 4 Mar 2009 15:38:22 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   312
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   313
/*****************************************************************************/
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   314
/* SDL Video and Display initialization/handling functions                   */
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   315
/*****************************************************************************/
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   316
int
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   317
photon_videoinit(_THIS)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   318
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   319
    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   320
    PgHWCaps_t hwcaps;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   321
    PgVideoModeInfo_t modeinfo;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   322
    int32_t status;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   323
    SDL_VideoDisplay display;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   324
    SDL_DisplayMode current_mode;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   325
    SDL_DisplayData *didata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   326
    uint32_t it;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   327
    uint32_t jt;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   328
    char *override;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   329
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   330
    /* By default Photon do not uses swap on VSYNC */
3411
d15a4daa4a58 Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents: 3399
diff changeset
   331
#if defined(SDL_VIDEO_OPENGL_ES)
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   332
    phdata->swapinterval = 0;
3411
d15a4daa4a58 Fixes in GLES configuration selection. Support for an old QNX 6.3.2.
Mike Gorchak <lestat@i.com.ua>
parents: 3399
diff changeset
   333
#endif /* SDL_VIDEO_OPENGL_ES */
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   334
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   335
    for (it = 0; it < phdata->avail_rids; it++) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   336
        didata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   337
        if (didata == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   338
            /* memory allocation error */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   339
            SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   340
            return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   341
        }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   342
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   343
        /* Allocate two cursors with SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE size */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   344
        /* and 128 bytes of spare place                                    */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   345
        didata->cursor_size =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   346
            ((SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE * 4) >> 3) + 128;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   347
        didata->cursor = (PhCursorDef_t *) SDL_calloc(1, didata->cursor_size);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   348
        if (didata->cursor == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   349
            /* memory allocation error */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   350
            SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   351
            SDL_free(didata);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   352
            return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   353
        }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   354
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   355
        /* Initialize GF in case of OpenGL ES support is compiled in */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   356
#if defined(SDL_VIDEO_OPENGL_ES)
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   357
        /* TODO: add real device detection versus multiple heads */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   358
        if (phdata->gfinitialized == SDL_TRUE) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   359
            status =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   360
                gf_display_attach(&didata->display, phdata->gfdev, it,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   361
                                  &didata->display_info);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   362
            if (status != GF_ERR_OK) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   363
                /* Just shutdown GF, do not fail */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   364
                gf_dev_detach(phdata->gfdev);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   365
                phdata->gfinitialized = SDL_FALSE;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   366
            }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   367
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   368
#endif /* SDL_VIDEO_OPENGL_ES */
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   369
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   370
        /* Check if current device is not the same as target */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   371
        if (phdata->current_device_id != it) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   372
            /* Set target device as default for Pd and Pg functions */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   373
            status = PdSetTargetDevice(NULL, phdata->rid[it]);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   374
            if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   375
                SDL_SetError("Photon: Can't set default target device\n");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   376
                SDL_free(didata->cursor);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   377
                SDL_free(didata);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   378
                return -1;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   379
            }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   380
            phdata->current_device_id = it;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   381
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   382
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   383
        /* Store device id */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   384
        didata->device_id = it;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   385
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   386
        /* Query photon about graphics hardware caps and current video mode */
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   387
        SDL_memset(&hwcaps, 0x00, sizeof(PgHWCaps_t));
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   388
        status = PgGetGraphicsHWCaps(&hwcaps);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   389
        if (status != 0) {
3185
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   390
            PhRect_t extent;
3193
64e4442676a6 Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
   391
            PdOffscreenContext_t* curctx;
3185
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   392
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   393
            /* If error happens, this also could mean, that photon is working */
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   394
            /* under custom (not listed by photon) video mode                 */
3193
64e4442676a6 Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
   395
            status=PhWindowQueryVisible(Ph_QUERY_GRAPHICS, 0, 0, &extent);
3185
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   396
            if (status != 0) {
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   397
                SDL_SetError("Photon: Can't get graphics driver region");
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   398
                SDL_free(didata->cursor);
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   399
                SDL_free(didata);
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   400
                return -1;
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   401
            }
3193
64e4442676a6 Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
   402
            modeinfo.width=extent.lr.x+1;
64e4442676a6 Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
   403
            modeinfo.height=extent.lr.y+1;
3185
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   404
            /* Hardcode 60Hz, as the base refresh rate frequency */
3193
64e4442676a6 Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
   405
            hwcaps.current_rrate=60;
3185
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   406
            /* Clear current video driver name, no way to get it somehow */
3193
64e4442676a6 Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
   407
            hwcaps.chip_name[0]=0x00;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   408
3185
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   409
            /* Create offscreen context from video memory, which is currently */
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   410
            /* displayed on the screen                                        */
3193
64e4442676a6 Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
   411
            curctx=PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY);
64e4442676a6 Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
   412
            if (curctx==NULL)
64e4442676a6 Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
   413
            {
3185
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   414
                SDL_SetError("Photon: Can't get display area capabilities");
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   415
                SDL_free(didata->cursor);
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   416
                SDL_free(didata);
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   417
                return -1;
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   418
            }
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   419
            /* Retrieve current bpp */
3193
64e4442676a6 Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
   420
            modeinfo.type=curctx->format;
3185
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   421
            PhDCRelease(curctx);
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   422
        } else {
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   423
            /* Get current video mode details */
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   424
            status = PgGetVideoModeInfo(hwcaps.current_video_mode, &modeinfo);
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   425
            if (status != 0) {
3193
64e4442676a6 Fixed problems with OpenGL ES window resizing.
Mike Gorchak <lestat@i.com.ua>
parents: 3186
diff changeset
   426
                SDL_SetError("Photon: Can't get current video mode information");
3185
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   427
                SDL_free(didata->cursor);
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   428
                SDL_free(didata);
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   429
                return -1;
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   430
            }
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   431
3399
f96615051c8c Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
   432
            /* Get current video mode 2D capabilities for the renderer */
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   433
            didata->mode_2dcaps=0;
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   434
            if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND)
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   435
            {
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
   436
               didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND;
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   437
            }
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   438
            if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_SCALED_BLIT)==PgVM_MODE_CAP2_SCALED_BLIT)
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   439
            {
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
   440
               didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_SCALED_BLIT;
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   441
            }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   442
        }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   443
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   444
        /* Setup current desktop mode for SDL */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   445
        SDL_zero(current_mode);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   446
        current_mode.w = modeinfo.width;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   447
        current_mode.h = modeinfo.height;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   448
        current_mode.refresh_rate = hwcaps.current_rrate;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   449
        current_mode.format = photon_image_to_sdl_pixelformat(modeinfo.type);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   450
        current_mode.driverdata = NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   451
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   452
        /* Copy device name */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   453
        SDL_strlcpy(didata->description, hwcaps.chip_name,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   454
                    SDL_VIDEO_PHOTON_DEVICENAME_MAX - 1);
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   455
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   456
        /* Search device capabilities and possible workarounds */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   457
        jt = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   458
        do {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   459
            if (photon_devicename[jt].name == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   460
                break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   461
            }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   462
            if (SDL_strncmp
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   463
                (photon_devicename[jt].name, didata->description,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   464
                 SDL_strlen(photon_devicename[jt].name)) == 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   465
                didata->caps = photon_devicename[jt].caps;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   466
            }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   467
            jt++;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   468
        } while (1);
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   469
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   470
        /* Initialize display structure */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   471
        SDL_zero(display);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   472
        display.desktop_mode = current_mode;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   473
        display.current_mode = current_mode;
3399
f96615051c8c Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
   474
        display.fullscreen_mode = current_mode;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   475
        display.driverdata = didata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   476
        didata->current_mode = current_mode;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   477
        SDL_AddVideoDisplay(&display);
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   478
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   479
        /* Check for environment variables which could override some SDL settings */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   480
        didata->custom_refresh = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   481
        override = SDL_getenv("SDL_VIDEO_PHOTON_REFRESH_RATE");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   482
        if (override != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   483
            if (SDL_sscanf(override, "%u", &didata->custom_refresh) != 1) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   484
                didata->custom_refresh = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   485
            }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   486
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   487
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   488
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   489
    /* Add photon input devices */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   490
    status = photon_addinputdevices(_this);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   491
    if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   492
        /* SDL error is set by photon_addinputdevices() function */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   493
        return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   494
    }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   495
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   496
    /* Add photon renderer to SDL */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   497
    photon_addrenderdriver(_this);
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   498
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   499
    /* video has been initialized successfully */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   500
    return 1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   501
}
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   502
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   503
void
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   504
photon_videoquit(_THIS)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   505
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   506
    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   507
    SDL_DisplayData *didata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   508
    uint32_t it;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   509
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   510
    /* SDL will restore our desktop mode on exit */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   511
    for (it = 0; it < _this->num_displays; it++) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   512
        didata = _this->displays[it].driverdata;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   513
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   514
        if (didata->cursor != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   515
            SDL_free(didata->cursor);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   516
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   517
#if defined(SDL_VIDEO_OPENGL_ES)
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   518
        if (phdata->gfinitialized == SDL_TRUE) {
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   519
            /* Detach GF display */
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   520
            gf_display_detach(didata->display);
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   521
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   522
#endif /* SDL_VIDEO_OPENGL_ES */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   523
    }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   524
}
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   525
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   526
void
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   527
photon_getdisplaymodes(_THIS)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   528
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   529
    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   530
    SDL_DisplayData *didata =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   531
        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   532
    SDL_DisplayMode mode;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   533
    PgVideoModes_t modes;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   534
    PgVideoModeInfo_t modeinfo;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   535
    int32_t status;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   536
    uint32_t it;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   537
    uint32_t jt;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   538
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   539
    /* Check if current device is not the same as target */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   540
    if (phdata->current_device_id != didata->device_id) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   541
        /* Set target device as default for Pd and Pg functions */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   542
        status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   543
        if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   544
            SDL_SetError("Photon: Can't set default target device\n");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   545
            return;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   546
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   547
        phdata->current_device_id = didata->device_id;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   548
    }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   549
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   550
    /* Get array of available video modes */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   551
    status = PgGetVideoModeList(&modes);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   552
    if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   553
        SDL_SetError("Photon: Can't get video mode list");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   554
        return;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   555
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   556
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   557
    for (it = 0; it < modes.num_modes; it++) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   558
        status = PgGetVideoModeInfo(modes.modes[it], &modeinfo);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   559
        if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   560
            /* Maybe something wrong with this particular mode, skip it */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   561
            continue;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   562
        }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   563
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   564
        jt = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   565
        do {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   566
            if (modeinfo.refresh_rates[jt] != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   567
                mode.w = modeinfo.width;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   568
                mode.h = modeinfo.height;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   569
                mode.refresh_rate = modeinfo.refresh_rates[jt];
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   570
                mode.format = photon_image_to_sdl_pixelformat(modeinfo.type);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   571
                mode.driverdata = NULL;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   572
                SDL_AddDisplayMode(_this->current_display, &mode);
3185
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   573
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   574
                /* If mode is RGBA8888, add the same mode as RGBx888 */
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   575
                if (modeinfo.type == Pg_IMAGE_DIRECT_8888) {
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   576
                    mode.w = modeinfo.width;
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   577
                    mode.h = modeinfo.height;
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   578
                    mode.refresh_rate = modeinfo.refresh_rates[jt];
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   579
                    mode.format = SDL_PIXELFORMAT_RGB888;
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   580
                    mode.driverdata = NULL;
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   581
                    SDL_AddDisplayMode(_this->current_display, &mode);
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   582
                }
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   583
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   584
                /* If mode is RGBA1555, add the same mode as RGBx555 */
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   585
                if (modeinfo.type == Pg_IMAGE_DIRECT_1555) {
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   586
                    mode.w = modeinfo.width;
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   587
                    mode.h = modeinfo.height;
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   588
                    mode.refresh_rate = modeinfo.refresh_rates[jt];
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   589
                    mode.format = SDL_PIXELFORMAT_RGB555;
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   590
                    mode.driverdata = NULL;
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   591
                    SDL_AddDisplayMode(_this->current_display, &mode);
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   592
                }
44d5474c2c8a Continue working on QNX GF and Photon support.
Mike Gorchak <lestat@i.com.ua>
parents: 3139
diff changeset
   593
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   594
                jt++;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   595
            } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   596
                break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   597
            }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   598
        } while (1);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   599
    }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   600
}
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   601
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   602
int
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   603
photon_setdisplaymode(_THIS, SDL_DisplayMode * mode)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   604
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   605
    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   606
    SDL_DisplayData *didata =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   607
        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   608
    PgVideoModes_t modes;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   609
    PgVideoModeInfo_t modeinfo;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   610
    PgDisplaySettings_t modesettings;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   611
    uint32_t refresh_rate = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   612
    int32_t status;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   613
    uint32_t it;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   614
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   615
    /* Check if current device is not the same as target */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   616
    if (phdata->current_device_id != didata->device_id) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   617
        /* Set target device as default for Pd and Pg functions */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   618
        status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   619
        if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   620
            SDL_SetError("Photon: Can't set default target device\n");
3399
f96615051c8c Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
   621
            return -1;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   622
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   623
        phdata->current_device_id = didata->device_id;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   624
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   625
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   626
    /* Get array of available video modes */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   627
    status = PgGetVideoModeList(&modes);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   628
    if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   629
        SDL_SetError("Photon: Can't get video mode list");
3399
f96615051c8c Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
   630
        return -1;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   631
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   632
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   633
    /* Current display dimension and bpp are no more valid */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   634
    didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   635
    didata->current_mode.w = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   636
    didata->current_mode.h = 0;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   637
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   638
    /* Check if custom refresh rate requested */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   639
    if (didata->custom_refresh != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   640
        refresh_rate = didata->custom_refresh;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   641
    } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   642
        refresh_rate = mode->refresh_rate;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   643
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   644
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   645
    /* Check if SDL GF driver needs to find appropriate refresh rate itself */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   646
    if (refresh_rate == 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   647
        SDL_DisplayMode tempmode;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   648
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   649
        /* Clear display mode structure */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   650
        SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode));
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   651
        tempmode.refresh_rate = 0x0000FFFF;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   652
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   653
        /* Check if window width and height matches one of our modes */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   654
        for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   655
            if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) &&
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   656
                (SDL_CurrentDisplay.display_modes[it].h == mode->h) &&
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   657
                (SDL_CurrentDisplay.display_modes[it].format == mode->format))
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   658
            {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   659
                /* Find the lowest refresh rate available */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   660
                if (tempmode.refresh_rate >
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   661
                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   662
                    tempmode = SDL_CurrentDisplay.display_modes[it];
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   663
                }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   664
            }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   665
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   666
        if (tempmode.refresh_rate != 0x0000FFFF) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   667
            refresh_rate = tempmode.refresh_rate;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   668
        } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   669
            /* Let video driver decide what to do with this */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   670
            refresh_rate = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   671
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   672
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   673
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   674
    /* Check if SDL GF driver needs to check custom refresh rate */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   675
    if (didata->custom_refresh != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   676
        SDL_DisplayMode tempmode;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   677
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   678
        /* Clear display mode structure */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   679
        SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode));
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   680
        tempmode.refresh_rate = 0x0000FFFF;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   681
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   682
        /* Check if window width and height matches one of our modes */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   683
        for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   684
            if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) &&
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   685
                (SDL_CurrentDisplay.display_modes[it].h == mode->h) &&
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   686
                (SDL_CurrentDisplay.display_modes[it].format == mode->format))
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   687
            {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   688
                /* Find the lowest refresh rate available */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   689
                if (tempmode.refresh_rate >
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   690
                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   691
                    tempmode = SDL_CurrentDisplay.display_modes[it];
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   692
                }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   693
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   694
                /* Check if requested refresh rate found */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   695
                if (refresh_rate ==
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   696
                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   697
                    tempmode = SDL_CurrentDisplay.display_modes[it];
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   698
                    break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   699
                }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   700
            }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   701
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   702
        if (tempmode.refresh_rate != 0x0000FFFF) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   703
            refresh_rate = tempmode.refresh_rate;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   704
        } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   705
            /* Let video driver decide what to do with this */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   706
            refresh_rate = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   707
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   708
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   709
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   710
    /* Find photon's video mode number */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   711
    for (it = 0; it < modes.num_modes; it++) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   712
        uint32_t jt;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   713
        uint32_t foundrefresh;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   714
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   715
        /* Get current video mode details */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   716
        status = PgGetVideoModeInfo(modes.modes[it], &modeinfo);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   717
        if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   718
            /* Maybe something wrong with this particular mode, skip it */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   719
            continue;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   720
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   721
        if ((modeinfo.width == mode->w) && (modeinfo.height == mode->h) &&
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   722
            (modeinfo.type == photon_sdl_to_image_pixelformat(mode->format)))
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   723
        {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   724
            /* Mode is found, find requested refresh rate, this case is for */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   725
            /* video drivers, which provide non-generic video modes.        */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   726
            jt = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   727
            foundrefresh = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   728
            do {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   729
                if (modeinfo.refresh_rates[jt] != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   730
                    if (modeinfo.refresh_rates[jt] == refresh_rate) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   731
                        foundrefresh = 1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   732
                        break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   733
                    }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   734
                    jt++;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   735
                } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   736
                    break;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   737
                }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   738
            } while (1);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   739
            if (foundrefresh != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   740
                break;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   741
            }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   742
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   743
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   744
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   745
    /* Check if video mode has not been found */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   746
    if (it == modes.num_modes) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   747
        SDL_SetError("Photon: Can't find appropriate video mode");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   748
        return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   749
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   750
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   751
    /* Fill mode settings */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   752
    modesettings.flags = 0x00000000;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   753
    modesettings.mode = modes.modes[it];
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   754
    modesettings.refresh = refresh_rate;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   755
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   756
    /* Finally set new video mode */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   757
    status = PgSetVideoMode(&modesettings);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   758
    if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   759
        SDL_SetError("Photon: Can't set new video mode");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   760
        return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   761
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   762
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   763
    /* Store new video mode parameters */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   764
    didata->current_mode = *mode;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   765
    didata->current_mode.refresh_rate = refresh_rate;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   766
3399
f96615051c8c Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
   767
    /* Get current video mode 2D capabilities for the renderer */
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   768
    didata->mode_2dcaps=0;
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   769
    if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND)
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   770
    {
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
   771
       didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND;
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   772
    }
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   773
    if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_SCALED_BLIT)==PgVM_MODE_CAP2_SCALED_BLIT)
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   774
    {
3386
fff074de9675 Photon SDL renderer almost finished, the double/tripple buffering is left only.
Mike Gorchak <lestat@i.com.ua>
parents: 3384
diff changeset
   775
       didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_SCALED_BLIT;
3384
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   776
    }
04af265172f9 Continue working on 2D support in Photon.
Mike Gorchak <lestat@i.com.ua>
parents: 3383
diff changeset
   777
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   778
    return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   779
}
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   780
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   781
int
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   782
photon_setdisplaypalette(_THIS, SDL_Palette * palette)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   783
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   784
    SDL_DisplayData *didata =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   785
        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   786
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   787
    /* Setting display palette operation has been failed */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   788
    return -1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   789
}
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   790
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   791
int
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   792
photon_getdisplaypalette(_THIS, SDL_Palette * palette)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   793
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   794
    SDL_DisplayData *didata =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   795
        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   796
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   797
    /* Getting display palette operation has been failed */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   798
    return -1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   799
}
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   800
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   801
int
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   802
photon_setdisplaygammaramp(_THIS, Uint16 * ramp)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   803
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   804
    SDL_DisplayData *didata =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   805
        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   806
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   807
    /* Setting display gamma ramp operation has been failed */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   808
    return -1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   809
}
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   810
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   811
int
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   812
photon_getdisplaygammaramp(_THIS, Uint16 * ramp)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   813
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   814
    /* Getting display gamma ramp operation has been failed */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   815
    return -1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   816
}
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   817
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   818
int
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   819
photon_createwindow(_THIS, SDL_Window * window)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   820
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   821
    SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   822
    SDL_DisplayData *didata =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   823
        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   824
    SDL_WindowData *wdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   825
    PhDim_t winsize;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   826
    PhPoint_t winpos;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   827
    PtArg_t winargs[32];
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   828
    uint32_t winargc = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   829
    int32_t status;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   830
    PhRegion_t wregion;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   831
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   832
    /* Allocate window internal data */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   833
    wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData));
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   834
    if (wdata == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   835
        SDL_OutOfMemory();
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   836
        return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   837
    }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   838
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   839
    /* Setup driver data for this window */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   840
    window->driverdata = wdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   841
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   842
    /* Set initial window title */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   843
    if (window->title != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   844
        PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_TITLE, window->title, 0);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   845
    } else {
3383
90935231e9b6 Continue working on 2D support in Photon
Mike Gorchak <lestat@i.com.ua>
parents: 3375
diff changeset
   846
        PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_TITLE, "SDL unnamed application", 0);
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   847
    }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   848
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   849
    /* TODO: handle SDL_WINDOW_INPUT_GRABBED */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   850
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   851
    /* Disable default window filling on redraw */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   852
    PtSetArg(&winargs[winargc++], Pt_ARG_BASIC_FLAGS, Pt_TRUE,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   853
             Pt_BASIC_PREVENT_FILL);
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   854
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   855
    /* Reset default managed flags to disabled state */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   856
    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   857
             Ph_WM_APP_DEF_MANAGED);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   858
    /* Set which events we will not handle, let WM to handle them */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   859
    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   860
             Ph_WM_BACKDROP | Ph_WM_TOFRONT | Ph_WM_COLLAPSE | Ph_WM_FFRONT |
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   861
             Ph_WM_FOCUS | Ph_WM_HELP | Ph_WM_HIDE | Ph_WM_MAX |
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   862
             Ph_WM_MENU | Ph_WM_MOVE | Ph_WM_RESTORE | Ph_WM_TASKBAR |
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   863
             Ph_WM_TOBACK | Ph_WM_RESIZE);
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   864
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   865
    /* Reset default notify events to disable */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   866
    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   867
             Ph_WM_RESIZE | Ph_WM_CLOSE | Ph_WM_HELP);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   868
    /* Set which events we will handle */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   869
    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   870
             Ph_WM_CLOSE | Ph_WM_COLLAPSE | Ph_WM_FOCUS | Ph_WM_MAX |
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   871
             Ph_WM_MOVE | Ph_WM_RESIZE | Ph_WM_RESTORE | Ph_WM_HIDE);
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   872
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   873
    /* Borderless window can't be resizeable */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   874
    if ((window->flags & SDL_WINDOW_BORDERLESS) == SDL_WINDOW_BORDERLESS) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   875
        window->flags &= ~(SDL_WINDOW_RESIZABLE);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   876
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   877
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   878
    /* Reset all default decorations */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   879
    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   880
             Ph_WM_APP_DEF_RENDER);
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   881
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   882
    /* Fullscreen window has its own decorations */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   883
    if ((window->flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   884
        window->flags |= SDL_WINDOW_BORDERLESS;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   885
        window->flags &= ~(SDL_WINDOW_RESIZABLE);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   886
        PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   887
                 Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_TITLE);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   888
    } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   889
        uint32_t decorations =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   890
            Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN |
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   891
            Ph_WM_RENDER_TITLE | Ph_WM_RENDER_MOVE;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   892
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   893
        if ((window->flags & SDL_WINDOW_RESIZABLE) == SDL_WINDOW_RESIZABLE) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   894
            decorations |=
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   895
                Ph_WM_RENDER_BORDER | Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   896
            PtSetArg(&winargs[winargc++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   897
                     Pt_RESIZE_XY_AS_REQUIRED);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   898
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   899
        if ((window->flags & SDL_WINDOW_BORDERLESS) != SDL_WINDOW_BORDERLESS) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   900
            decorations |= Ph_WM_RENDER_BORDER;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   901
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   902
        PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   903
                 decorations);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   904
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   905
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   906
    /* Set initial window state */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   907
    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_FALSE,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   908
             Ph_WM_STATE_ISFOCUS);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   909
    PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_TRUE,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   910
             Ph_WM_STATE_ISALTKEY);
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   911
3375
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3193
diff changeset
   912
    /* Special case, do not handle maximize events, if window can't be resized */
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3193
diff changeset
   913
    if ((window->flags & SDL_WINDOW_RESIZABLE) != SDL_WINDOW_RESIZABLE)
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3193
diff changeset
   914
    {
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3193
diff changeset
   915
       PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE,
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3193
diff changeset
   916
                Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE);
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3193
diff changeset
   917
    }
dd105b317335 Continue working on 2D support for Photon/QNX.
Mike Gorchak <lestat@i.com.ua>
parents: 3193
diff changeset
   918
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   919
    /* Set window dimension */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   920
    winsize.w = window->w;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   921
    winsize.h = window->h;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   922
    PtSetArg(&winargs[winargc++], Pt_ARG_DIM, &winsize, 0);
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   923
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   924
    /* Check if upper level requests WM to position window */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   925
    if ((window->x == SDL_WINDOWPOS_UNDEFINED)
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   926
        && (window->y == SDL_WINDOWPOS_UNDEFINED)) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   927
        /* Do not set widget position, let WM to set it */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   928
    } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   929
        if (window->x == SDL_WINDOWPOS_UNDEFINED) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   930
            window->x = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   931
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   932
        if (window->y == SDL_WINDOWPOS_UNDEFINED) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   933
            window->y = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   934
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   935
        if (window->x == SDL_WINDOWPOS_CENTERED) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   936
            window->x = (didata->current_mode.w - window->w) / 2;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   937
        }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   938
        if (window->y == SDL_WINDOWPOS_CENTERED) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   939
            window->y = (didata->current_mode.h - window->h) / 2;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   940
        }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   941
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   942
        /* Now set window position */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   943
        winpos.x = window->x;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   944
        winpos.y = window->y;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   945
        PtSetArg(&winargs[winargc++], Pt_ARG_POS, &winpos, 0);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   946
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   947
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   948
    /* Check if window must support OpenGL ES rendering */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   949
    if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   950
#if defined(SDL_VIDEO_OPENGL_ES)
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   951
        EGLBoolean initstatus;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   952
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   953
        /* Check if GF was initialized correctly */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   954
        if (phdata->gfinitialized == SDL_FALSE) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   955
            SDL_SetError
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   956
                ("Photon: GF initialization failed, no OpenGL ES support");
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   957
            return -1;
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   958
        }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   959
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   960
        /* Mark this window as OpenGL ES compatible */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   961
        wdata->uses_gles = SDL_TRUE;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   962
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   963
        /* Create connection to OpenGL ES */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   964
        if (phdata->egldisplay == EGL_NO_DISPLAY) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   965
            phdata->egldisplay = eglGetDisplay(phdata->gfdev);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   966
            if (phdata->egldisplay == EGL_NO_DISPLAY) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   967
                SDL_SetError("Photon: Can't get connection to OpenGL ES");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   968
                return -1;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   969
            }
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   970
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   971
            /* Initialize OpenGL ES library, ignore EGL version */
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   972
            initstatus = eglInitialize(phdata->egldisplay, NULL, NULL);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   973
            if (initstatus != EGL_TRUE) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   974
                SDL_SetError("Photon: Can't init OpenGL ES library");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   975
                return -1;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   976
            }
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   977
        }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   978
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   979
        /* Increment GL ES reference count usage */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   980
        phdata->egl_refcount++;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   981
#else
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   982
        SDL_SetError("Photon: OpenGL ES support is not compiled in");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   983
        return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   984
#endif /* SDL_VIDEO_OPENGL_ES */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   985
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
   986
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   987
    /* Finally create the window */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   988
    wdata->window = PtCreateWidget(PtWindow, Pt_NO_PARENT, winargc, winargs);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   989
    if (wdata->window == NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   990
        SDL_SetError("Photon: Can't create window widget");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   991
        SDL_free(wdata);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   992
        return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   993
    }
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
   994
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   995
    /* Show widget */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   996
    status = PtRealizeWidget(wdata->window);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   997
    if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   998
        SDL_SetError("Photon: Can't realize window widget");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
   999
        PtDestroyWidget(wdata->window);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1000
        SDL_free(wdata);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1001
        return;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1002
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
  1003
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1004
    /* Just created SDL window always gets focus */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1005
    window->flags |= SDL_WINDOW_INPUT_FOCUS;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
  1006
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1007
    /* Create window-specific cursor after creation */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1008
    if (didata->cursor_visible == SDL_TRUE) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1009
        /* Setup cursor type. shape and default color */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1010
        PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1011
                      Ph_CURSOR_DEFAULT_COLOR, 0);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1012
        PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1013
        PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR, didata->cursor,
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1014
                      didata->cursor->hdr.len + sizeof(PhRegionDataHdr_t));
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1015
    } else {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1016
        PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1017
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
  1018
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1019
    /* Set window region sensible to mouse motion events */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1020
    status =
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1021
        PhRegionQuery(PtWidgetRid(wdata->window), &wregion, NULL, NULL, 0);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1022
    if (status != 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1023
        SDL_SetError
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1024
            ("Photon: Can't set region sensivity to mouse motion events");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1025
        PtDestroyWidget(wdata->window);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1026
        SDL_free(wdata);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1027
        return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1028
    }
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1029
    wregion.events_sense |=
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1030
        Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1031
    status = PhRegionChange(Ph_REGION_EV_SENSE, 0, &wregion, NULL, NULL);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1032
    if (status < 0) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1033
        SDL_SetError("Photon: Can't change region sensivity");
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1034
        PtDestroyWidget(wdata->window);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1035
        SDL_free(wdata);
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1036
        return -1;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1037
    }
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
  1038
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1039
    /* Flush all widget operations again */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1040
    PtFlush();
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
  1041
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1042
    /* By default last created window got a input focus */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1043
    SDL_SetKeyboardFocus(0, window->id);
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
  1044
3399
f96615051c8c Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
  1045
    /* Emit focus gained event, because photon is not sending it */
f96615051c8c Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
  1046
    SDL_OnWindowFocusGained(window);
f96615051c8c Working on fullscreen video modes support
Mike Gorchak <lestat@i.com.ua>
parents: 3387
diff changeset
  1047
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1048
    /* Window has been successfully created */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1049
    return 0;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
  1050
}
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
  1051
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1052
int
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1053
photon_createwindowfrom(_THIS, SDL_Window * window, const void *data)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
  1054
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1055
    /* TODO: it is possible */
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
  1056
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1057
    /* Failed to create window from another window */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1058
    return -1;
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
  1059
}
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
  1060
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1061
void
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1062
photon_setwindowtitle(_THIS, SDL_Window * window)
3092
cad1aefa2ed9 Date: Thu, 12 Mar 2009 15:14:38 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 3087
diff changeset
  1063
{
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1064
    SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1065
    int32_t status;
3108
aa1897bee1e9 Continue working on QNX Photon with OpenGL ES support
Mike Gorchak <lestat@i.com.ua>
parents: 3092
diff changeset
  1066
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1067
    /* Set window title */
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1068
    if (window->title != NULL) {
Sam Lantinga <slouken@libsdl.org>
parents: 3115
diff changeset
  1069
        status =
Sam Lant