30#include "gdk/win32/gdkwin32.h"
68 CDCGuard(
const CDCGuard &);
72 explicit CDCGuard(HDC hDC) : fHDC(hDC)
91 WDCGuard(
const WDCGuard &);
95 WDCGuard(HDC hDC,
Window_t winID) : fHDC(hDC), fWinID(winID)
100 ReleaseDC((HWND)GDK_DRAWABLE_XID((GdkWindow *)fWinID), fHDC);
113 BMPGuard(
const BMPGuard &);
117 explicit BMPGuard(HBITMAP bmp) : fBMP(bmp)
135 WGLGuard(
const WGLGuard &);
139 explicit WGLGuard(HGLRC glrc) : fCtx(glrc)
144 wglDeleteContext(fCtx);
153const PIXELFORMATDESCRIPTOR
173const PIXELFORMATDESCRIPTOR
204 std::deque<TGLContext>::size_type i = 0;
211 ::Warning(
"TGWin32GLManager::~TGLWin32GLManager",
"You forget to destroy gl-context %d\n", i);
232 gROOT->GetListOfSpecials()->AddLast(
this);
257 HDC hDC = GetWindowDC((HWND)GDK_DRAWABLE_XID((GdkWindow *)winID));
260 Error(
"CreateGLContext",
"GetWindowDC failed\n");
264 WDCGuard dcGuard(hDC, winID);
268 HGLRC glCtx = wglCreateContext(hDC);
271 Error(
"CreateGLContext",
"wglCreateContext failed\n");
275 TGLContext newDevice = {winInd, -1, hDC, 0, glCtx};
276 PIXELFORMATDESCRIPTOR testFormat = {};
277 DescribePixelFormat(hDC, pixFormat,
sizeof testFormat, &testFormat);
281 Int_t ind = ctx->fWindowIndex;
287 WGLGuard wglGuard(glCtx);
294 Error(
"CreateGLContext",
"SetPixelFormat failed\n");
296 Error(
"CreateGLContext",
"ChoosePixelFormat failed\n");
306 HDC dibDC = CreateCompatibleDC(0);
309 Error(
"CreateDIB",
"CreateCompatibleDC failed\n");
313 CDCGuard dcGuard(dibDC);
315 BITMAPINFOHEADER bmpHeader = {
sizeof bmpHeader, (LONG) ctx.
fW, (LONG) ctx.
fH, 1, 32, BI_RGB};
316 void *bmpCnt =
nullptr;
317 HBITMAP hDIB = CreateDIBSection(dibDC, (BITMAPINFO*)&bmpHeader, DIB_RGB_COLORS, &bmpCnt, 0, 0);
320 Error(
"CreateDIB",
"CreateDIBSection failed\n");
324 BMPGuard bmpGuard(hDIB);
366 Error(
"ResizeOffScreenDevice",
"Error trying to create new DIB\n");
399 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
400 glReadBuffer(GL_BACK);
401 glReadPixels(0, 0, ctx.
fW, ctx.
fH, GL_BGRA_EXT, GL_UNSIGNED_BYTE, ctx.
fDIBData);
428 wglSwapLayerBuffers(ctx.
fDC, WGL_SWAP_MAIN_PLANE);
431 HDC hDC = CreateCompatibleDC(0);
434 Error(
"Flush",
"CreateCompatibleDC failed\n");
438 HBITMAP oldDIB = (HBITMAP)SelectObject(hDC, ctx.
fHBitmap);
440 if (!BitBlt(ctx.
fDC, ctx.
fX, ctx.
fY, ctx.
fW, ctx.
fH, hDC, 0, 0, SRCCOPY))
443 SelectObject(hDC, oldDIB);
480 viewport[2] = ctx.
fW;
481 viewport[3] = ctx.
fH;
503 return manip->
Select(*camera, *rect, *sceneBox);
Handle_t Window_t
Window handle.
ULongptr_t Handle_t
Generic resource handle.
const PIXELFORMATDESCRIPTOR doubleBufferDesc
const PIXELFORMATDESCRIPTOR singleScreenDesc
Binding & operator=(OUT(*fun)(void))
R__EXTERN TGLManager *(* gPtr2GLManager)()
Concrete class describing an orientated (free) or axis aligned box of 8 vertices.
Abstract base camera class - concrete classes for orthographic and perspective cameras derive from it...
Viewport (pixel base) 2D rectangle class.
static TGLManager * ProxyObject()
TGLContext * fNextFreeContext
std::deque< TGLContext > fGLContexts
Int_t InitGLWindow(Window_t winID)
Int_t CreateGLContext(Int_t winInd)
winInd is TGWin32 index, returned by previous call gGLManager->InitGLWindow returns descripto (index)...
Bool_t ResizeOffScreenDevice(Int_t devInd, Int_t x, Int_t y, UInt_t w, UInt_t h)
Create new DIB if needed.
Bool_t PlotSelected(TVirtualGLPainter *plot, Int_t px, Int_t py)
void PaintSingleObject(TVirtualGLPainter *)
void PrintViewer(TVirtualViewer3D *vv)
Bool_t CreateDIB(TGLContext &ctx) const
Create DIB section to read GL buffer into.
Int_t GetVirtualXInd(Int_t devInd)
void PanObject(TVirtualGLPainter *o, Int_t x, Int_t y)
void DeleteGLContext(Int_t devInd)
void ExtractViewport(Int_t devInd, Int_t *vp)
void SelectOffScreenDevice(Int_t devInd)
void MarkForDirectCopy(Int_t devInd, Bool_t)
Bool_t MakeCurrent(Int_t devInd)
void ReadGLBuffer(Int_t devInd)
Bool_t AttachOffScreenDevice(Int_t ctxInd, Int_t x, Int_t y, UInt_t w, UInt_t h)
Bool_t HighColorFormat(Int_t ctx)
char * GetPlotInfo(TVirtualGLPainter *plot, Int_t px, Int_t py)
Bool_t SelectManip(TVirtualGLManip *manip, const TGLCamera *camera, const TGLRect *rect, const TGLBoundingBox *sceneBox)
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual Bool_t Select(const TGLCamera &camera, const TGLRect &rect, const TGLBoundingBox &sceneBox)=0
virtual Bool_t PlotSelected(Int_t px, Int_t py)=0
virtual char * GetPlotInfo(Int_t px, Int_t py)=0
virtual void Pan(Int_t px, Int_t py)=0
Abstract 3D shapes viewer.
virtual void PrintObjects()
TGLContext * fNextFreeContext