.
, , DC, , , , .
http://glscene.cvs.sourceforge.net/viewvc/glscene/Source/Platform/GLWin32Viewer.pas?view=log, , GLScene , OpenGL.
DC CreateParams + :
with Params do begin
Style:=Style or WS_CLIPCHILDREN or WS_CLIPSIBLINGS;
WindowClass.Style:=WindowClass.Style or CS_OWNDC;
end;
DC CreateWnd DestroyWnd
After you have DC, you need to make sure that PixelFormat supports OpenGL +, has the necessary information:
const pfd: PIXELFORMATDESCRIPTOR = (
nSize: sizeof(PIXELFORMATDESCRIPTOR);
nVersion: 1; // version
dwFlags: PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
iPixelType: PFD_TYPE_RGBA;
cColorBits: 24; // 24-bit color depth
cRedBits: 0;
cRedShift: 0;
cGreenBits: 0;
cGreenShift: 0;
cBlueBits: 0;
cBlueShift: 0;
cAlphaBits: 8; // alpha bits
cAlphaShift: 0;
cAccumBits: 0; // accumulation buffer
cAccumRedBits: 0;
cAccumGreenBits: 0;
cAccumBlueBits: 0;
cAccumAlphaBits: 0;
cDepthBits: 32; // z-buffer
cStencilBits: 16; // stencil buffer
cAuxBuffers: 0; // auxiliary buffer
iLayerType: PFD_MAIN_PLANE; // main layer
bReserved: 0;
dwLayerMask: 0;
dwVisibleMask: 0;
dwDamageMask: 0
);
var
pf: Integer;
begin
pf := ChoosePixelFormat(dc, @pfd);
if not SetPixelFormat(dc, pf, @pfd) then
Assert(false);//failed, could retry with other settings
rc := wglCreateContext(dc);
if not wglMakeCurrent(dc, rc) then
Assert(false);// failed
// we should now have a rc so to test, we'll just clear
glClearColor(1, 0.5, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
// If we're double-buffered, then swap
SwapBuffers(dc);
wglMakeCurrent(0, 0);
After you have finished using RC, you should also clear it by calling wglDeleteContext.
source
share