view docs/html/video.html @ 1192:54aa9aa32327

To: sdl@libsdl.org From: Christian Walther <cwalther@gmx.ch> Date: Fri, 18 Nov 2005 23:39:02 +0100 Subject: [SDL] Mouse position bugs on Mac OS X The attached patch fixes a few bugs in SDL related to the mouse position in windowed mode on Mac OS X, reproduced using the attached minimal test program - at least here on 10.3.9, with SDL CVS from today. Could anyone test whether the bugs exist and are fixed by the patch on 10.2 and 10.4? 1. When using OpenGL, the vertical mouse positions obtained through events or SDL_GetMouseState() are off by one. 2. When using OpenGL, SDL_WarpMouse() inverts the y coordinate. 3. Clicks on the topmost pixel row of the window are not recognized. 1 and 2 do not occur in non-OpenGL mode, while 3 does. All three only occur in windowed mode, not in fullscreen. The cause for 1 and 3 is that in Cocoa, "the location of the mouse" seems to be defined as "the location of the top left corner of the mouse pointer's hot pixel" (this is not documented, it's just what I found out here), which together with the fact that Cocoa's usual y coordinates start at the bottom and increase upwards means that the y coordinate of the mouse runs from 1 to h, not from 0 to h-1, in a window of height h. If it does work on 10.2 and 10.4 (I'll try to test it as soon as I can, but at the moment all I have at hand is 10.3.9), can this be applied to the CVS? -Christian To: sdl@libsdl.org From: Christian Walther <cwalther@gmx.ch> Date: Mon, 28 Nov 2005 10:41:51 +0100 Subject: [SDL] Re: Mouse position bugs on Mac OS X I wrote: > I'll try to test it as soon as I can, but at the moment all I have at hand is 10.3.9 So, here are the results of my tests (with patched and unpatched frameworks compiled with Xcode 1.5 (gcc 3.3) on 10.3.9): On 10.1.5, my test program doesn't run because of "Undefined symbols: SDL undefined reference to _CGMainDisplayID expected to be defined in Carbon". I guess not supporting 10.1 was a deliberate decision then and that's OK with me. On 10.2.8, 10.3.9, and 10.4.0, the bugs exist as described in my original post and are fixed by my patch. That is, there is no difference between pre/post 10.3 and the patched version works correctly in all combinations of GL/non-GL and windowed/fullscreen. I therefore recommend the patch for inclusion. -Christian
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 28 Nov 2005 13:58:26 +0000
parents 355632dca928
children
line wrap: on
line source

<HTML
><HEAD
><TITLE
>Video</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
"><LINK
REL="HOME"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="SDL Reference"
HREF="reference.html"><LINK
REL="PREVIOUS"
TITLE="SDL_envvars"
HREF="sdlenvvars.html"><LINK
REL="NEXT"
TITLE="SDL_GetVideoSurface"
HREF="sdlgetvideosurface.html"><META
NAME="KEYWORD"
CONTENT="video"><META
NAME="KEYWORD"
CONTENT="function"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="sdlenvvars.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sdlgetvideosurface.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="VIDEO"
></A
>Chapter 6. Video</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
><A
HREF="sdlgetvideosurface.html"
>SDL_GetVideoSurface</A
>&nbsp;--&nbsp;returns a pointer to the current display surface</DT
><DT
><A
HREF="sdlgetvideoinfo.html"
>SDL_GetVideoInfo</A
>&nbsp;--&nbsp;returns a pointer to information about the video hardware</DT
><DT
><A
HREF="sdlvideodrivername.html"
>SDL_VideoDriverName</A
>&nbsp;--&nbsp;Obtain the name of the video driver</DT
><DT
><A
HREF="sdllistmodes.html"
>SDL_ListModes</A
>&nbsp;--&nbsp;Returns a pointer to an array of available screen dimensions for 
the given format and video flags</DT
><DT
><A
HREF="sdlvideomodeok.html"
>SDL_VideoModeOK</A
>&nbsp;--&nbsp;Check to see if a particular video mode is supported.</DT
><DT
><A
HREF="sdlsetvideomode.html"
>SDL_SetVideoMode</A
>&nbsp;--&nbsp;Set up a video mode with the specified width, height and bits-per-pixel.</DT
><DT
><A
HREF="sdlupdaterect.html"
>SDL_UpdateRect</A
>&nbsp;--&nbsp;Makes sure the given area is updated on the given screen.</DT
><DT
><A
HREF="sdlupdaterects.html"
>SDL_UpdateRects</A
>&nbsp;--&nbsp;Makes sure the given list of rectangles is updated on the given screen.</DT
><DT
><A
HREF="sdlflip.html"
>SDL_Flip</A
>&nbsp;--&nbsp;Swaps screen buffers</DT
><DT
><A
HREF="sdlsetcolors.html"
>SDL_SetColors</A
>&nbsp;--&nbsp;Sets a portion of the colormap for the given 8-bit surface.</DT
><DT
><A
HREF="sdlsetpalette.html"
>SDL_SetPalette</A
>&nbsp;--&nbsp;Sets the colors in the palette of an 8-bit surface.</DT
><DT
><A
HREF="sdlsetgamma.html"
>SDL_SetGamma</A
>&nbsp;--&nbsp;Sets the color gamma function for the display</DT
><DT
><A
HREF="sdlgetgammaramp.html"
>SDL_GetGammaRamp</A
>&nbsp;--&nbsp;Gets the color gamma lookup tables for the display</DT
><DT
><A
HREF="sdlsetgammaramp.html"
>SDL_SetGammaRamp</A
>&nbsp;--&nbsp;Sets the color gamma lookup tables for the display</DT
><DT
><A
HREF="sdlmaprgb.html"
>SDL_MapRGB</A
>&nbsp;--&nbsp;Map a RGB color value to a pixel format.</DT
><DT
><A
HREF="sdlmaprgba.html"
>SDL_MapRGBA</A
>&nbsp;--&nbsp;Map a RGBA color value to a pixel format.</DT
><DT
><A
HREF="sdlgetrgb.html"
>SDL_GetRGB</A
>&nbsp;--&nbsp;Get RGB values from a pixel in the specified pixel format.</DT
><DT
><A
HREF="sdlgetrgba.html"
>SDL_GetRGBA</A
>&nbsp;--&nbsp;Get RGBA values from a pixel in the specified pixel format.</DT
><DT
><A
HREF="sdlcreatergbsurface.html"
>SDL_CreateRGBSurface</A
>&nbsp;--&nbsp;Create an empty SDL_Surface</DT
><DT
><A
HREF="sdlcreatergbsurfacefrom.html"
>SDL_CreateRGBSurfaceFrom</A
>&nbsp;--&nbsp;Create an SDL_Surface from pixel data</DT
><DT
><A
HREF="sdlfreesurface.html"
>SDL_FreeSurface</A
>&nbsp;--&nbsp;Frees (deletes) a SDL_Surface</DT
><DT
><A
HREF="sdllocksurface.html"
>SDL_LockSurface</A
>&nbsp;--&nbsp;Lock a surface for directly access.</DT
><DT
><A
HREF="sdlunlocksurface.html"
>SDL_UnlockSurface</A
>&nbsp;--&nbsp;Unlocks a previously locked surface.</DT
><DT
><A
HREF="sdlloadbmp.html"
>SDL_LoadBMP</A
>&nbsp;--&nbsp;Load a Windows BMP file into an SDL_Surface.</DT
><DT
><A
HREF="sdlsavebmp.html"
>SDL_SaveBMP</A
>&nbsp;--&nbsp;Save an SDL_Surface as a Windows BMP file.</DT
><DT
><A
HREF="sdlsetcolorkey.html"
>SDL_SetColorKey</A
>&nbsp;--&nbsp;Sets the color key (transparent pixel) in a blittable surface and
RLE acceleration.</DT
><DT
><A
HREF="sdlsetalpha.html"
>SDL_SetAlpha</A
>&nbsp;--&nbsp;Adjust the alpha properties of a surface</DT
><DT
><A
HREF="sdlsetcliprect.html"
>SDL_SetClipRect</A
>&nbsp;--&nbsp;Sets the clipping rectangle for a surface.</DT
><DT
><A
HREF="sdlgetcliprect.html"
>SDL_GetClipRect</A
>&nbsp;--&nbsp;Gets the clipping rectangle for a surface.</DT
><DT
><A
HREF="sdlconvertsurface.html"
>SDL_ConvertSurface</A
>&nbsp;--&nbsp;Converts a surface to the same format as another surface.</DT
><DT
><A
HREF="sdlblitsurface.html"
>SDL_BlitSurface</A
>&nbsp;--&nbsp;This performs a fast blit from the source surface to the destination surface.</DT
><DT
><A
HREF="sdlfillrect.html"
>SDL_FillRect</A
>&nbsp;--&nbsp;This function performs a fast fill of the given rectangle with some color</DT
><DT
><A
HREF="sdldisplayformat.html"
>SDL_DisplayFormat</A
>&nbsp;--&nbsp;Convert a surface to the display format</DT
><DT
><A
HREF="sdldisplayformatalpha.html"
>SDL_DisplayFormatAlpha</A
>&nbsp;--&nbsp;Convert a surface to the display format</DT
><DT
><A
HREF="sdlwarpmouse.html"
>SDL_WarpMouse</A
>&nbsp;--&nbsp;Set the position of the mouse cursor.</DT
><DT
><A
HREF="sdlcreatecursor.html"
>SDL_CreateCursor</A
>&nbsp;--&nbsp;Creates a new mouse cursor.</DT
><DT
><A
HREF="sdlfreecursor.html"
>SDL_FreeCursor</A
>&nbsp;--&nbsp;Frees a cursor created with SDL_CreateCursor.</DT
><DT
><A
HREF="sdlsetcursor.html"
>SDL_SetCursor</A
>&nbsp;--&nbsp;Set the currently active mouse cursor.</DT
><DT
><A
HREF="sdlgetcursor.html"
>SDL_GetCursor</A
>&nbsp;--&nbsp;Get the currently active mouse cursor.</DT
><DT
><A
HREF="sdlshowcursor.html"
>SDL_ShowCursor</A
>&nbsp;--&nbsp;Toggle whether or not the cursor is shown on the screen.</DT
><DT
><A
HREF="sdlglloadlibrary.html"
>SDL_GL_LoadLibrary</A
>&nbsp;--&nbsp;Specify an OpenGL library</DT
><DT
><A
HREF="sdlglgetprocaddress.html"
>SDL_GL_GetProcAddress</A
>&nbsp;--&nbsp;Get the address of a GL function</DT
><DT
><A
HREF="sdlglgetattribute.html"
>SDL_GL_GetAttribute</A
>&nbsp;--&nbsp;Get the value of a special SDL/OpenGL attribute</DT
><DT
><A
HREF="sdlglsetattribute.html"
>SDL_GL_SetAttribute</A
>&nbsp;--&nbsp;Set a special SDL/OpenGL attribute</DT
><DT
><A
HREF="sdlglswapbuffers.html"
>SDL_GL_SwapBuffers</A
>&nbsp;--&nbsp;Swap OpenGL framebuffers/Update Display</DT
><DT
><A
HREF="sdlcreateyuvoverlay.html"
>SDL_CreateYUVOverlay</A
>&nbsp;--&nbsp;Create a YUV video overlay</DT
><DT
><A
HREF="sdllockyuvoverlay.html"
>SDL_LockYUVOverlay</A
>&nbsp;--&nbsp;Lock an overlay</DT
><DT
><A
HREF="sdlunlockyuvoverlay.html"
>SDL_UnlockYUVOverlay</A
>&nbsp;--&nbsp;Unlock an overlay</DT
><DT
><A
HREF="sdldisplayyuvoverlay.html"
>SDL_DisplayYUVOverlay</A
>&nbsp;--&nbsp;Blit the overlay to the display</DT
><DT
><A
HREF="sdlfreeyuvoverlay.html"
>SDL_FreeYUVOverlay</A
>&nbsp;--&nbsp;Free a YUV video overlay</DT
><DT
><A
HREF="sdlglattr.html"
>SDL_GLattr</A
>&nbsp;--&nbsp;SDL GL Attributes</DT
><DT
><A
HREF="sdlrect.html"
>SDL_Rect</A
>&nbsp;--&nbsp;Defines a rectangular area</DT
><DT
><A
HREF="sdlcolor.html"
>SDL_Color</A
>&nbsp;--&nbsp;Format independent color description</DT
><DT
><A
HREF="sdlpalette.html"
>SDL_Palette</A
>&nbsp;--&nbsp;Color palette for 8-bit pixel formats</DT
><DT
><A
HREF="sdlpixelformat.html"
>SDL_PixelFormat</A
>&nbsp;--&nbsp;Stores surface format information</DT
><DT
><A
HREF="sdlsurface.html"
>SDL_Surface</A
>&nbsp;--&nbsp;Graphical Surface Structure</DT
><DT
><A
HREF="sdlvideoinfo.html"
>SDL_VideoInfo</A
>&nbsp;--&nbsp;Video Target information</DT
><DT
><A
HREF="sdloverlay.html"
>SDL_Overlay</A
>&nbsp;--&nbsp;YUV video overlay</DT
></DL
></DIV
><P
>SDL presents a very simple interface to the display framebuffer.  The
framebuffer is represented as an offscreen surface to which you can write
directly.  If you want the screen to show what you have written, call the <A
HREF="sdlupdaterects.html"
>update</A
> function which will
guarantee that the desired portion of the screen is updated.</P
><P
>Before you call any of the SDL video functions, you must first call
<SPAN
CLASS="TOKEN"
>SDL_Init(SDL_INIT_VIDEO)</SPAN
>, which initializes the video
and events in the SDL library.  Check the return code, which should be
<SPAN
CLASS="RETURNVALUE"
>0</SPAN
>, to see if there were any errors in starting up.</P
><P
>If you use both sound and video in your application, you need to call
<SPAN
CLASS="TOKEN"
>SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO)</SPAN
> before opening the
sound device, otherwise under Win32 DirectX, you won't be able to set
full-screen display modes.</P
><P
>After you have initialized the library, you can start up the video display in a
number of ways.  The easiest way is to pick a common screen resolution and
depth and just initialize the video, checking for errors.  You will probably
get what you want, but SDL may be emulating your requested mode and converting
the display on update.  The best way is to
<A
HREF="sdlgetvideoinfo.html"
>query</A
>, for the best
video mode closest to the desired one, and then
<A
HREF="sdldisplayformat.html"
>convert</A
>
your images to that pixel format.</P
><P
>SDL currently supports any bit depth &gt;= 8 bits per pixel.  8 bpp formats are
considered 8-bit palettized modes, while 12, 15, 16, 24, and 32 bits per pixel
are considered "packed pixel" modes, meaning each pixel contains the RGB color
components packed in the bits of the pixel.</P
><P
>After you have initialized your video mode, you can take the surface that was
returned, and write to it like any other framebuffer, calling the update
routine as you go.</P
><P
>When you have finished your video access and are ready to quit your
application, you should call "<SPAN
CLASS="TOKEN"
>SDL_Quit()</SPAN
>" to shutdown the
video and events.</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sdlenvvars.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sdlgetvideosurface.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SDL_envvars</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="reference.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SDL_GetVideoSurface</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>