bool AndroidEGL::InitContexts() { bool Result = true; PImplData->SharedContext.eglContext = CreateContext(); PImplData->RenderingContext.eglContext = CreateContext(PImplData->SharedContext.eglContext); PImplData->SingleThreadedContext.eglContext = CreateContext(); return Result; }
/** * Creates a ThreadBlock structure from @func, and its @argument. * @stacksize is passed to CreateContext call. **/ static ThreadBlock * CreateThread(void (*func) (void *),void * argument,long stackSize) { ucontext_t * linkedContext = CreateContext(ExitRunningThread,NULL,stackSize,0,NULL); ucontext_t * threadContext = CreateContext((void (*) (void))func,linkedContext,stackSize,1,argument); ThreadBlock * threadBlock = (ThreadBlock *) malloc(sizeof(ThreadBlock)); threadBlock->context = threadContext; threadBlock->status = STATUS_READY; threadBlock->numberOfChildren = 0; threadBlock->previous = threadBlock->next = threadBlock->parent = NULL; threadBlock->id = uThreadContext->currentID++; return threadBlock; }
bool ConnectToSelf() { char host[MAX_HOST_LENGTH]; DWORD length = MAX_HOST_LENGTH; MPD_Context *pRightContext, *pLeftContext; host[0] = '\0'; GetComputerName(host, &length); // Initialize the new contexts pRightContext = CreateContext(); if (pRightContext == NULL) return false; strncpy(pRightContext->pszHost, host, MAX_HOST_LENGTH); pRightContext->nCurPos = 0; pRightContext->nState = MPD_IDLE; pRightContext->nLLState = MPD_READING_CMD; pRightContext->nType = MPD_RIGHT_SOCKET; pLeftContext = CreateContext(); if (pLeftContext == NULL) { RemoveContext(pRightContext); return false; } strncpy(pLeftContext->pszHost, host, MAX_HOST_LENGTH); pLeftContext->nCurPos = 0; pLeftContext->nState = MPD_IDLE; pLeftContext->nLLState = MPD_READING_CMD; pLeftContext->nType = MPD_LEFT_SOCKET; MakeLoopAsync(&pLeftContext->sock, &pRightContext->sock); if (pLeftContext->sock == INVALID_SOCKET || pRightContext->sock == INVALID_SOCKET) { RemoveContext(pLeftContext); RemoveContext(pRightContext); return false; } // overwrite the old left and right contexts g_pRightContext = pRightContext; g_pLeftContext = pLeftContext; strncpy(g_pszRightHost, host, MAX_HOST_LENGTH); strncpy(g_pszLeftHost, host, MAX_HOST_LENGTH); //dbg_printf("ConnectToSelf succeeded\n"); return true; }
int main(int argc, const char *argv[]) { KonohaContext* kctx = CreateContext(); int i; void *malloced[100]; for (i = 0; i < 100; ++i) { malloced[i] = PLATAPI GCModule.Kmalloc(0, i, NULL); } for (i = 0; i < 100; ++i) { PLATAPI GCModule.Kfree(0, malloced[i], i); } for (i = 0; i < 100; ++i) { malloced[i] = PLATAPI GCModule.Kzmalloc(0, i, NULL); int j; char *p = (char *)malloced[i]; for (j = 0; j < i; ++j) { assert(p[0] == 0); } } for (i = 0; i < 100; ++i) { PLATAPI GCModule.Kfree(0, malloced[i], i); } DeleteContext(kctx); return 0; }
HWND OGLWindow::InitInstance(HINSTANCE hInstance, HWND hParent, bool doubleBuf, int x, int y, int w, int h) { // Create the main Window. m_hWnd = CreateWindow( m_ClassName, // name of Window class m_WindowTitle, // title-bar string WS_BORDER | WS_CHILD/* | WS_CLIPSIBLINGS | WS_CLIPCHILDREN*/, // 0, // default horizontal position 0, // default vertical position 1, // default width 1, // default height hParent, // no owner Window (HMENU) NULL, // use class menu hInstance, // handle to application instance (LPVOID) NULL); // no Window-creation data if ( !CreateContext() ) { DestroyWindow(m_hWnd); m_hWnd = NULL; } m_width = w; m_height = h; MoveWindow(m_hWnd, x, y, w, h, FALSE); ShowWindow(m_hWnd, SW_HIDE); BOOL makeCurResult = wglMakeCurrent( m_hDC, m_Context ); return m_hWnd; }
void wxGISDisplay::PanningDraw(wxCoord x, wxCoord y, wxDC* pDC) { wxCriticalSectionLocker locker(m_CritSect); cairo_set_source_rgb(m_cr_tmp, m_BackGroudnColour.GetRed(), m_BackGroudnColour.GetGreen(), m_BackGroudnColour.GetBlue()); cairo_paint(m_cr_tmp); double dNewX = m_dOrigin_X + double(x); double dNewY = m_dOrigin_Y + double(y); cairo_set_source_surface (m_cr_tmp, m_saLayerCaches[m_nLastCacheID].pCairoSurface, -dNewX, -dNewY); cairo_paint (m_cr_tmp); //cairo_surface_t *surface; cairo_t *cr; cr = CreateContext(pDC); //surface = cairo_get_target(cr); cairo_set_source_surface (cr, m_surface_tmp, 0, 0); cairo_paint (cr); #ifdef __WXMSW__ //cairo_surface_destroy (surface); cairo_destroy (cr); #endif }
LinuxGLContext::LinuxGLContext(const RenderContextDescriptor& desc, Surface& surface, LinuxGLContext* sharedContext) : GLContext { sharedContext } { NativeHandle nativeHandle; surface.GetNativeHandle(&nativeHandle); CreateContext(desc, nativeHandle, sharedContext); }
void FJavascriptEditorModule::StartupModule() { #if WITH_EDITOR auto Isolate = NewObject<UJavascriptIsolate>(); auto Context = Isolate->CreateContext(); JavascriptContext = Context; JavascriptContext->AddToRoot(); JavascriptContext->SetContextId(TEXT("Editor")); Tick = NewObject<UJavascriptEditorTick>(JavascriptContext); JavascriptContext->Expose(TEXT("Root"), Tick); Tick->AddToRoot(); if (!IsRunningCommandlet()) { FScopedTransaction Transaction(NSLOCTEXT("UnrealEd", "UnrealJS", "Javascript action")); FEditorScriptExecutionGuard ScriptGuard; Context->RunFile("editor.js"); } bRegistered = true; FCoreDelegates::OnPreExit.AddRaw(this, &FJavascriptEditorModule::Unregister); #endif }
bool GSWndEGL::Create(const string& title, int w, int h) { if(m_NativeWindow) throw GSDXRecoverableError(); if(w <= 0 || h <= 0) { w = theApp.GetConfig("ModeWidth", 640); h = theApp.GetConfig("ModeHeight", 480); } m_managed = true; // note this part must be only executed when replaying .gs debug file m_NativeDisplay = XOpenDisplay(NULL); OpenEGLDisplay(); m_NativeWindow = XCreateSimpleWindow(m_NativeDisplay, DefaultRootWindow(m_NativeDisplay), 0, 0, w, h, 0, 0, 0); XMapWindow (m_NativeDisplay, m_NativeWindow); CreateContext(3, 3); AttachContext(); CheckContext(); PopulateGlFunction(); if (m_NativeWindow == 0) throw GSDXRecoverableError(); return true; }
int main(int argc, char *argv[]) { GLuint shader = 0; ParseOptions(argc, argv); if (!CreateContext()) { fprintf(stderr, "%s: Failed to create compiler context\n", Prog); exit(1); } if (Options.VertFile) { shader = CompileShader(Options.VertFile, GL_VERTEX_SHADER); } else if (Options.FragFile) { shader = CompileShader(Options.FragFile, GL_FRAGMENT_SHADER); } if (shader) { if (Options.OutputFile) { fclose(stdout); /*stdout =*/ freopen(Options.OutputFile, "w", stdout); } if (stdout) { PrintShaderInstructions(shader, stdout); } if (Options.OutputFile) { fclose(stdout); } } return 0; }
bool GSWndOGL::Create(const string& title, int w, int h) { if(m_NativeWindow) throw GSDXRecoverableError(); if(w <= 0 || h <= 0) { w = theApp.GetConfig("ModeWidth", 640); h = theApp.GetConfig("ModeHeight", 480); } m_managed = true; // note this part must be only executed when replaying .gs debug file m_NativeDisplay = XOpenDisplay(NULL); m_NativeWindow = XCreateSimpleWindow(m_NativeDisplay, DefaultRootWindow(m_NativeDisplay), 0, 0, w, h, 0, 0, 0); XMapWindow (m_NativeDisplay, m_NativeWindow); if (m_NativeWindow == 0) throw GSDXRecoverableError(); CreateContext(3, 3); AttachContext(); CheckContext(); m_swapinterval = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); PopulateGlFunction(); return true; }
int main (int argc, char *argv[]) { if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ if (argc != 2) { fprintf(stderr, "you must pass the path to a module to test"); return -1; } char *testModule = argv[1]; if (!FileExists(testModule, 0)) { fprintf(stderr, "you must pass the path to a module to test"); } ListType names; SymbolParser *parser = MakeParser(testModule); names = GetExports(parser); context = CreateContext(); LoadTestInfo info = { .parser = parser, .executeOnContext = context->ExecuteTests }; ListApplyToEach(names, 1, LoadUserTests, &info); DeleteParser(parser); FreeContext(context); return 0; }
GlxContext::GlxContext(GlxContext* shared) : myWindow (0), myContext (NULL), myOwnsWindow(true) { // Open a connection with the X server myDisplay = XOpenDisplay(NULL); // Create a dummy window (disabled and hidden) int screen = DefaultScreen(myDisplay); myWindow = XCreateWindow(myDisplay, RootWindow(myDisplay, screen), 0, 0, 1, 1, 0, DefaultDepth(myDisplay, screen), InputOutput, DefaultVisual(myDisplay, screen), 0, NULL); // Create the context CreateContext(shared, VideoMode::GetDesktopMode().BitsPerPixel, ContextSettings(0, 0, 0)); // Activate the context SetActive(true); }
int OpenBlankerWindow( void ) { struct NewGadget ng; struct Gadget *g; UWORD lc, tc; UWORD wleft = BlankerLeft, wtop = BlankerTop, ww, wh; ComputeFont( BlankerWidth, BlankerHeight ); ww = ComputeX( BlankerWidth ); wh = ComputeY( BlankerHeight ); if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww; if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh; if ( ! ( BlankerFont = OpenDiskFont( Font ))) return( 5L ); if ( ! ( g = CreateContext( &BlankerGList ))) return( 1L ); for( lc = 0, tc = 0; lc < Blanker_CNT; lc++ ) { CopyMem((char * )&BlankerNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget )); ng.ng_VisualInfo = VisualInfo; ng.ng_TextAttr = Font; ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge ); ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge ); ng.ng_Width = ComputeX( ng.ng_Width ); ng.ng_Height = ComputeY( ng.ng_Height); BlankerGadgets[ lc ] = g = CreateGadgetA((ULONG)BlankerGTypes[ lc ], g, &ng, ( struct TagItem * )&BlankerGTags[ tc ] ); while( BlankerGTags[ tc ] ) tc += 2; tc++; if ( NOT g ) return( 2L ); } if ( ! ( BlankerWnd = OpenWindowTags( NULL, WA_Left, wleft, WA_Top, wtop, WA_Width, ww + OffX + Scr->WBorRight, WA_Height, wh + OffY + Scr->WBorBottom, WA_IDCMP, BUTTONIDCMP|LISTVIEWIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW, WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SIZEBBOTTOM|WFLG_SMART_REFRESH|WFLG_ACTIVATE|WFLG_RMBTRAP, WA_Gadgets, BlankerGList, WA_Title, BlankerWdt, WA_ScreenTitle, "Garshneblanker", WA_PubScreen, Scr, TAG_DONE ))) return( 4L ); GT_RefreshWindow( BlankerWnd, NULL ); return( 0L ); }
struct Gadget *CreateAllGadgets(piObject *o) { struct Gadget *g=NULL; piObject *go; struct Node_Window *nw; piGetAttr(o,OBJ_Node,(ULONG *)&nw); nw->nw_Gadgets=NULL; if(nw->nw_PageGadget==0 && GUI.gui_Mode==MODE_TEST) { if(nw->nw_MyFlags&MYWA_BBottomSlider) { g=CreateContext(&nw->nw_Gadgets); unless(nw->nw_Object[0]=NewObject(NULL, BUTTONGCLASS, // ICA_TARGET, ICTARGET_IDCMP, GA_RelVerify,TRUE, GA_Image, gui_LeftImage, GA_RelRight, 1-(IM_WIDTH(gui_LeftImage)+IM_WIDTH(gui_SizeImage)+IM_WIDTH(gui_RightImage)), GA_RelBottom, 1-(IM_HEIGHT(gui_LeftImage)), GA_BottomBorder,TRUE, GA_Previous,(ULONG *)g, (nw->nw_Flags&WFLG_GIMMEZEROZERO) ? GA_GZZGadget : TAG_IGNORE,TRUE, GA_ID, GD_LEFTBUTTON, TAG_DONE)) return NULL; g=(struct Gadget *)nw->nw_Object[0]; unless(nw->nw_Object[1]=NewObject(NULL, BUTTONGCLASS, // ICA_TARGET, ICTARGET_IDCMP, GA_RelVerify,TRUE, GA_Image, gui_RightImage, GA_RelRight, 1-(IM_WIDTH(gui_RightImage)+IM_WIDTH(gui_SizeImage)), GA_RelBottom, 1-(IM_HEIGHT(gui_RightImage)), GA_BottomBorder,TRUE, GA_Previous,(ULONG *)g, (nw->nw_Flags&WFLG_GIMMEZEROZERO) ? GA_GZZGadget : TAG_IGNORE,TRUE, GA_ID, GD_RIGHTBUTTON, TAG_DONE)) return NULL; g=(struct Gadget *)nw->nw_Object[1]; unless(nw->nw_Object[2]=NewObject(NULL, PROPGCLASS, // ICA_TARGET, ICTARGET_IDCMP, GA_RelVerify,TRUE, PGA_Freedom, FREEHORIZ, PGA_NewLook, TRUE, PGA_Borderless, ((DrawInfo->dri_Flags & DRIF_NEWLOOK) && DrawInfo->dri_Depth != 1), GA_Left, 3, GA_RelBottom, -(IM_HEIGHT(gui_SizeImage)-3), GA_RelWidth, -(4+IM_WIDTH(gui_LeftImage)+IM_WIDTH(gui_RightImage)+IM_WIDTH(gui_SizeImage)+1), GA_Height, IM_HEIGHT(gui_SizeImage)-4, GA_BottomBorder, TRUE, GA_Previous,(ULONG *)g, (nw->nw_Flags&WFLG_GIMMEZEROZERO) ? GA_GZZGadget : TAG_IGNORE,TRUE, GA_ID, GD_HORIZBUTTON, PGA_Total, 1, PGA_Visible, 1, TAG_DONE)) return NULL; g=(struct Gadget *)nw->nw_Object[2]; } else {
zglCoreContextWin::zglCoreContextWin(const zglState& state) : m_state(state) , m_hDC(NULL) , m_Context(NULL) , m_tempContext(NULL) { CreateContext(); }
void TLSContext::Initialise() { InitialiseThreadSafety(); InitialiseOpenSSL(); CreateContext(); LoadCertificate(); SelectCiphers(); DerivedInitialise(); }
int OpenBlockSelectWindow( void ) { struct NewGadget ng; struct Gadget *g; UWORD lc, tc; UWORD offx = Scr->WBorLeft, offy = Scr->WBorTop + Scr->RastPort.TxHeight + 1; if ( ! ( g = CreateContext( &BlockSelectGList ))){ CloseBlockSelectWindow(); return( 1L ); } for( lc = 0, tc = 0; lc < BlockSelect_CNT; lc++ ) { CopyMem((char * )&BlockSelectNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget )); ng.ng_VisualInfo = VisualInfo; ng.ng_TextAttr = &topaz8; ng.ng_LeftEdge += offx; ng.ng_TopEdge += offy; BlockSelectGadgets[ lc ] = g = CreateGadgetA((ULONG)BlockSelectGTypes[ lc ], g, &ng, ( struct TagItem * )&BlockSelectGTags[ tc ] ); while( BlockSelectGTags[ tc ] ) tc += 2; tc++; if ( NOT g ){ CloseBlockSelectWindow(); return( 2L ); } } if ( ! ( BlockSelectWnd = OpenWindowTags( NULL, WA_Left, BlockSelectLeft, WA_Top, BlockSelectTop, WA_Width, BlockSelectWidth, WA_Height, BlockSelectHeight + offy, WA_IDCMP, LISTVIEWIDCMP | BUTTONIDCMP | IDCMP_NEWSIZE | IDCMP_REFRESHWINDOW | IDCMP_RAWKEY, WA_Flags, WFLG_SIZEGADGET|WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_SMART_REFRESH, WA_Gadgets, BlockSelectGList, WA_Title, BlockSelectWdt, WA_MinWidth, 160, WA_MinHeight, 60, WA_MaxWidth, 720, WA_MaxHeight, 467, WA_AutoAdjust, TRUE, WA_PubScreen,Scr, TAG_DONE ))) { CloseBlockSelectWindow(); return( 4L ); } GT_RefreshWindow( BlockSelectWnd, NULL ); return( 0L ); }
OGLDriver::OGLDriver(HWND hWnd, float viewportWidth, float viewportHeight, bool fullscreen) { m_hWnd = hWnd; m_viewPortWidth = viewportWidth; m_viewPortHeight = viewportHeight; m_fullscreen = fullscreen; CreateContext(); }
int lib_gadtools_f_CreateContext_2(emumsg_syscall_t *msg) { /* Make real syscall */ msg->arg[0]._aptr = CreateContext( (struct Gadget **)msg->arg[0]._aptr ); return HOOK_DONE; }
int main(int argc, const char *argv[]) { KonohaContext* konoha = CreateContext(); int i; for (i = 0; i < 100; ++i) { test_kString(konoha); } DeleteContext(konoha); return 0; }
void ClSetup::SetupCl(int platform_index, int device_index) { platform = GetPlatformID(platform_index); PrintPlatformInfo(platform); device = GetDeviceID(device_index); PrintDeviceInfo(device); context = CreateContext(); queue = CreateCommandQueue(); bInit = true; }
//Función que se encarga de la inicialización de OpenGL. //Recibe la ventana sobre la que OpenGL hará el render. bool cGraphicManager::Init( cWindow * lpWindow ) { //Se crear el contexto de renderizado: bool lbRet = CreateContext( lpWindow ); if ( lbRet ) { //Se establece el estado de OpenGL: InitializeGLState(); } return lbRet; }
ThreadContext* PhysicalOperator::CreateOrReuseContext(context_reuse_mode crm) { ThreadContext* target = GetFreeContext(crm); if (target != NULL) { return target; } target = CreateContext(); target->set_locality_(GetCurrentCpuAffinity()); InitContext(target); return target; }
int main(int argc, const char *argv[]) { int ret = 0; KonohaContext* konoha = CreateContext(); test_gc(konoha); DeleteContext(konoha); assert(__Free__ == __Init__); fprintf(stderr, "alloced_object_count = %d, freed_object_count=%d\n", __Init__, __Free__); test_bitops(); return ret; }
static void Instance_DidChangeView(PP_Instance instance, const struct PP_Rect* position, const struct PP_Rect* clip) { if (position->size.width == screenWidth && position->size.height == screenHeight) return; // Size didn't change, no need to update anything. Log("change view\n"); DestroyContext(instance); CreateContext(instance, &position->size); }
int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutCreateWindow("GL interop"); glutIconifyWindow(); glutDisplayFunc(computeVBO); glutIdleFunc(computeVBO); initVBO(); CreateContext(); if(!context) { std::cerr << "Failed to create OpenCL context." << std::endl; return EXIT_FAILURE; } CreateCommandQueue(); if(!commandQueue) { Cleanup(); return EXIT_FAILURE; } CreateProgram(); if(!program) { Cleanup(); return EXIT_FAILURE; } kernel = clCreateKernel(program, "init_vbo_kernel", NULL); if(!kernel) { std::cerr << "Failed to create kernel" << std::endl; Cleanup(); return EXIT_FAILURE; } if (!CreateMemObjects()) { Cleanup(); return EXIT_FAILURE; } glutMainLoop(); std::cout << std::endl; std::cout << "Executed program succesfully." << std::endl; Cleanup(); }
void wxGISDisplay::Output(cairo_surface_t *pSurface, wxDC* pDC) { cairo_t *cr = CreateContext(pDC); if(cr == NULL) return; cairo_set_source_surface (cr, pSurface, 0, 0); cairo_paint (cr); //#ifdef __WXMSW__ cairo_destroy (cr); //#endif }
bool GSWndOGL::Attach(void* handle, bool managed) { m_NativeWindow = *(Window*)handle; m_managed = managed; m_NativeDisplay = XOpenDisplay(NULL); if (theApp.GetConfig("reduce_gl_requirement_for_free_driver", 0) == 1) CreateContext(3, 0); else CreateContext(3, 3); AttachContext(); CheckContext(); m_swapinterval = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalEXT"); PopulateGlFunction(); return true; }
bool GSWndEGL::Attach(void* handle, bool managed) { m_NativeWindow = *(Window*)handle; m_managed = managed; m_NativeDisplay = XOpenDisplay(NULL); OpenEGLDisplay(); #ifdef ENABLE_GLES // FIXME: update it to GLES 3.1 when they support it CreateContext(3, 0); #else CreateContext(3, 3); #endif AttachContext(); CheckContext(); PopulateGlFunction(); return true; }