int main(int argc, char *argv[]) { int fsaa, accel; int value; int i, done; SDL_DisplayMode mode; SDL_Event event; Uint32 then, now, frames; int status; /* Initialize parameters */ fsaa = 0; accel = 0; /* Initialize test framework */ state = CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { return 1; } for (i = 1; i < argc;) { int consumed; consumed = CommonArg(state, i); if (consumed == 0) { if (SDL_strcasecmp(argv[i], "--fsaa") == 0) { ++fsaa; consumed = 1; } else if (SDL_strcasecmp(argv[i], "--accel") == 0) { ++accel; consumed = 1; } else { consumed = -1; } } if (consumed < 0) { fprintf(stderr, "Usage: %s %s [--fsaa] [--accel]\n", argv[0], CommonUsage(state)); quit(1); } i += consumed; } /* Set OpenGL parameters */ state->window_flags |= SDL_WINDOW_OPENGL; SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); if (fsaa) { SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, fsaa); } if (accel) { SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); } if (!CommonInit(state)) { quit(2); } context=SDL_calloc(state->num_windows, sizeof(SDL_GLContext)); if (context==NULL) { fprintf(stderr, "Out of memory!\n"); quit(2); } /* Create OpenGL ES contexts */ for (i=0; i<state->num_windows; i++) { context[i] = SDL_GL_CreateContext(state->windows[i]); if (!context[i]) { fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); quit(2); } } if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) { SDL_GL_SetSwapInterval(1); } else { SDL_GL_SetSwapInterval(0); } SDL_GetCurrentDisplayMode(&mode); printf("Screen BPP: %d\n", SDL_BITSPERPIXEL(mode.format)); printf("\n"); printf("Vendor : %s\n", glGetString(GL_VENDOR)); printf("Renderer : %s\n", glGetString(GL_RENDERER)); printf("Version : %s\n", glGetString(GL_VERSION)); printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); printf("\n"); status=SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); if (!status) { printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); } else { fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); } status=SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); if (!status) { printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); } else { fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); } status=SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); if (!status) { printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); } else { fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); } status=SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); if (!status) { printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", 16, value); } else { fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); } if (fsaa) { status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); if (!status) { printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); } else { fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError()); } status=SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); if (!status) { printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value); } else { fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError()); } } if (accel) { status=SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); if (!status) { printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); } else { fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError()); } } /* Set rendering settings for each context */ for (i = 0; i < state->num_windows; ++i) { status=SDL_GL_MakeCurrent(state->windows[i], context[i]); if (status) { printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); /* Continue for next window */ continue; } glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glShadeModel(GL_SMOOTH); } /* Main render loop */ frames = 0; then = SDL_GetTicks(); done = 0; while (!done) { /* Check for events */ ++frames; while (SDL_PollEvent(&event)) { CommonEvent(state, &event, &done); } for (i = 0; i < state->num_windows; ++i) { int w, h; status=SDL_GL_MakeCurrent(state->windows[i], context[i]); if (status) { printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); /* Continue for next window */ continue; } SDL_GetWindowSize(state->windows[i], &w, &h); glViewport(0, 0, w, h); Render(); SDL_GL_SwapWindow(state->windows[i]); } } /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { printf("%2.2f frames per second\n", ((double) frames * 1000) / (now - then)); } quit(0); return 0; }
/** * It creates a Direct3D vout display. */ static int Open(vlc_object_t *object) { vout_display_t *vd = (vout_display_t *)object; vout_display_sys_t *sys; /* Allocate structure */ vd->sys = sys = calloc(1, sizeof(vout_display_sys_t)); if (!sys) return VLC_ENOMEM; if (Direct3DCreate(vd)) { msg_Err(vd, "Direct3D could not be initialized"); Direct3DDestroy(vd); free(sys); return VLC_EGENERIC; } sys->use_desktop = var_CreateGetBool(vd, "video-wallpaper"); sys->reset_device = false; sys->reset_device = false; sys->allow_hw_yuv = var_CreateGetBool(vd, "directx-hw-yuv"); sys->desktop_save.is_fullscreen = vd->cfg->is_fullscreen; sys->desktop_save.is_on_top = false; sys->desktop_save.win.left = var_InheritInteger(vd, "video-x"); sys->desktop_save.win.right = vd->cfg->display.width; sys->desktop_save.win.top = var_InheritInteger(vd, "video-y"); sys->desktop_save.win.bottom = vd->cfg->display.height; if (CommonInit(vd)) goto error; /* */ video_format_t fmt; if (Direct3DOpen(vd, &fmt)) { msg_Err(vd, "Direct3D could not be opened"); goto error; } /* */ vout_display_info_t info = vd->info; info.is_slow = true; info.has_double_click = true; info.has_hide_mouse = false; info.has_pictures_invalid = true; info.has_event_thread = true; if (var_InheritBool(vd, "direct3d-hw-blending") && sys->d3dregion_format != D3DFMT_UNKNOWN && (sys->d3dcaps.SrcBlendCaps & D3DPBLENDCAPS_SRCALPHA) && (sys->d3dcaps.DestBlendCaps & D3DPBLENDCAPS_INVSRCALPHA) && (sys->d3dcaps.TextureCaps & D3DPTEXTURECAPS_ALPHA) && (sys->d3dcaps.TextureOpCaps & D3DTEXOPCAPS_SELECTARG1) && (sys->d3dcaps.TextureOpCaps & D3DTEXOPCAPS_MODULATE)) info.subpicture_chromas = d3d_subpicture_chromas; else info.subpicture_chromas = NULL; /* Interaction */ vlc_mutex_init(&sys->lock); sys->ch_desktop = false; sys->desktop_requested = sys->use_desktop; vlc_value_t val; val.psz_string = _("Desktop"); var_Change(vd, "video-wallpaper", VLC_VAR_SETTEXT, &val, NULL); var_AddCallback(vd, "video-wallpaper", DesktopCallback, NULL); /* Setup vout_display now that everything is fine */ vd->fmt = fmt; vd->info = info; vd->pool = Pool; vd->prepare = Prepare; vd->display = Display; vd->control = Control; vd->manage = Manage; /* Fix state in case of desktop mode */ if (sys->use_desktop && vd->cfg->is_fullscreen) vout_display_SendEventFullscreen(vd, false); return VLC_SUCCESS; error: Direct3DClose(vd); CommonClean(vd); Direct3DDestroy(vd); free(vd->sys); return VLC_EGENERIC; }
idFieldWindow::idFieldWindow( idUserInterfaceLocal *g ) : idWindow( g ) { gui = g; CommonInit(); }
ImageDrawingArea::ImageDrawingArea() { CommonInit(); }
CBCGPropertySheet::CBCGPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) :CPropertySheet(pszCaption, pParentWnd, iSelectPage), m_Impl (*this) { CommonInit (); }
static int Open(vlc_object_t *object) { vout_display_t *vd = (vout_display_t *)object; vout_display_sys_t *sys; vd->sys = sys = calloc(1, sizeof(*sys)); if (!sys) return VLC_ENOMEM; #ifdef MODULE_NAME_IS_wingapi /* Load GAPI */ sys->gapi_dll = LoadLibrary(_T("GX.DLL")); if (!sys->gapi_dll) { msg_Warn(vd, "failed loading gx.dll"); free(sys); return VLC_EGENERIC; } GXOpenDisplay = (void *)GetProcAddress(sys->gapi_dll, _T("?GXOpenDisplay@@YAHPAUHWND__@@K@Z")); GXCloseDisplay = (void *)GetProcAddress(sys->gapi_dll, _T("?GXCloseDisplay@@YAHXZ")); GXBeginDraw = (void *)GetProcAddress(sys->gapi_dll, _T("?GXBeginDraw@@YAPAXXZ")); GXEndDraw = (void *)GetProcAddress(sys->gapi_dll, _T("?GXEndDraw@@YAHXZ")); GXGetDisplayProperties = (void *)GetProcAddress(sys->gapi_dll, _T("?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ")); GXSuspend = (void *)GetProcAddress(sys->gapi_dll, _T("?GXSuspend@@YAHXZ")); GXResume = GetProcAddress(sys->gapi_dll, _T("?GXResume@@YAHXZ")); if (!GXOpenDisplay || !GXCloseDisplay || !GXBeginDraw || !GXEndDraw || !GXGetDisplayProperties || !GXSuspend || !GXResume) { msg_Err(vd, "failed GetProcAddress on gapi.dll"); free(sys); return VLC_EGENERIC; } msg_Dbg(vd, "GAPI DLL loaded"); #endif if (CommonInit(vd)) goto error; /* */ video_format_t fmt = vd->fmt; if (Init(vd, &fmt, fmt.i_width, fmt.i_height)) goto error; vout_display_info_t info = vd->info; info.is_slow = false; info.has_double_click = true; info.has_hide_mouse = false; info.has_pictures_invalid = true; /* */ vd->fmt = fmt; vd->info = info; vd->pool = Pool; vd->prepare = NULL; vd->display = Display; vd->manage = Manage; vd->control = Control; return VLC_SUCCESS; error: Close(VLC_OBJECT(vd)); return VLC_EGENERIC; }
HRESULT CTestClientLogic::TestBehaviorAndFiltering(bool fBehaviorTest, NatBehavior behavior, bool fFilteringTest, NatFiltering filtering) { HRESULT hr = S_OK; StunClientLogicConfig config; HRESULT hrRet; uint32_t time = 0; CRefCountedBuffer spMsgOut(new CBuffer(MAX_STUN_MESSAGE_SIZE)); CRefCountedBuffer spMsgResponse(new CBuffer(MAX_STUN_MESSAGE_SIZE)); SocketRole outputRole; CSocketAddress addrDummy; StunMessageIn stunmsgIn; StunMessageOut stunmsgOut; CSocketAddress addrDest; CSocketAddress addrMapped; CSocketAddress addrServerResponse; // what address the fake server responded back on StunClientResults results; StunTransactionId transid= {}; //std::string strAddr; ChkA(CommonInit(behavior, filtering)); config.addrServer = _addrServerPP; config.fBehaviorTest = fBehaviorTest; config.fFilteringTest = fFilteringTest; config.timeoutSeconds = 5; config.uMaxAttempts = 10; ChkA(_spClientLogic->Initialize(config)); while (true) { CStunMessageReader reader; bool fDropMessage = false; time += 1000; hrRet = _spClientLogic->GetNextMessage(spMsgOut, &addrDest, time); if (hrRet == E_STUNCLIENT_STILL_WAITING) { //printf("GetNextMessage returned 'still waiting'\n"); continue; } if (hrRet == E_STUNCLIENT_RESULTS_READY) { //printf("GetNextMessage returned 'results ready'\n"); break; } //addrDest.ToString(&strAddr); //printf("Client is sending stun packet to %s\n", strAddr.c_str()); ChkA(GetMappedAddressForDestinationAddress(addrDest, &addrMapped)); //addrMapped.ToString(&strAddr); //printf("Server is receiving stun packet from %s\n", strAddr.c_str()); ChkA(ValidateBindingRequest(spMsgOut, &transid)); // -------------------------------------------------- reader.AddBytes(spMsgOut->GetData(), spMsgOut->GetSize()); ChkIfA(reader.GetState() != CStunMessageReader::BodyValidated, E_UNEXPECTED); // Simulate sending the binding request and getting a response back stunmsgIn.socketrole = GetSocketRoleForDestinationAddress(addrDest); stunmsgIn.addrLocal = addrDest; stunmsgIn.addrRemote = addrMapped; stunmsgIn.fConnectionOriented = false; stunmsgIn.pReader = &reader; stunmsgOut.socketrole = (SocketRole)-1; // intentionally setting it wrong stunmsgOut.addrDest = addrDummy; // we don't care what address the server sent back to stunmsgOut.spBufferOut = spMsgResponse; spMsgResponse->SetSize(0); ChkA(::CStunRequestHandler::ProcessRequest(stunmsgIn, stunmsgOut, &_tsa, NULL)); // simulate the message coming back // make sure we got something! outputRole = stunmsgOut.socketrole; ChkIfA(::IsValidSocketRole(outputRole)==false, E_FAIL); ChkIfA(spMsgResponse->GetSize() == 0, E_FAIL); addrServerResponse = _tsa.set[stunmsgOut.socketrole].addr; // -------------------------------------------------- //addrServerResponse.ToString(&strAddr); //printf("Server is sending back from %s\n", strAddr.c_str()); // if the request went to PP, but came back from AA or AP, then it's likely a filtering test // decide if we need to drop the response fDropMessage = ( addrDest.IsSameIP_and_Port(_addrServerPP) && ( ((outputRole == RoleAA) && (_fAllowChangeRequestAA==false)) || ((outputRole == RolePA) && (_fAllowChangeRequestPA==false)) ) ); //{ // CStunMessageReader::ReaderParseState state; // CStunMessageReader readerDebug; // state = readerDebug.AddBytes(spMsgResponse->GetData(), spMsgResponse->GetSize()); // if (state != CStunMessageReader::BodyValidated) // { // printf("Error - response from server doesn't look valid"); // } // else // { // CSocketAddress addr; // readerDebug.GetMappedAddress(&addr); // addr.ToString(&strAddr); // printf("Response from server indicates our mapped address is %s\n", strAddr.c_str()); // } //} if (fDropMessage == false) { ChkA(_spClientLogic->ProcessResponse(spMsgResponse, addrServerResponse, _addrLocal)); } } // now validate the results results.Init(); // zero it out _spClientLogic->GetResults(&results); ChkIfA(results.behavior != behavior, E_UNEXPECTED); Cleanup: return hr; }
int main(int argc, char *argv[]) { int i, done; SDL_Event event; Uint32 then, now, frames; /* Initialize parameters */ num_sprites = NUM_SPRITES; /* Initialize test framework */ state = CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { return 1; } for (i = 1; i < argc;) { int consumed; consumed = CommonArg(state, i); if (consumed == 0) { consumed = -1; if (SDL_strcasecmp(argv[i], "--blend") == 0) { if (argv[i + 1]) { if (SDL_strcasecmp(argv[i + 1], "none") == 0) { blendMode = SDL_BLENDMODE_NONE; consumed = 2; } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) { blendMode = SDL_BLENDMODE_MASK; consumed = 2; } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) { blendMode = SDL_BLENDMODE_BLEND; consumed = 2; } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) { blendMode = SDL_BLENDMODE_ADD; consumed = 2; } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) { blendMode = SDL_BLENDMODE_MOD; consumed = 2; } } } else if (SDL_strcasecmp(argv[i], "--scale") == 0) { if (argv[i + 1]) { if (SDL_strcasecmp(argv[i + 1], "none") == 0) { scaleMode = SDL_TEXTURESCALEMODE_NONE; consumed = 2; } else if (SDL_strcasecmp(argv[i + 1], "fast") == 0) { scaleMode = SDL_TEXTURESCALEMODE_FAST; consumed = 2; } else if (SDL_strcasecmp(argv[i + 1], "slow") == 0) { scaleMode = SDL_TEXTURESCALEMODE_SLOW; consumed = 2; } else if (SDL_strcasecmp(argv[i + 1], "best") == 0) { scaleMode = SDL_TEXTURESCALEMODE_BEST; consumed = 2; } } } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) { cycle_color = SDL_TRUE; consumed = 1; } else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) { cycle_alpha = SDL_TRUE; consumed = 1; } else if (SDL_isdigit(*argv[i])) { num_sprites = SDL_atoi(argv[i]); consumed = 1; } } if (consumed < 0) { fprintf(stderr, "Usage: %s %s [--blend none|mask|blend|add|mod] [--scale none|fast|slow|best] [--cyclecolor] [--cyclealpha]\n", argv[0], CommonUsage(state)); quit(1); } i += consumed; } if (!CommonInit(state)) { quit(2); } /* Create the windows, initialize the renderers, and load the textures */ sprites = (SDL_TextureID *) SDL_malloc(state->num_windows * sizeof(*sprites)); if (!sprites) { fprintf(stderr, "Out of memory!\n"); quit(2); } for (i = 0; i < state->num_windows; ++i) { SDL_SelectRenderer(state->windows[i]); SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderRect(NULL); } if (LoadSprite("icon.bmp") < 0) { quit(2); } /* Allocate memory for the sprite info */ positions = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect)); velocities = (SDL_Rect *) SDL_malloc(num_sprites * sizeof(SDL_Rect)); if (!positions || !velocities) { fprintf(stderr, "Out of memory!\n"); quit(2); } srand(time(NULL)); if (scaleMode != SDL_TEXTURESCALEMODE_NONE) { sprite_w += sprite_w / 2; sprite_h += sprite_h / 2; } for (i = 0; i < num_sprites; ++i) { positions[i].x = rand() % (state->window_w - sprite_w); positions[i].y = rand() % (state->window_h - sprite_h); positions[i].w = sprite_w; positions[i].h = sprite_h; velocities[i].x = 0; velocities[i].y = 0; while (!velocities[i].x && !velocities[i].y) { velocities[i].x = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED; velocities[i].y = (rand() % (MAX_SPEED * 2 + 1)) - MAX_SPEED; } } /* Main render loop */ frames = 0; then = SDL_GetTicks(); done = 0; while (!done) { /* Check for events */ ++frames; while (SDL_PollEvent(&event)) { CommonEvent(state, &event, &done); switch (event.type) { case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_EXPOSED: SDL_SelectRenderer(event.window.windowID); SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF); SDL_RenderRect(NULL); break; } break; default: break; } } for (i = 0; i < state->num_windows; ++i) { MoveSprites(state->windows[i], sprites[i]); } } /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { double fps = ((double) frames * 1000) / (now - then); printf("%2.2f frames per second\n", fps); } quit(0); }
// ---------------------------------------------------------------------------- void vHavokChainConstraintChainRenderer::OnVariableValueChanged( VisVariable_cl *pVar, const char * value) { CommonInit(); }
CBCGPControlRendererParams::CBCGPControlRendererParams (const CBCGPControlRendererParams& rSrc) { CommonInit (); (*this) = rSrc; }
CBCGPControlRendererParams::CBCGPControlRendererParams () { CommonInit (); }
wxRibbonButtonBar::wxRibbonButtonBar() { m_layouts_valid = false; CommonInit (0); }
/** * Initialises Direct2D vout module */ static int Open(vlc_object_t *object) { vout_display_t *vd = (vout_display_t *)object; vout_display_sys_t *sys; vd->sys = sys = (vout_display_sys_t *)calloc(1, sizeof(*sys)); // sunqueen modify if (!sys) return VLC_ENOMEM; sys->d2_render_target = NULL; sys->d2_dll = LoadLibrary(TEXT("D2D1.DLL")); if (!sys->d2_dll) { if (object->b_force) msg_Err(vd, "Cannot load D2D1.DLL, aborting"); goto error; } D2D1_FACTORY_OPTIONS fo = { D2D1_DEBUG_LEVEL_NONE }; HRESULT (WINAPI *D2D1CreateFactory)(D2D1_FACTORY_TYPE, REFIID, const D2D1_FACTORY_OPTIONS *, void **); D2D1CreateFactory = (HRESULT (__stdcall *)(D2D1_FACTORY_TYPE,const IID &,const D2D1_FACTORY_OPTIONS *,void **))GetProcAddress(sys->d2_dll, // sunqueen modify "D2D1CreateFactory"); if (!D2D1CreateFactory) { msg_Err(vd, "Cannot locate reference to a D2D1CreateFactory ABI in D2D1.DLL"); goto error; } #ifndef NDEBUG msg_Dbg(vd, "D2D1.DLL loaded"); #endif HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, (REFIID)IID_ID2D1Factory, // sunqueen modify &fo, (void **)&sys->d2_factory); if (hr != S_OK) { msg_Err(vd, "Cannot create Direct2D factory (hr = 0x%x)!", (unsigned)hr); goto error; } if (CommonInit(vd)) goto error; if (D2D_CreateRenderTarget(vd) != VLC_SUCCESS) goto error; vout_display_info_t info = vd->info; info.is_slow = false; info.has_double_click = true; info.has_hide_mouse = false; info.has_pictures_invalid = false; vd->info = info; vd->fmt.i_chroma = VLC_CODEC_RGB32; /* masks change this to BGR32 for ID2D1Bitmap */ vd->fmt.i_rmask = 0x0000ff00; vd->fmt.i_gmask = 0x00ff0000; vd->fmt.i_bmask = 0xff000000; vd->pool = Pool; vd->prepare = Prepare; vd->display = Display; vd->manage = Manage; vd->control = Control; EventThreadUpdateTitle(sys->event, VOUT_TITLE " (Direct2D output)"); #ifndef NDEBUG msg_Dbg(vd, "Ready"); #endif return VLC_SUCCESS; error: Close(VLC_OBJECT(vd)); return VLC_EGENERIC; }
CBCGPRibbonQuickStepsButton::CBCGPRibbonQuickStepsButton() { CommonInit(); }
// ---------------------------------------------------------------------------- void vHavokChainAnimation::OnVariableValueChanged(VisVariable_cl *pVar, const char * value) { // Re-Init CommonInit(); }
void VCablePathRenderer::OnVariableValueChanged(VisVariable_cl* pVar, const char* value) { CommonInit(); }
CBCGPRibbonStatusBarPane::CBCGPRibbonStatusBarPane() { CommonInit (); }
/** * It creates an OpenGL vout display. */ static int Open(vlc_object_t *object) { vout_display_t *vd = (vout_display_t *)object; vout_display_sys_t *sys; /* Allocate structure */ vd->sys = sys = (vout_display_sys_t *)calloc(1, sizeof(*sys)); // sunqueen modify if (!sys) return VLC_ENOMEM; /* */ if (CommonInit(vd)) goto error; EventThreadUpdateTitle(sys->event, VOUT_TITLE " (OpenGL output)"); /* process selected GPU affinity */ int nVidiaAffinity = var_InheritInteger(vd, "gpu-affinity"); if (nVidiaAffinity >= 0) CreateGPUAffinityDC(vd, nVidiaAffinity); /* */ sys->hGLDC = GetDC(sys->hvideownd); /* Set the pixel format for the DC */ PIXELFORMATDESCRIPTOR pfd; memset(&pfd, 0, sizeof(pfd)); pfd.nSize = sizeof(pfd); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; SetPixelFormat(sys->hGLDC, ChoosePixelFormat(sys->hGLDC, &pfd), &pfd); /* * Create and enable the render context * For GPU affinity, attach the window DC * to the GPU affinity DC */ sys->hGLRC = wglCreateContext((sys->affinityHDC != NULL) ? sys->affinityHDC : sys->hGLDC); wglMakeCurrent(sys->hGLDC, sys->hGLRC); const char *extensions = (const char*)glGetString(GL_EXTENSIONS); #ifdef WGL_EXT_swap_control if (HasExtension(extensions, "WGL_EXT_swap_control")) { PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); if (SwapIntervalEXT) SwapIntervalEXT(1); } #endif /* */ sys->gl.lock = NULL; sys->gl.unlock = NULL; sys->gl.swap = Swap; sys->gl.getProcAddress = OurGetProcAddress; sys->gl.sys = vd; video_format_t fmt = vd->fmt; const vlc_fourcc_t *subpicture_chromas; sys->vgl = vout_display_opengl_New(&fmt, &subpicture_chromas, &sys->gl); if (!sys->vgl) goto error; vout_display_info_t info = vd->info; info.has_double_click = true; info.has_hide_mouse = false; info.has_event_thread = true; info.subpicture_chromas = subpicture_chromas; /* Setup vout_display now that everything is fine */ vd->fmt = fmt; vd->info = info; vd->pool = Pool; vd->prepare = Prepare; vd->display = Display; vd->control = Control; vd->manage = Manage; return VLC_SUCCESS; error: Close(object); return VLC_EGENERIC; }
//******************************************************************************* CBCGPChartObject::CBCGPChartObject() { CommonInit(); }
void n2dEngineImpl::SingleThreadMainLoop(ncTStr title, nuInt FPS) { // 啪! SetThreadAffinityMask(GetCurrentThread(), 1); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); natStopWatch tTimer, tMsgTimer; double tTime, tMsgTime; n2dFPSControllerImpl tfpsc(FPS); if (!m_pListener->EngineInit()) { TerminateApplication(); } while (m_IsProgramLooping.load(std::memory_order_acquire)) { if (m_Window.Create(title, m_ClassName, m_hInstance, this)) { m_Window.Show(); CommonInit(); if (!m_pListener->WindowInit()) { TerminateApplication(); } else { MSG msg; bool isMessagePumpActive = true; m_Keys.Clear(); while (isMessagePumpActive) { tMsgTimer.Reset(); if (PeekMessage(&msg, m_Window.GetWnd(), 0, 0, PM_REMOVE)) { if (msg.message != WM_QUIT) { DispatchMessage(&msg); } else { isMessagePumpActive = false; } } tMsgTime = tMsgTimer.GetElpased(); tTime = tfpsc.Update(tTimer) - tMsgTime; if (!m_IsVisible) { WaitMessage(); } else { m_pListener->Update(tTime, &tfpsc); m_pListener->Render(tTime, &tfpsc, m_pRenderer); //m_Window.SwapBuffers(); } } } m_pListener->WindowUninit(); } else { m_IsProgramLooping.store(false, std::memory_order_release); nat_Throw(natException, _T("Failed to create GL window.")); } } m_pListener->EngineUninit(); }
idGameBustOutWindow::idGameBustOutWindow(idUserInterfaceLocal *g) : idWindow(g) { gui = g; CommonInit(); }
void n2dEngineImpl::MultiThreadMainLoop(ncTStr title, nuInt FPS) { UpdateThread updateThread(this, FPS); RenderThread renderThread(this, FPS); if (!m_pListener->EngineInit()) { TerminateApplication(); } while (m_IsProgramLooping.load(std::memory_order_acquire)) { if (m_Window.Create(title, m_ClassName, m_hInstance, this)) { MSG msg; m_Window.Show(); CommonInit(); if (!m_pListener->WindowInit()) { TerminateApplication(); } else { wglMakeCurrent(NULL, NULL); updateThread.Resume(); renderThread.Resume(); bool isMessagePumpActive = true; m_Keys.Clear(); while (isMessagePumpActive) { if (PeekMessage(&msg, m_Window.GetWnd(), 0, 0, PM_REMOVE)) { if (msg.message != WM_QUIT) { DispatchMessage(&msg); } else { isMessagePumpActive = false; } } if (!m_IsVisible) { WaitMessage(); } } if (updateThread.Wait(10u)) if (renderThread.Wait(10u)) break; if (PeekMessage(&msg, m_Window.GetWnd(), 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } } m_pListener->WindowUninit(); } else { m_IsProgramLooping.store(false, std::memory_order_release); nat_Throw(natException, _T("Failed to create GL window.")); } } updateThread.Wait(); renderThread.Wait(); m_pListener->EngineUninit(); }
CBCGPropertySheet::CBCGPropertySheet() : m_Impl (*this) { CommonInit (); }
CBCGPRibbonProgressBar::CBCGPRibbonProgressBar() { CommonInit (); }
//****************************************************************************** CBCGPRadialMenuItem::CBCGPRadialMenuItem() { CommonInit(); }
int main(int argc, char *argv[]) { int fsaa, accel; int value; int i, done; SDL_DisplayMode mode; SDL_Event event; Uint32 then, now, frames; int status; /* Initialize parameters */ fsaa = 0; accel = 0; /* Initialize test framework */ state = CommonCreateState(argv, SDL_INIT_VIDEO); if (!state) { return 1; } for (i = 1; i < argc;) { int consumed; consumed = CommonArg(state, i); if (consumed == 0) { if (SDL_strcasecmp(argv[i], "--fsaa") == 0) { ++fsaa; consumed = 1; } else if (SDL_strcasecmp(argv[i], "--accel") == 0) { ++accel; consumed = 1; } else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) { i++; if (!argv[i]) { consumed = -1; } else { depth = SDL_atoi(argv[i]); consumed = 1; } } else { consumed = -1; } } if (consumed < 0) { fprintf(stderr, "Usage: %s %s [--fsaa] [--accel] [--zdepth %%d]\n", argv[0], CommonUsage(state)); quit(1); } i += consumed; } /* Set OpenGL parameters */ state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_BORDERLESS; state->gl_red_size = 5; state->gl_green_size = 5; state->gl_blue_size = 5; state->gl_depth_size = depth; if (fsaa) { state->gl_multisamplebuffers=1; state->gl_multisamplesamples=fsaa; } if (accel) { state->gl_accelerated=1; } if (!CommonInit(state)) { quit(2); } context = SDL_calloc(state->num_windows, sizeof(context)); if (context == NULL) { fprintf(stderr, "Out of memory!\n"); quit(2); } /* Create OpenGL ES contexts */ for (i = 0; i < state->num_windows; i++) { context[i] = SDL_GL_CreateContext(state->windows[i]); if (!context[i]) { fprintf(stderr, "SDL_GL_CreateContext(): %s\n", SDL_GetError()); quit(2); } } if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) { SDL_GL_SetSwapInterval(1); } else { SDL_GL_SetSwapInterval(0); } SDL_GetCurrentDisplayMode(0, &mode); printf("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format)); printf("\n"); printf("Vendor : %s\n", glGetString(GL_VENDOR)); printf("Renderer : %s\n", glGetString(GL_RENDERER)); printf("Version : %s\n", glGetString(GL_VERSION)); printf("Extensions : %s\n", glGetString(GL_EXTENSIONS)); printf("\n"); status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); if (!status) { printf("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); } else { fprintf(stderr, "Failed to get SDL_GL_RED_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); if (!status) { printf("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); } else { fprintf(stderr, "Failed to get SDL_GL_GREEN_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); if (!status) { printf("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); } else { fprintf(stderr, "Failed to get SDL_GL_BLUE_SIZE: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); if (!status) { printf("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); } else { fprintf(stderr, "Failed to get SDL_GL_DEPTH_SIZE: %s\n", SDL_GetError()); } if (fsaa) { status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); if (!status) { printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); } else { fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", SDL_GetError()); } status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); if (!status) { printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value); } else { fprintf(stderr, "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", SDL_GetError()); } } if (accel) { status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); if (!status) { printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); } else { fprintf(stderr, "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", SDL_GetError()); } } /* Set rendering settings for each context */ for (i = 0; i < state->num_windows; ++i) { float aspectAdjust; status = SDL_GL_MakeCurrent(state->windows[i], context[i]); if (status) { printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); /* Continue for next window */ continue; } aspectAdjust = (4.0f / 3.0f) / ((float)state->window_w / state->window_h); glViewport(0, 0, state->window_w, state->window_h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof(-2.0, 2.0, -2.0 * aspectAdjust, 2.0 * aspectAdjust, -20.0, 20.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glShadeModel(GL_SMOOTH); } /* Main render loop */ frames = 0; then = SDL_GetTicks(); done = 0; int isPause = 0; while (!done) { SDL_Delay(1000); LOGI("in process"); /* Check for events */ ++frames; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_RESIZED: for (i = 0; i < state->num_windows; ++i) { if (event.window.windowID == SDL_GetWindowID(state->windows[i])) { status = SDL_GL_MakeCurrent(state->windows[i], context[i]); if (status) { printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); break; } /* Change view port to the new window dimensions */ glViewport(0, 0, event.window.data1, event.window.data2); /* Update window content */ Render(); SDL_GL_SwapWindow(state->windows[i]); break; } } break; case SDL_WINDOWEVENT_FOCUS_LOST: LOGI("in SDL_WINDOWEVENT_FOCUS_LOST"); isPause = 1; break; case SDL_WINDOWEVENT_FOCUS_GAINED: LOGI("in SDL_WINDOWEVENT_FOCUS_GAINED"); isPause = 0; break; } } CommonEvent(state, &event, &done); } if (isPause == 0) { for (i = 0; i < state->num_windows; ++i) { status = SDL_GL_MakeCurrent(state->windows[i], context[i]); if (status) { printf("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); /* Continue for next window */ continue; } Render(); SDL_GL_SwapWindow(state->windows[i]); } } } /* Print out some timing information */ now = SDL_GetTicks(); if (now > then) { printf("%2.2f frames per second\n", ((double) frames * 1000) / (now - then)); } quit(0); return 0; }
/** This function allocates and initialize the DirectX vout display. */ static int Open(vlc_object_t *object) { vout_display_t *vd = (vout_display_t *)object; vout_display_sys_t *sys; /* Allocate structure */ vd->sys = sys = calloc(1, sizeof(*sys)); if (!sys) return VLC_ENOMEM; /* Load direct draw DLL */ sys->hddraw_dll = LoadLibrary(_T("DDRAW.DLL")); if (!sys->hddraw_dll) { msg_Warn(vd, "DirectXInitDDraw failed loading ddraw.dll"); free(sys); return VLC_EGENERIC; } /* */ sys->use_wallpaper = var_CreateGetBool(vd, "video-wallpaper"); /* FIXME */ sys->use_overlay = false;//var_CreateGetBool(vd, "overlay"); /* FIXME */ sys->restore_overlay = false; var_Create(vd, "directx-device", VLC_VAR_STRING | VLC_VAR_DOINHERIT); /* Initialisation */ if (CommonInit(vd)) goto error; /* */ video_format_t fmt = vd->fmt; if (DirectXOpen(vd, &fmt)) goto error; /* */ vout_display_info_t info = vd->info; info.is_slow = true; info.has_double_click = true; info.has_hide_mouse = false; info.has_pictures_invalid = true; info.has_event_thread = true; /* Interaction TODO support starting with wallpaper mode */ vlc_mutex_init(&sys->lock); sys->ch_wallpaper = sys->use_wallpaper; sys->wallpaper_requested = sys->use_wallpaper; sys->use_wallpaper = false; vlc_value_t val; val.psz_string = _("Wallpaper"); var_Change(vd, "video-wallpaper", VLC_VAR_SETTEXT, &val, NULL); var_AddCallback(vd, "video-wallpaper", WallpaperCallback, NULL); /* Setup vout_display now that everything is fine */ vd->fmt = fmt; vd->info = info; vd->pool = Pool; vd->prepare = NULL; vd->display = Display; vd->control = Control; vd->manage = Manage; return VLC_SUCCESS; error: DirectXClose(vd); CommonClean(vd); if (sys->hddraw_dll) FreeLibrary(sys->hddraw_dll); free(sys); return VLC_EGENERIC; }
// ---------------------------------------------------------------------------- void vHavokChainAnimation::OnDeserializationCallback(const VSerializationContext &context) { // The owner constraint chain should now be established; we can init this // component now. CommonInit(); }
idEditWindow::idEditWindow( idDeviceContext *d, idUserInterfaceLocal *g ) : idWindow(d, g) { dc = d; gui = g; CommonInit(); }
void CLife::Initialize( int GridCols, int GridRows, int CellSize, GridStep stepping, std::string OutFile ) { LifeGrid = new CCellGrid( GridRows, GridCols ); CommonInit( CellSize, stepping, OutFile ); }