static void OGL_swapinterval (void) { doublevsync = 0; if (wglSwapIntervalEXT) { int i1, i2; i1 = (currprefs.gfx_avsync > 0 && isfullscreen() > 0) ? (abs (currprefs.gfx_refreshrate) > 85 ? 2 : 1) : 0; if (currprefs.turbo_emulation) i1 = 0; wglSwapIntervalEXT (i1); i2 = wglGetSwapIntervalEXT (); if (i1 == 2 && i2 < i1) /* did display driver support SwapInterval == 2 ? */ doublevsync = 1; /* nope, we must wait for vblank twice */ } }
void statusline_render(uae_u8 *buf, int bpp, int pitch, int width, int height, uae_u32 *rc, uae_u32 *gc, uae_u32 *bc, uae_u32 *alpha) { uae_u32 white = rc[0xff] | gc[0xff] | bc[0xff] | (alpha ? alpha[0xff] : 0); uae_u32 back = rc[0x00] | gc[0x00] | bc[0x00] | (alpha ? alpha[0xa0] : 0); const TCHAR *text; int y = -1, x = 10, textwidth = 0; int bar_xstart; if (currprefs.gf[WIN32GFX_IsPicassoScreen()].gfx_filter == 0 && !currprefs.gfx_api) return; text = statusline_fetch(); //text = _T("Testing string 123!"); if (!text) return; BitBlt(statusline_hdc, 0, 0, statusline_width, statusline_height, NULL, 0, 0, BLACKNESS); SIZE size; if (GetTextExtentPoint32(statusline_hdc, text, _tcslen(text), &size)) { textwidth = size.cx; if (isfullscreen()) { if (td_pos & TD_RIGHT) { bar_xstart = width - TD_PADX - VISIBLE_LEDS * TD_WIDTH; x = bar_xstart - textwidth - TD_LED_WIDTH; } else { bar_xstart = TD_PADX; x = bar_xstart + textwidth + TD_LED_WIDTH; } } } if (x < 0) x = 0; TextOut(statusline_hdc, x, y, text, _tcslen(text)); for (int y = 0; y < height && y < statusline_height; y++) { uae_u8 *src = (uae_u8*)statusline_bm + y * statusline_width; uae_u32 *dst2 = (uae_u32*)(buf + pitch * y); for (int x = 0; x < width && x < statusline_width; x++) { uae_u8 b = *src++; if (b) { if (b == 2) *dst2 = white; else if (b == 1) *dst2 = back; } dst2++; } } }
void refreshtitle (void) { if (isfullscreen () == 0) setmaintitle (); }
const TCHAR *OGL_init (HWND ahwnd, int w_w, int w_h, int t_w, int t_h, int depth) { int PixelFormat; const char *ext1; static TCHAR errmsg[100] = { 0 }; static int init; ogl_enabled = 0; if (currprefs.gfx_filter != UAE_FILTER_OPENGL) { _tcscpy (errmsg, _T("OPENGL: not enabled")); return errmsg; } w_width = w_w; w_height = w_h; t_width = t_w; t_height = t_h; t_depth = depth; hwnd = ahwnd; total_textures = 2; if (isfullscreen() > 0 && WIN32GFX_GetDepth (TRUE) < 15) { _tcscpy (errmsg, _T("OPENGL: display depth must be at least 15 bit")); return errmsg; } for (;;) { memset (&pfd, 0, sizeof (pfd)); pfd.nSize = sizeof (PIXELFORMATDESCRIPTOR); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_TYPE_RGBA; pfd.cColorBits = depth; pfd.iLayerType = PFD_MAIN_PLANE; openglhdc = GetDC (hwnd); if (!arbMultisampleSupported) { PixelFormat = ChoosePixelFormat (openglhdc, &pfd); // Find A Compatible Pixel Format if (PixelFormat == 0) { // Did We Find A Compatible Format? _tcscpy (errmsg, _T("OPENGL: can't find suitable pixelformat")); return errmsg; } } else { PixelFormat = arbMultisampleFormat; } if (!SetPixelFormat (openglhdc, PixelFormat, &pfd)) { _stprintf (errmsg, _T("OPENGL: can't set pixelformat %x"), PixelFormat); return errmsg; } if (!(hrc = wglCreateContext (openglhdc))) { _tcscpy (errmsg, _T("OPENGL: can't create gl rendering context")); return errmsg; } if (!wglMakeCurrent (openglhdc, hrc)) { _tcscpy (errmsg, _T("OPENGL: can't activate gl rendering context")); return errmsg; } #ifdef FSAA if(!arbMultisampleSupported) { if(InitMultisample(openglhdc, &pfd)) { OGL_free (); _tcscpy (errmsg, "*"); return errmsg; } } #endif break; } glGetIntegerv (GL_MAX_TEXTURE_SIZE, &max_texture_size); required_texture_size = 2 << exact_log2 (t_width > t_height ? t_width : t_height); if (max_texture_size < t_width || max_texture_size < t_height) { _stprintf (errmsg, _T("OPENGL: %d * %d or bigger texture support required\nYour gfx card's maximum texture size is only %d * %d"), required_texture_size, required_texture_size, max_texture_size, max_texture_size); return errmsg; } required_sl_texture_size = 2 << exact_log2 (w_width > w_height ? w_width : w_height); if (currprefs.gfx_filter_scanlines > 0 && (max_texture_size < w_width || max_texture_size < w_height)) { gui_message (_T("OPENGL: %d * %d or bigger texture support required for scanlines (max is only %d * %d)\n") _T("Scanlines disabled."), required_sl_texture_size, required_sl_texture_size, max_texture_size, max_texture_size); changed_prefs.gfx_filter_scanlines = currprefs.gfx_filter_scanlines = 0; } ext1 = glGetString (GL_EXTENSIONS); if (!init) write_log (_T("OpenGL extensions: %s\n"), ext1); if (strstr (ext1, "EXT_packed_pixels")) packed_pixels = 1; if (strstr (ext1, "WGL_EXT_swap_control")) { wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress ("wglSwapIntervalEXT"); wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress ("wglGetSwapIntervalEXT"); if (!wglGetSwapIntervalEXT || !wglSwapIntervalEXT) { write_log (_T("OPENGL: WGL_EXT_swap_control extension found but no wglGetSwapIntervalEXT or wglSwapIntervalEXT found!?\n")); wglSwapIntervalEXT = 0; wglGetSwapIntervalEXT = 0; } } sl_ti2d_internalformat = GL_RGBA4; sl_ti2d_format = GL_RGBA; sl_ti2d_type = GL_UNSIGNED_SHORT_4_4_4_4_EXT; ti2d_type = -1; if (depth == 15 || depth == 16) { if (!packed_pixels) { _stprintf (errmsg, _T("OPENGL: can't use 15/16 bit screen depths because\n") _T("EXT_packed_pixels extension was not found.")); OGL_free (); return errmsg; } ti2d_internalformat = GL_RGB5_A1; ti2d_format = GL_RGBA; ti2d_type = GL_UNSIGNED_SHORT_5_5_5_1_EXT; } if (depth == 32) { ti2d_internalformat = GL_RGBA; ti2d_format = GL_RGBA; ti2d_type = GL_UNSIGNED_BYTE; if (!packed_pixels) { sl_ti2d_internalformat = GL_RGBA; sl_ti2d_format = GL_RGBA; sl_ti2d_type = GL_UNSIGNED_BYTE; } } if (ti2d_type < 0) { _stprintf (errmsg, _T("OPENGL: Only 15, 16 or 32 bit screen depths supported (was %d)"), depth); OGL_free (); return errmsg; } glGenTextures (total_textures, tex); /* "bitplane" texture */ glBindTexture (GL_TEXTURE_2D, tex [0]); glTexImage2D (GL_TEXTURE_2D, 0, ti2d_internalformat, required_texture_size, required_texture_size,0, ti2d_format, ti2d_type, 0); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); glDisable (GL_DEPTH_TEST); glEnable (GL_TEXTURE_2D); glDisable (GL_LIGHTING); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ogl_enabled = 1; OGL_resize (w_width, w_height); OGL_refresh (); init = 1; write_log (_T("OPENGL: using texture depth %d texture size %d * %d scanline texture size %d * %d\n"), depth, required_texture_size, required_texture_size, required_sl_texture_size, required_sl_texture_size); return 0; }
void my_kbd_handler (int keyboard, int scancode, int newstate) { int code = 0; int scancode_new; static int swapperdrive = 0; if (scancode == specialkeycode ()) return; if (scancode == DIK_F11 && currprefs.win32_ctrl_F11_is_quit && ctrlpressed ()) code = AKS_QUIT; scancode_new = scancode; if (!specialpressed () && inputdevice_iskeymapped (keyboard, scancode)) scancode = 0; // GUI must be always available if (scancode_new == DIK_F12 && currprefs.win32_guikey < 0) scancode = scancode_new; if (scancode_new == currprefs.win32_guikey && scancode_new != DIK_F12) scancode = scancode_new; //write_log (L"keyboard = %d scancode = 0x%02x state = %d\n", keyboard, scancode, newstate ); if (newstate == 0 && code == 0) { switch (scancode) { case DIK_SYSRQ: screenshot (specialpressed () ? 1 : 0, 1); break; } } if (newstate && code == 0) { if (scancode == DIK_F12 || scancode == currprefs.win32_guikey) { if (ctrlpressed ()) { code = AKS_TOGGLEDEFAULTSCREEN; } else if (shiftpressed () || specialpressed ()) { if (isfullscreen() <= 0) { disablecapture (); code = AKS_ENTERDEBUGGER; } } else { code = AKS_ENTERGUI; } } switch (scancode) { case DIK_F1: case DIK_F2: case DIK_F3: case DIK_F4: if (specialpressed ()) { if (ctrlpressed ()) { } else { if (shiftpressed ()) code = AKS_EFLOPPY0 + (scancode - DIK_F1); else code = AKS_FLOPPY0 + (scancode - DIK_F1); } } break; case DIK_F5: #if 0 { disk_prevnext (0, -1); return; //crap++; //write_log (L"%d\n", crap); } #endif if (specialpressed ()) { if (shiftpressed ()) code = AKS_STATESAVEDIALOG; else code = AKS_STATERESTOREDIALOG; } break; case DIK_1: case DIK_2: case DIK_3: case DIK_4: case DIK_5: case DIK_6: case DIK_7: case DIK_8: case DIK_9: case DIK_0: if (specialpressed ()) { int num = scancode - DIK_1; if (shiftpressed ()) num += 10; if (ctrlpressed ()) { swapperdrive = num; if (swapperdrive > 3) swapperdrive = 0; } else { int i; for (i = 0; i < 4; i++) { if (!_tcscmp (currprefs.floppyslots[i].df, currprefs.dfxlist[num])) changed_prefs.floppyslots[i].df[0] = 0; } _tcscpy (changed_prefs.floppyslots[swapperdrive].df, currprefs.dfxlist[num]); config_changed = 1; } } break; case DIK_NUMPAD0: case DIK_NUMPAD1: case DIK_NUMPAD2: case DIK_NUMPAD3: case DIK_NUMPAD4: case DIK_NUMPAD5: case DIK_NUMPAD6: case DIK_NUMPAD7: case DIK_NUMPAD8: case DIK_NUMPAD9: case DIK_NUMPADPERIOD: if (specialpressed ()) { int i = 0, v = -1; while (np[i] >= 0) { v = np[i + 1]; if (np[i] == scancode) break; i += 2; } if (v >= 0) code = AKS_STATESAVEQUICK + v * 2 + ((shiftpressed () || ctrlpressed ()) ? 0 : 1); } break; case DIK_PAUSE: if (specialpressed ()) { if (shiftpressed ()) code = AKS_IRQ7; else code = AKS_WARP; } else { code = AKS_PAUSE; } break; case DIK_SCROLL: code = AKS_INHIBITSCREEN; break; case DIK_NUMPADMINUS: if (specialpressed ()) { if (shiftpressed ()) code = AKS_DECREASEREFRESHRATE; else if (ctrlpressed ()) code = AKS_MVOLDOWN; else code = AKS_VOLDOWN; } break; case DIK_NUMPADPLUS: if (specialpressed ()) { if (shiftpressed ()) code = AKS_INCREASEREFRESHRATE; else if (ctrlpressed ()) code = AKS_MVOLUP; else code = AKS_VOLUP; } break; case DIK_NUMPADSTAR: if (specialpressed ()) { if (ctrlpressed ()) code = AKS_MVOLMUTE; else code = AKS_VOLMUTE; } break; case DIK_NUMPADSLASH: if (specialpressed ()) code = AKS_STATEREWIND; break; } } if (code) { inputdevice_add_inputcode (code, 1); return; } scancode = scancode_new; if (!specialpressed () && newstate) { if (scancode == DIK_CAPITAL) { host_capslockstate = host_capslockstate ? 0 : 1; capslockstate = host_capslockstate; } if (scancode == DIK_NUMLOCK) { host_numlockstate = host_numlockstate ? 0 : 1; capslockstate = host_numlockstate; } if (scancode == DIK_SCROLL) { host_scrolllockstate = host_scrolllockstate ? 0 : 1; capslockstate = host_scrolllockstate; } } if (specialpressed ()) return; inputdevice_translatekeycode (keyboard, scancode, newstate); }