Context* Context::Create(const HWND i_renderingWindow) { HDC deviceContext = nullptr; HGLRC openGlRenderingContext = nullptr; if (CreateRenderingContext(i_renderingWindow, deviceContext, openGlRenderingContext)) { std::string error; if (eae6320::OpenGlExtensions::Load(&error)) { Context *context = new Context(i_renderingWindow); if (context) { context->deviceContext = deviceContext; context->openGlRenderingContext = openGlRenderingContext; return context; } else { Lame::UserOutput::Display("Failed to create OpenGL Context, due to insufficient memory.", "Context Loading Error"); } } else { Lame::UserOutput::Display(error); } } CleanupContextData(i_renderingWindow, deviceContext, openGlRenderingContext); return nullptr; }
bool eae6320::Graphics::Initialize( const HWND i_renderingWindow ) { s_renderingWindow = i_renderingWindow; // Create an OpenGL rendering context if ( !CreateRenderingContext() ) { goto OnError; } // Load any required OpenGL extensions { std::string errorMessage; if ( !OpenGlExtensions::Load( &errorMessage ) ) { UserOutput::Print( errorMessage ); goto OnError; } } if (!LoadObjects()) { goto OnError; } return true; OnError: ShutDown(); return false; }
NS_IMETHODIMP nsThebesDeviceContext::CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext) { // This is currently only called by the caret code NS_ENSURE_ARG_POINTER(aView); NS_PRECONDITION(aView->HasWidget(), "View has no widget!"); nsCOMPtr<nsIWidget> widget; widget = aView->GetWidget(); return CreateRenderingContext(widget, aContext); }
bool CMSWindow::Create(int LeftUpX, int LeftUpY, int Width, int Height, int bitsPerPixel, char *title, int arbMultisampleFormat, bool arbMultisampleSupported, bool Antialiasing, int AntialiasingMode) { //Initializing global strings LoadString(hInstance, IdTitle, AppTitle, MAX_LOADSTRING); LoadString(hInstance, IdApp, AppWindowClass, MAX_LOADSTRING); Register(); // Realizar la inicialización de la aplicación: if (!InitInstance ()) return FALSE; hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IdApp)); //**************************************************************// // Initialize Common Controls INITCOMMONCONTROLSEX icex; // Initialize Windows Common Controls // Load the ToolTip class from the DLL icex.dwSize = sizeof(icex); icex.dwICC = ICC_BAR_CLASSES; // For Tooltips if(!InitCommonControlsEx(&icex)) BOX("InitCommonControlEx() failed."); CreateRenderingContext(); if(!IsDeviceContextOK() || !IsRenderingContextOK()) { Destroy(); return FALSE; } Visible = TRUE; /// Set Visible To True //Reshape(45.0f); return TRUE; // Window Creating Was A Success }
void TaskbarPreview::DrawBitmap(PRUint32 width, PRUint32 height, PRBool isPreview) { nsresult rv; nsRefPtr<gfxWindowsSurface> surface = new gfxWindowsSurface(gfxIntSize(width, height), gfxASurface::ImageFormatARGB32); nsCOMPtr<nsIDocShell> shell = do_QueryReferent(mDocShell); if (!shell) return; nsCOMPtr<nsICanvasRenderingContextInternal> ctxI; rv = CreateRenderingContext(shell, surface, width, height, getter_AddRefs(ctxI)); nsCOMPtr<nsIDOMCanvasRenderingContext2D> ctx = do_QueryInterface(ctxI); PRBool drawFrame = PR_FALSE; if (NS_SUCCEEDED(rv) && ctx) { if (isPreview) rv = mController->DrawPreview(ctx, &drawFrame); else rv = mController->DrawThumbnail(ctx, width, height, &drawFrame); } if (NS_FAILED(rv)) return; HDC hDC = surface->GetDC(); HBITMAP hBitmap = (HBITMAP)GetCurrentObject(hDC, OBJ_BITMAP); DWORD flags = drawFrame ? DWM_SIT_DISPLAYFRAME : 0; POINT pptClient = { 0, 0 }; if (isPreview) nsUXThemeData::dwmSetIconicLivePreviewBitmapPtr(PreviewWindow(), hBitmap, &pptClient, flags); else nsUXThemeData::dwmSetIconicThumbnailPtr(PreviewWindow(), hBitmap, flags); }
bool eae6320::Graphics::Initialize( const HWND i_renderingWindow ) { s_renderingWindow = i_renderingWindow; //s_effect = new GraphicEffect("data/effect.lua"); //s_effect_transparent = new GraphicEffect("data/effect_transparent.lua"); s_material_ceiling = new Material("data/ceiling.lua"); s_material_floor = new Material("data/floor.lua"); s_material_metal = new Material("data/metal.lua"); s_material_railing = new Material("data/railing.lua"); s_material_wall = new Material("data/wall.lua"); s_material_cement = new Material("data/cement.lua"); s_ceiling = new Mesh("data/Ceiling.mesh"); s_floor = new Mesh("data/Floor.mesh"); s_metal = new Mesh("data/Metal.mesh"); s_railing = new Mesh("data/Railing.mesh"); s_lambert2 = new Mesh("data/Lambert2.mesh"); s_wall = new Mesh("data/Walls.mesh"); s_cement = new Mesh("data/Cement.mesh"); o_cam = new Camera(); // Create an OpenGL rendering context if ( !CreateRenderingContext() ) { goto OnError; } // Load any required OpenGL extensions { std::string errorMessage; if ( !OpenGlExtensions::Load( &errorMessage ) ) { UserOutput::Print( errorMessage ); goto OnError; } } assert(glGetError() == GL_NO_ERROR); // Initialize the graphics objects /*if ( !s_Mesh_Rectangle->LoadMesh("data/rectangle.mesh")|| !s_Mesh_Triangle->LoadMesh("data/triangle.mesh")) { goto OnError; }*/ o_ceiling = new Renderable(*s_material_ceiling, *s_ceiling); o_floor = new Renderable(*s_material_floor, *s_floor); o_metal = new Renderable(*s_material_metal, *s_metal); o_railing = new Renderable(*s_material_railing, *s_railing); o_lambert2 = new Renderable(*s_material_floor, *s_lambert2); o_wall = new Renderable(*s_material_wall, *s_wall); o_cement = new Renderable(*s_material_cement, *s_cement); /*if (!o_man->LoadRenderable() || !o_floor->LoadRenderable() || !o_house->LoadRenderable() || !o_box_1->LoadRenderable() || !o_box_2->LoadRenderable() || !o_box_3->LoadRenderable() || !o_box_4->LoadRenderable()) { goto OnError; }*/ if (!o_ceiling->LoadRenderable() || !o_floor->LoadRenderable() || !o_metal->LoadRenderable() || !o_railing->LoadRenderable() || !o_lambert2->LoadRenderable() || !o_wall->LoadRenderable() || !o_cement->LoadRenderable()) { goto OnError; } assert(glGetError() == GL_NO_ERROR); return true; OnError: ShutDown(); return false; }