yucad3d

Windows & OpenGL Rendering

yucad renders with OpenGL and offers two ways to put pixels on screen inside a host application.

All geometry — entities, grid, crosshair, rubber-band preview, snap markers — is drawn through OpenGL. There is no GDI or QPainter path for drawing geometry. yucad maintains retained GPU vertex buffers per document and re-collects only when the drawing's revision or the scene state changes, so redraws during pan/zoom are cheap even on large drawings.

Mode A — library-owned viewport: CadWndCreate

The primary mode. You give yucad a parent HWND; it creates a child window, builds the OpenGL surface, and takes over painting and input for that region.

YuHwnd view = CadWndCreate(hDwg, hParent, style, x, y, w, h);

Mode B — host-owned surface: the CadWin* family

When the host wants to own the window and its message loop completely, the CadWin* family renders offscreen and hands you the pixels — or blits them into your device context — instead of creating a child window.

CadWinCreate(hDwg, hostHwnd, w, h);   /* bind an offscreen GL surface   */
CadWinSetView(hDwg, cx, cy, scale);   /* center + scale (world→pixels)  */
CadWinPaint(hDwg, hdc);               /* render + blit into your HDC    */
CadWinMouse(hDwg, msg, x, y, flags);  /* feed input for pan / zoom      */

Internally this path uses an OpenGL context bound to an offscreen framebuffer: yucad renders the scene, reads it back, and StretchDIBits it onto the host's HDC. It stays OpenGL-only — the GDI call is just the final blit, never geometry drawing.

HDC = Handle to Device Context, the Win32 GDI handle for a drawing surface. In mode B you pass yucad the HDC of the area you want the frame copied into.

Which mode?

CadWndCreateCadWin*
Window ownershipyucad (child HWND)host
Input loopyucad handles ithost forwards via CadWinMouse
Best fordrop-in Vecad replacement, least host code hosts that fully own their surface / compositing
RenderingOpenGL to child windowOpenGL offscreen → blit to HDC

Zoom, pan & navigation

The CadZoom* and CadView* families drive the viewport programmatically — zoom to extents, to a window, to a scale, and pan. In the library-owned viewport these also respond to mouse wheel and drag automatically.