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);
- yucad owns
WM_PAINT, mouse and keyboard for the child — pan, wheel zoom, crosshair, interactive commands all work with no host plumbing. - Resize the host and the viewport follows; call
CadUpdate(hDwg)to force a repaint after programmatic changes. - This is the closest match to how Vecad's
CadWndCreatebehaves, so a migrating host keeps its window management unchanged.
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.
Which mode?
CadWndCreate | CadWin* | |
|---|---|---|
| Window ownership | yucad (child HWND) | host |
| Input loop | yucad handles it | host forwards via CadWinMouse |
| Best for | drop-in Vecad replacement, least host code | hosts that fully own their surface / compositing |
| Rendering | OpenGL to child window | OpenGL 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.