Mike Gorchak added some QNX tweaks, including OpenGL support
authorSam Lantinga <slouken@libsdl.org>
Thu, 14 Feb 2002 02:15:15 +0000
changeset 27904351f59b051
parent 278 dcd9f7b50a1c
child 280 0ddcea45d829
Mike Gorchak added some QNX tweaks, including OpenGL support
BUGS
README.QNX
configure.in
src/video/photon/SDL_ph_video.c
     1.1 --- a/BUGS	Thu Feb 14 01:24:08 2002 +0000
     1.2 +++ b/BUGS	Thu Feb 14 02:15:15 2002 +0000
     1.3 @@ -190,10 +190,6 @@
     1.4  	http://www.kom.e-technik.tu-darmstadt.de/~griff/SDL/
     1.5  
     1.6  QNX:  -= NOT YET SUPPORTED =-
     1.7 -	Configuration doesn't work right, Makefiles still need to be
     1.8 -	tweaked (need to add libraries to any apps that use sdl_config
     1.9 -	to figure out what libs they need).
    1.10 - 
    1.11  	Only static libraries are being made, no shared ones.
    1.12   
    1.13  	The only hardware surface is the primary view surface.
    1.14 @@ -204,9 +200,6 @@
    1.15   
    1.16  	The software surfaces could use some speed up.
    1.17   
    1.18 -	It doesn't look like the OpenGL stuff is there. (did a grep for
    1.19 -	PdCreateOpenGLContext, nothing found).
    1.20 - 
    1.21  	The mouse cursor doesn't look right.
    1.22  
    1.23  AmigaOS:  -= NOT YET SUPPORTED =-
     2.1 --- a/README.QNX	Thu Feb 14 01:24:08 2002 +0000
     2.2 +++ b/README.QNX	Thu Feb 14 02:15:15 2002 +0000
     2.3 @@ -3,17 +3,34 @@
     2.4      Experimentally added OpenGL support in window mode (in fullscreen
     2.5  mode not yet). If you have QNX RtP v6.1.0 w/ or w/o Patch A you  need
     2.6  to download new Photon3D runtime from http://developers.qnx.com.  The
     2.7 -versions of OS before 6.1.0 is not supported. OpenGL support is  very
     2.8 -raw. It is often fail.
     2.9 +versions of OS before 6.1.0 is not supported.
    2.10 +
    2.11 +Problems:
    2.12 +1. OpenGL support is very raw. It is often fail. Update function has
    2.13 +   not been written yet. Fullscreen mode has not been written yet.
    2.14 +2. Photon has some errors in detecting how much bits per pixel has
    2.15 +   videomode, creating images with different color depth.
    2.16 +3. No shared libraries yet. We need manually set flags as
    2.17 +   --disable-shared.
    2.18  
    2.19  Some building issues:
    2.20  
    2.21      Run configure script without x11 support, e.g.:
    2.22  
    2.23 -    ./configure --prefix=/usr/local --disable-video-x11
    2.24 +    a) for OpenGL support:
    2.25 +    ./configure --prefix=/usr/local \
    2.26 +                --disable-video-x11 \
    2.27 +                --disable-shared
    2.28 +
    2.29 +    a) without OpenGL support:
    2.30 +    ./configure --prefix=/usr/local \
    2.31 +                --disable-video-x11 \
    2.32 +                --disable-shared    \
    2.33 +                --disable-video-opengl
    2.34  
    2.35      In test directory also run ./configure script without x11 support, e.g.:
    2.36  
    2.37      ./configure  --with-sdl-prefix=/usr/local      \
    2.38                   --with-sdl-exec-prefix=/usr/local \
    2.39                   --prefix=/usr/local --without-x
    2.40 +
     3.1 --- a/configure.in	Thu Feb 14 01:24:08 2002 +0000
     3.2 +++ b/configure.in	Thu Feb 14 02:15:15 2002 +0000
     3.3 @@ -647,6 +647,7 @@
     3.4          fi
     3.5      fi
     3.6  }
     3.7 +
     3.8  CheckPHOTON()
     3.9  {
    3.10      AC_ARG_ENABLE(video-photon,
    3.11 @@ -671,6 +672,7 @@
    3.12              SYSTEM_LIBS="$SYSTEM_LIBS -lph"
    3.13              VIDEO_SUBDIRS="$VIDEO_SUBDIRS photon"
    3.14              VIDEO_DRIVERS="$VIDEO_DRIVERS photon/libvideo_photon.la"
    3.15 +            CheckOpenGLQNX
    3.16          fi
    3.17      fi
    3.18  }
    3.19 @@ -947,6 +949,26 @@
    3.20      fi
    3.21  }
    3.22  
    3.23 +dnl Find QNX RtP OpenGL
    3.24 +CheckOpenGLQNX()
    3.25 +{
    3.26 +    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
    3.27 +        AC_MSG_CHECKING(for OpenGL (Photon) support)
    3.28 +        video_opengl=no
    3.29 +        AC_TRY_COMPILE([
    3.30 +         #include <GL/gl.h>
    3.31 +        ],[
    3.32 +        ],[
    3.33 +        video_opengl=yes
    3.34 +        ])
    3.35 +        AC_MSG_RESULT($video_opengl)
    3.36 +        if test x$video_opengl = xyes; then
    3.37 +            CFLAGS="$CFLAGS -DHAVE_OPENGL"
    3.38 +            SYSTEM_LIBS="$SYSTEM_LIBS -lGL"
    3.39 +        fi
    3.40 +    fi
    3.41 +}
    3.42 +
    3.43  dnl Check for BeOS OpenGL
    3.44  CheckBeGL()
    3.45  {
    3.46 @@ -2162,6 +2184,7 @@
    3.47  AM_CONDITIONAL(TARGET_BEOS, test $ARCH = beos)
    3.48  AM_CONDITIONAL(TARGET_MACOS, test $ARCH = macos)
    3.49  AM_CONDITIONAL(TARGET_MACOSX, test $ARCH = macosx)
    3.50 +AM_CONDITIONAL(TARGET_QNX, test $ARCH = qnx)
    3.51  
    3.52  # Set conditional variables for shared and static library selection.
    3.53  # These are not used in any Makefile.am but in sdl-config.in.
     4.1 --- a/src/video/photon/SDL_ph_video.c	Thu Feb 14 01:24:08 2002 +0000
     4.2 +++ b/src/video/photon/SDL_ph_video.c	Thu Feb 14 02:15:15 2002 +0000
     4.3 @@ -58,7 +58,9 @@
     4.4  static void ph_DeleteDevice(SDL_VideoDevice *device);
     4.5  static void ph_GL_SwapBuffers(_THIS);
     4.6  
     4.7 +#ifdef HAVE_OPENGL
     4.8  PdOpenGLContext_t* OGLContext=NULL;
     4.9 +#endif /* HAVE_OPENGL */
    4.10  
    4.11  static int ph_Available(void)
    4.12  {
    4.13 @@ -85,7 +87,7 @@
    4.14      memset(device->hidden, 0, (sizeof *device->hidden));
    4.15  
    4.16      /* Set the driver flags */
    4.17 -    device->handles_any_size = 1; //JB not true for fullscreen
    4.18 +    device->handles_any_size = 1; /* JB not true for fullscreen */
    4.19  
    4.20      /* Set the function pointers */
    4.21      device->CreateYUVOverlay = ph_CreateYUVOverlay;
    4.22 @@ -95,7 +97,7 @@
    4.23      device->ToggleFullScreen =  ph_ToggleFullScreen;
    4.24      device->UpdateMouse = NULL;	
    4.25      device->SetColors = ph_SetColors;
    4.26 -    device->UpdateRects =  NULL; //set in ph_ResizeImage
    4.27 +    device->UpdateRects = NULL; /* ph_ResizeImage; */
    4.28      device->VideoQuit = ph_VideoQuit;
    4.29      device->AllocHWSurface = ph_AllocHWSurface;
    4.30      device->CheckHWBlit = NULL;
    4.31 @@ -119,12 +121,16 @@
    4.32      device->InitOSKeymap = ph_InitOSKeymap;
    4.33      device->PumpEvents = ph_PumpEvents;
    4.34  
    4.35 -    // OpenGL support.
    4.36 +    /* OpenGL support. */
    4.37      device->GL_LoadLibrary = NULL;
    4.38      device->GL_GetProcAddress = NULL;
    4.39      device->GL_GetAttribute = NULL;
    4.40      device->GL_MakeCurrent = NULL;
    4.41 +#ifdef HAVE_OPENGL
    4.42      device->GL_SwapBuffers = ph_GL_SwapBuffers;
    4.43 +#else
    4.44 +    device->GL_SwapBuffers = NULL;
    4.45 +#endif /* HAVE_OPENGL */
    4.46  
    4.47      device->free = ph_DeleteDevice;
    4.48  
    4.49 @@ -196,7 +202,6 @@
    4.50    	{
    4.51    		printf("Photon application init failed, probably Photon is not running.\n");
    4.52          	exit( EXIT_FAILURE );
    4.53 -//        PtExit(EXIT_FAILURE);         // Got SEGFAULT.
    4.54    	}
    4.55  
    4.56  	//PgSetDrawBufferSize(16 *1024);
    4.57 @@ -216,29 +221,21 @@
    4.58  
    4.59  	if(SDL_BlankCursor == NULL)
    4.60  	  printf("could not create blank cursor\n");
    4.61 -     /* Get the video mode */
    4.62 -     /*    
    4.63 -         if (PgGetVideoMode( &mysettings ) < 0)
    4.64 -            {
    4.65 -                fprintf(stderr,"ph_VideoInit:  PgGetVideoMode failed patch A?? \n");
    4.66 -      			//QNX6/Patch A always fails return code even though call succeeds. fixed Patch B
    4.67 -            }
    4.68 -       */
    4.69 +
    4.70           if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
    4.71           {
    4.72                  fprintf(stderr,"ph_VideoInit:  GetGraphicsHWCaps failed!! \n");
    4.73 -      			//that HAVE to work
    4.74           }
    4.75           if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &my_mode_info) < 0)
    4.76           {
    4.77                  fprintf(stderr,"ph_VideoInit:  PgGetVideoModeInfo failed\n");
    4.78           }
    4.79  
    4.80 -       //We need to return BytesPerPixel as it in used by CreateRGBsurface
    4.81 -       vformat->BitsPerPixel = my_mode_info.bits_per_pixel;
    4.82 -       vformat->BytesPerPixel = vformat->BitsPerPixel/8;
    4.83 - 
    4.84 -       //return a palette if we are in 256 color mode           
    4.85 +         //We need to return BytesPerPixel as it in used by CreateRGBsurface
    4.86 +         vformat->BitsPerPixel = my_mode_info.bits_per_pixel;
    4.87 +         vformat->BytesPerPixel = my_mode_info.bytes_per_scanline/my_mode_info.width;
    4.88 +         
    4.89 +         //return a palette if we are in 256 color mode           
    4.90  		if(vformat->BitsPerPixel == 8)
    4.91  		{
    4.92  			vformat->palette = malloc(sizeof(SDL_Palette));
    4.93 @@ -251,7 +248,7 @@
    4.94  			if(rtnval < 0)
    4.95  			   printf("ph_VideoInit:  PgGetPalette failed\n");
    4.96  			   
    4.97 -       	tempptr = (unsigned long *)vformat->palette->colors;
    4.98 +                        tempptr = (unsigned long *)vformat->palette->colors;
    4.99  
   4.100  			for(i=0;i<256; i++)
   4.101  			{
   4.102 @@ -273,10 +270,11 @@
   4.103  static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
   4.104                  int width, int height, int bpp, Uint32 flags)
   4.105  {
   4.106 -//    PhRegion_t region_info;
   4.107      PgDisplaySettings_t settings;
   4.108 +/*
   4.109      PgHWCaps_t my_hwcaps;
   4.110      PgVideoModeInfo_t mode_info;
   4.111 +*/
   4.112      int mode, actual_width, actual_height;
   4.113      PtArg_t arg[5];
   4.114      PhDim_t dim;	
   4.115 @@ -284,7 +282,10 @@
   4.116      PgColor_t ph_palette[_Pg_MAX_PALETTE];
   4.117      int i;
   4.118      unsigned long *tempptr;
   4.119 +
   4.120 +#ifdef HAVE_OPENGL
   4.121      uint64_t OGLAttrib[PH_OGL_MAX_ATTRIBS];
   4.122 +#endif // HAVE_OPENGL
   4.123  
   4.124      actual_width = width;
   4.125      actual_height = height;
   4.126 @@ -296,37 +297,9 @@
   4.127      SDL_Lock_EventThread();
   4.128  
   4.129       /* Initialize the window */
   4.130 -    if (flags & SDL_FULLSCREEN) //Direct Context , assume SDL_HWSURFACE also set
   4.131 +    if (flags & SDL_FULLSCREEN) /* Direct Context , assume SDL_HWSURFACE also set */
   4.132      {
   4.133 -/*  
   4.134 -	if (old_video_mode==-1)
   4.135 -	{
   4.136 -		PgGetGraphicsHWCaps(&graphics_card_caps);
   4.137 -		old_video_mode=graphics_card_caps.current_video_mode;
   4.138 -		old_refresh_rate=graphics_card_caps.current_rrate;
   4.139 -	}
   4.140 -*/    	
   4.141 -
   4.142          /* Get the video mode and set it */
   4.143 -        if (bpp == 0)
   4.144 -        {
   4.145 -            /*again same issue, same solution
   4.146 -            if (PgGetVideoMode( &settings ) < 0)
   4.147 -            {
   4.148 -                fprintf(stderr,"error: PgGetVideoMode failed\n");
   4.149 -            }
   4.150 -            */
   4.151 -           if (PgGetGraphicsHWCaps(&my_hwcaps) < 0)
   4.152 -           {
   4.153 -                   fprintf(stderr,"ph_SetVideoMode:  GetGraphicsHWCaps failed!! \n");
   4.154 -      	           //that HAVE to work
   4.155 -           }
   4.156 -           if (PgGetVideoModeInfo(my_hwcaps.current_video_mode, &mode_info) < 0)
   4.157 -           {
   4.158 -               fprintf(stderr,"ph_SetVideoMode:  PgGetVideoModeInfo failed\n");
   4.159 -           }
   4.160 -           bpp = mode_info.bits_per_pixel;
   4.161 -        }
   4.162          if (flags & SDL_ANYFORMAT)
   4.163          {
   4.164              if ((mode = get_mode_any_format(width, height, bpp)) == 0)
   4.165 @@ -356,27 +329,28 @@
   4.166  
   4.167  		/* Get the true height and width */
   4.168  		
   4.169 -      current->flags = (flags|(~SDL_RESIZABLE)); //no resize for Direct Context
   4.170 +      current->flags = (flags|(~SDL_RESIZABLE)); /* no resize for Direct Context */
   4.171  
   4.172  		 /* Begin direct mode */
   4.173  		 ph_EnterFullScreen(this);
   4.174  
   4.175         
   4.176  
   4.177 -    } //end fullscreen flag
   4.178 +    } /* end fullscreen flag */
   4.179      else
   4.180      {
   4.181         if (flags & SDL_HWSURFACE)  /* Use offscreen memory iff SDL_HWSURFACE flag is set */
   4.182         {
   4.183 -         // Hardware surface is Offsceen Context.  ph_ResizeImage handles the switch
   4.184 -         current->flags = (flags|(~SDL_RESIZABLE)); //no stretch blit in offscreen context
   4.185 +         /* Hardware surface is Offsceen Context.  ph_ResizeImage handles the switch */
   4.186 +         current->flags = (flags|(~SDL_RESIZABLE)); /* no stretch blit in offscreen context */
   4.187         }
   4.188 -       else // must be SDL_SWSURFACE
   4.189 +       else /* must be SDL_SWSURFACE */
   4.190         {
   4.191 -          current->flags = (flags|SDL_RESIZABLE); //yes we can resize as this is a software surface
   4.192 +          current->flags = (flags|SDL_RESIZABLE); /* yes we can resize as this is a software surface */
   4.193         }
   4.194 -       
   4.195 -       if (flags & SDL_OPENGL) // for now support OpenGL in window mode only
   4.196 +
   4.197 +#ifdef HAVE_OPENGL       
   4.198 +       if (flags & SDL_OPENGL) /* for now support OpenGL in window mode only */
   4.199         {
   4.200            OGLAttrib[0]=PHOGL_ATTRIB_DEPTH_BITS;
   4.201            OGLAttrib[1]=bpp;
   4.202 @@ -389,17 +363,18 @@
   4.203            }
   4.204            PhDCSetCurrent(OGLContext);
   4.205         }
   4.206 +#endif /* HAVE_OPENGL */
   4.207         
   4.208      }
   4.209  
   4.210 -	//If we are setting video to use the palette make sure we have allocated memory for it
   4.211 +	/* If we are setting video to use the palette make sure we have allocated memory for it */
   4.212  	if(bpp == 8)
   4.213  	{
   4.214  		current->format->palette = malloc(sizeof(SDL_Palette));
   4.215  		memset(current->format->palette, 0, sizeof(SDL_Palette));
   4.216  		current->format->palette->ncolors = 256;
   4.217  		current->format->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color));
   4.218 -		//fill the palette
   4.219 +		/* fill the palette */
   4.220  		rtnval = PgGetPalette(ph_palette);
   4.221  
   4.222                  tempptr = (unsigned long *)current->format->palette->colors;
   4.223 @@ -413,10 +388,10 @@
   4.224  	}
   4.225  
   4.226  
   4.227 -	//Current window dimensions
   4.228 +	/* Current window dimensions */
   4.229  	PtGetResource( window, Pt_ARG_DIM, &dim, 0 );
   4.230 -	
   4.231 -	//If we need to resize the window
   4.232 +
   4.233 +	/* If we need to resize the window */
   4.234  	if((dim.w != width)||(dim.h != height))
   4.235  	{
   4.236  	    dim.w=width;
   4.237 @@ -426,13 +401,12 @@
   4.238              current->w = width;
   4.239              current->h = height;
   4.240              current->format->BitsPerPixel = bpp;
   4.241 -            current->format->BytesPerPixel = bpp/8;
   4.242 +            current->format->BytesPerPixel = (bpp+7)/8;
   4.243              current->pitch = SDL_CalculatePitch(current);
   4.244 -            //Must call at least once it setup image planes 
   4.245 +            /* Must call at least once it setup image planes */
   4.246              ph_ResizeImage(this, current, flags);
   4.247          }
   4.248  
   4.249 -
   4.250      SDL_Unlock_EventThread();
   4.251  
   4.252      /* We're done! */
   4.253 @@ -441,20 +415,18 @@
   4.254  
   4.255  static void ph_VideoQuit(_THIS)
   4.256  {
   4.257 -		
   4.258 -	if(SDL_Image != NULL)
   4.259 -	{
   4.260 -  	    ph_DestroyImage(this, SDL_VideoSurface); 
   4.261 -	}
   4.262 +    if (SDL_Image != NULL)
   4.263 +    {
   4.264 +        ph_DestroyImage(this, SDL_VideoSurface); 
   4.265 +    }
   4.266  
   4.267 -	if (currently_fullscreen)
   4.268 -	{
   4.269 -		PdDirectStop( directContext );
   4.270 -		PdReleaseDirectContext( directContext );
   4.271 -		directContext=0;	
   4.272 -		currently_fullscreen = 0;
   4.273 -	}
   4.274 -	
   4.275 +    if (currently_fullscreen)
   4.276 +    {
   4.277 +        PdDirectStop( directContext );
   4.278 +        PdReleaseDirectContext( directContext );
   4.279 +        directContext=0;	
   4.280 +        currently_fullscreen = 0;
   4.281 +    }
   4.282  }
   4.283  
   4.284  
   4.285 @@ -516,11 +488,13 @@
   4.286  	return alloct_all;
   4.287  }
   4.288  
   4.289 +#ifdef HAVE_OPENGL
   4.290  void ph_GL_SwapBuffers(_THIS)
   4.291  {
   4.292     PgSetRegion(PtWidgetRid(window));
   4.293     PdOpenGLContextSwapBuffers(OGLContext);
   4.294  }
   4.295 +#endif // HAVE_OPENGL
   4.296  
   4.297  /*
   4.298  static int ph_ResizeWindow(_THIS,