?? sdl_nxvideo.c
字號:
}static void NX_DestroyWindow (_THIS, SDL_Surface * screen){ Dprintf ("enter NX_DestroyWindow\n") ; if (! SDL_windowid) { if (screen && (screen -> flags & SDL_FULLSCREEN)) { screen -> flags &= ~ SDL_FULLSCREEN ; NX_LeaveFullScreen (this) ; } // Destroy the output window if (SDL_Window && SDL_Window != GR_ROOT_WINDOW_ID) { GrDestroyWindow (SDL_Window) ; } } // Free the graphics context if (! SDL_GC) { GrDestroyGC (SDL_GC) ; SDL_GC = 0; } Dprintf ("leave NX_DestroyWindow\n") ;}static int NX_CreateWindow (_THIS, SDL_Surface * screen, int w, int h, int bpp, Uint32 flags){ Dprintf ("enter NX_CreateWindow\n") ; // If a window is already present, destroy it and start fresh if (SDL_Window && SDL_Window != GR_ROOT_WINDOW_ID) { NX_DestroyWindow (this, screen) ; } // See if we have been given a window id if (SDL_windowid) { SDL_Window = strtol (SDL_windowid, NULL, 0) ; } else { SDL_Window = 0 ; } if ( ! SDL_ReallocFormat (screen, bpp, SDL_Visual.red_mask, SDL_Visual.green_mask, SDL_Visual.blue_mask, 0)) return -1; // Create (or use) the nanox display window if (! SDL_windowid) { SDL_Window = GrNewWindow (GR_ROOT_WINDOW_ID, 0, 0, w, h, 0, BLACK, WHITE) ; GrSelectEvents (SDL_Window, (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)) ; } /* Create the graphics context here, once we have a window */ SDL_GC = GrNewGC () ; if (SDL_GC == 0) { SDL_SetError("Couldn't create graphics context"); return(-1); } // Map them both and go fullscreen, if requested if (! SDL_windowid) { GrMapWindow (SDL_Window) ; if (flags & SDL_FULLSCREEN) { screen -> flags |= SDL_FULLSCREEN ; NX_EnterFullScreen (this) ; } else { screen -> flags &= ~ SDL_FULLSCREEN ; } }#ifdef ENABLE_NANOX_DIRECT_FB /* attempt allocating the client side framebuffer */ Clientfb = GrOpenClientFramebuffer(); /* NULL return will default to using GrArea()*/#endif Dprintf ("leave NX_CreateWindow\n") ; return 0 ;}SDL_Surface * NX_SetVideoMode (_THIS, SDL_Surface * current, int width, int height, int bpp, Uint32 flags){ Dprintf ("enter NX_SetVideoMode\n") ; // Lock the event thread, in multi-threading environments SDL_Lock_EventThread () ; bpp = SDL_Visual.bpp ; if (NX_CreateWindow (this, current, width, height, bpp, flags) < 0) { current = NULL; goto done; } if (current -> w != width || current -> h != height) { current -> w = width ; current -> h = height ; current -> pitch = SDL_CalculatePitch (current) ; NX_ResizeImage (this, current, flags) ; } current -> flags |= (flags & (SDL_RESIZABLE | SDL_NOFRAME)) ; done: SDL_Unlock_EventThread () ; Dprintf ("leave NX_SetVideoMode\n") ; // We're done! return current ;}// ncolors <= 256int NX_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors){ int i ; GR_PALETTE pal ; Dprintf ("enter NX_SetColors\n") ; if (ncolors > 256) return 0 ; pal.count = ncolors ; for (i = 0; i < ncolors; ++ i) { pal.palette [i].r = colors [i].r ; pal.palette [i].g = colors [i].g ; pal.palette [i].b = colors [i].b ; } GrSetSystemPalette (firstcolor, & pal) ; Dprintf ("leave NX_SetColors\n") ; return 1 ;}static int NX_ToggleFullScreen (_THIS, int on){ SDL_Rect rect ; Uint32 event_thread ; Dprintf ("enter NX_ToggleFullScreen\n") ; // Don't switch if we don't own the window if (SDL_windowid) return 0 ; // Don't lock if we are the event thread event_thread = SDL_EventThreadID () ; if (event_thread && (SDL_ThreadID () == event_thread)) { event_thread = 0 ; } if (event_thread) { SDL_Lock_EventThread() ; } if (on) { NX_EnterFullScreen (this) ; } else { this -> screen -> flags &= ~ SDL_FULLSCREEN ; NX_LeaveFullScreen (this) ; } rect.x = rect.y = 0 ; rect.w = this -> screen -> w, rect.h = this -> screen -> h ; NX_NormalUpdate (this, 1, & rect) ; if (event_thread) { SDL_Unlock_EventThread () ; } Dprintf ("leave NX_ToggleFullScreen\n") ; return 1 ;}// Update the current mouse state and positionstatic void NX_UpdateMouse (_THIS){ int x, y ; GR_WINDOW_INFO info ; GR_SCREEN_INFO si ; Dprintf ("enter NX_UpdateMouse\n") ; // Lock the event thread, in multi-threading environments SDL_Lock_EventThread () ; GrGetScreenInfo (& si) ; GrGetWindowInfo (SDL_Window, & info) ; x = si.xpos - info.x ; y = si.ypos - info.y ; if (x >= 0 && x <= info.width && y >= 0 && y <= info.height) { SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS) ; SDL_PrivateMouseMotion (0, 0, x, y); } else { SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS) ; } SDL_Unlock_EventThread () ; Dprintf ("leave NX_UpdateMouse\n") ;}static int NX_SetGammaRamp (_THIS, Uint16 * ramp){ int i ; Uint16 * red, * green, * blue ; Dprintf ("enter NX_SetGammaRamp\n") ; if (SDL_Visual.bpp != 32 && SDL_Visual.bpp != 24) return -1 ; if (! GammaRamp_R) GammaRamp_R = (Uint16 *) malloc (sizeof (Uint16) * CI_SIZE) ; if (! GammaRamp_G) GammaRamp_G = (Uint16 *) malloc (sizeof (Uint16) * CI_SIZE) ; if (! GammaRamp_B) GammaRamp_B = (Uint16 *) malloc (sizeof (Uint16) * CI_SIZE) ; if ((! GammaRamp_R) || (! GammaRamp_G) || (! GammaRamp_B)) { SDL_OutOfMemory () ; return -1 ; } for (i = 0; i < CI_SIZE; ++ i) GammaRamp_R [i] = GammaRamp_G [i] = GammaRamp_B [i] = i ; red = ramp ; green = ramp + CI_SIZE ; blue = green + CI_SIZE ; for (i = 0; i < CI_SIZE; ++ i) { GammaRamp_R [i] = red [i] ; GammaRamp_G [i] = green [i] ; GammaRamp_B [i] = blue [i] ; } Dprintf ("leave NX_SetGammaRamp\n") ; return 0 ;}static int NX_GetGammaRamp (_THIS, Uint16 * ramp){ int i ; Uint16 * red, * green, * blue ; Dprintf ("enter NX_GetGammaRamp\n") ; if (SDL_Visual.bpp != 32 && SDL_Visual.bpp != 24) return -1 ; red = ramp ; green = ramp + CI_SIZE ; blue = green + CI_SIZE ; if (GammaRamp_R && GammaRamp_G && GammaRamp_B) { for (i = 0; i < CI_SIZE; ++ i) { red [i] = GammaRamp_R [i] ; green [i] = GammaRamp_G [i] ; blue [i] = GammaRamp_B [i] ; } } else { for (i = 0; i < CI_SIZE; ++ i) red [i] = green [i] = blue [i] = i ; } Dprintf ("leave NX_GetGammaRamp\n") ; return 0 ;}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -