⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdl_nxvideo.c

📁 网络MPEG4IP流媒体开发源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*    SDL - Simple DirectMedia Layer    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga    Copyright (C) 2001  Hsieh-Fu Tsai    Copyright (C) 2002  Greg Haerr <greg@censoft.com>    This library is free software; you can redistribute it and/or    modify it under the terms of the GNU Library General Public    License as published by the Free Software Foundation; either    version 2 of the License, or (at your option) any later version.    This library is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    Library General Public License for more details.    You should have received a copy of the GNU Library General Public    License along with this library; if not, write to the Free    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA    Sam Lantinga    slouken@libsdl.org        Hsieh-Fu Tsai    clare@setabox.com*/#include <stdlib.h>#include "SDL_video.h"#include "SDL_pixels_c.h"#include "SDL_events_c.h"#include "SDL_thread.h"#define MWINCLUDECOLORS#include "SDL_nxvideo.h"#include "SDL_nxmodes_c.h"#include "SDL_nxwm_c.h"#include "SDL_nxmouse_c.h"#include "SDL_nximage_c.h"#include "SDL_nxevents_c.h"// Initialization/Query functionsstatic int NX_VideoInit (_THIS, SDL_PixelFormat * vformat) ;static SDL_Surface * NX_SetVideoMode (_THIS, SDL_Surface * current, int width, int height, int bpp, Uint32 flags) ;static int NX_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) ;static void NX_VideoQuit (_THIS) ;static void NX_DestroyWindow (_THIS, SDL_Surface * screen) ;static int NX_ToggleFullScreen (_THIS, int on) ;static void NX_UpdateMouse (_THIS) ;static int NX_SetGammaRamp (_THIS, Uint16 * ramp) ;static int NX_GetGammaRamp (_THIS, Uint16 * ramp) ;// Microwin driver bootstrap functionsstatic int NX_Available (){    Dprintf ("enter NX_Available\n") ;    if (GrOpen () < 0) return 0 ;        GrClose () ;        Dprintf ("leave NX_Available\n") ;    return 1 ;}static void NX_DeleteDevice (SDL_VideoDevice * device){    Dprintf ("enter NX_DeleteDevice\n") ;    if (device) {        if (device -> hidden) free (device -> hidden) ;        if (device -> gl_data) free (device -> gl_data) ;            free (device) ;    }    Dprintf ("leave NX_DeleteDevice\n") ;}    static SDL_VideoDevice * NX_CreateDevice (int devindex){    SDL_VideoDevice * device ;    Dprintf ("enter NX_CreateDevice\n") ;    // Initialize all variables that we clean on shutdown    device = (SDL_VideoDevice *) malloc (sizeof (SDL_VideoDevice)) ;    if (device) {        memset (device, 0, (sizeof * device)) ;        device -> hidden = (struct SDL_PrivateVideoData *)                malloc ((sizeof * device -> hidden)) ;        device -> gl_data = NULL ;    }    if ((device == NULL) || (device -> hidden == NULL)) {        SDL_OutOfMemory () ;        NX_DeleteDevice (device) ;        return 0 ;    }    memset (device -> hidden, 0, (sizeof * device -> hidden)) ;    // Set the function pointers    device -> VideoInit = NX_VideoInit ;    device -> ListModes = NX_ListModes ;    device -> SetVideoMode = NX_SetVideoMode ;    device -> ToggleFullScreen = NX_ToggleFullScreen ;    device -> UpdateMouse = NX_UpdateMouse ;    device -> CreateYUVOverlay = NULL ;    device -> SetColors = NX_SetColors ;    device -> UpdateRects = NULL ;    device -> VideoQuit = NX_VideoQuit;    device -> AllocHWSurface = NULL ;    device -> CheckHWBlit = NULL ;    device -> FillHWRect = NULL ;    device -> SetHWColorKey = NULL ;    device -> SetHWAlpha = NULL ;    device -> LockHWSurface = NULL ;    device -> UnlockHWSurface = NULL ;    device -> FlipHWSurface = NULL ;    device -> FreeHWSurface = NULL ;    device -> SetGamma = NULL ;    device -> GetGamma = NULL ;    device -> SetGammaRamp = NX_SetGammaRamp ;    device -> GetGammaRamp = NX_GetGammaRamp ;#ifdef HAVE_OPENGL    device -> GL_LoadLibrary = NULL ;    device -> GL_GetProcAddress = NULL ;    device -> GL_GetAttribute = NULL ;    device -> GL_MakeCurrent = NULL ;    device -> GL_SwapBuffers = NULL ;#endif    device -> SetIcon = NULL ;    device -> SetCaption = NX_SetCaption;    device -> IconifyWindow = NULL ;    device -> GrabInput = NULL ;    device -> GetWMInfo = NX_GetWMInfo ;    device -> FreeWMCursor =  NX_FreeWMCursor ;    device -> CreateWMCursor = NX_CreateWMCursor ;    device -> ShowWMCursor = NX_ShowWMCursor ;    device -> WarpWMCursor = NX_WarpWMCursor ;    device -> CheckMouseMode = NULL ;    device -> InitOSKeymap = NX_InitOSKeymap ;    device -> PumpEvents = NX_PumpEvents ;    device -> free = NX_DeleteDevice ;    Dprintf ("leave NX_CreateDevice\n") ;    return device ;}VideoBootStrap NX_bootstrap = {    "nanox", "nanox", NX_Available, NX_CreateDevice} ;static void create_aux_windows (_THIS){    GR_WM_PROPERTIES props ;    Dprintf ("enter create_aux_windows\n") ;    // Don't create any extra windows if we are being managed    if (SDL_windowid) {        FSwindow = 0 ;        return ;    }        if (FSwindow && FSwindow != GR_ROOT_WINDOW_ID) {        GrDestroyWindow (FSwindow) ;    }        FSwindow = GrNewWindow (GR_ROOT_WINDOW_ID, 0, 0, 1, 1, 0, BLACK, BLACK) ;    props.flags = GR_WM_FLAGS_PROPS ;    props.props = GR_WM_PROPS_NODECORATE ;    GrSetWMProperties (FSwindow, & props) ;    GrSelectEvents (FSwindow, (GR_EVENT_MASK_EXPOSURE         |        GR_EVENT_MASK_BUTTON_DOWN  | GR_EVENT_MASK_BUTTON_UP  |        GR_EVENT_MASK_FOCUS_IN     | GR_EVENT_MASK_FOCUS_OUT  |        GR_EVENT_MASK_KEY_DOWN     | GR_EVENT_MASK_KEY_UP     |        GR_EVENT_MASK_MOUSE_ENTER  | GR_EVENT_MASK_MOUSE_EXIT |        GR_EVENT_MASK_MOUSE_MOTION | GR_EVENT_MASK_UPDATE     |        GR_EVENT_MASK_CLOSE_REQ)) ;    Dprintf ("leave create_aux_windows\n") ;}int NX_VideoInit (_THIS, SDL_PixelFormat * vformat){    GR_SCREEN_INFO si ;    Dprintf ("enter NX_VideoInit\n") ;        if (GrOpen () < 0) {        SDL_SetError ("GrOpen() fail") ;        return -1 ;    }    // use share memory to speed up#ifdef NANOX_SHARE_MEMORY    GrReqShmCmds (0xFFFF);#endif    SDL_Window = 0 ;    FSwindow = 0 ;    GammaRamp_R = NULL ;    GammaRamp_G = NULL ;    GammaRamp_B = NULL ;        GrGetScreenInfo (& si) ;    SDL_Visual.bpp = si.bpp ;    // GetVideoMode    SDL_modelist = (SDL_Rect **) malloc (sizeof (SDL_Rect *) * 2) ;    if (SDL_modelist) {        SDL_modelist [0] = (SDL_Rect *) malloc (sizeof(SDL_Rect)) ;        if (SDL_modelist [0]) {            SDL_modelist [0] -> x = 0 ;            SDL_modelist [0] -> y = 0 ;            SDL_modelist [0] -> w = si.cols ;            SDL_modelist [0] -> h = si.rows ;        }        SDL_modelist [1] = NULL ;    }    pixel_type = si.pixtype;    SDL_Visual.red_mask = si.rmask;    SDL_Visual.green_mask = si.gmask;    SDL_Visual.blue_mask = si.bmask;    vformat -> BitsPerPixel = SDL_Visual.bpp ;    if (vformat -> BitsPerPixel > 8) {        vformat -> Rmask = SDL_Visual.red_mask ;        vformat -> Gmask = SDL_Visual.green_mask ;        vformat -> Bmask = SDL_Visual.blue_mask ;    }    // See if we have been passed a window to use    SDL_windowid = getenv ("SDL_WINDOWID") ;        // Create the fullscreen (and managed windows : no implement)    create_aux_windows (this) ;    Dprintf ("leave NX_VideoInit\n") ;    return 0 ;}void NX_VideoQuit (_THIS){    Dprintf ("enter NX_VideoQuit\n") ;    // Start shutting down the windows    NX_DestroyImage (this, this -> screen) ;    NX_DestroyWindow (this, this -> screen) ;    if (FSwindow && FSwindow != GR_ROOT_WINDOW_ID) {        GrDestroyWindow (FSwindow) ;    }    NX_FreeVideoModes (this) ;    free (GammaRamp_R) ;    free (GammaRamp_G) ;    free (GammaRamp_B) ;#ifdef ENABLE_NANOX_DIRECT_FB    if (Clientfb)        GrCloseClientFramebuffer();#endif    GrClose () ;    Dprintf ("leave NX_VideoQuit\n") ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -