I'm trying to create an OpenGL context for rendering
to an offscreen bitmap.
The attached program gets as far as trying to call
wglCreateContext, then fails with
WindowsError: [Errno 8] Not enough storage is available to
process this command.
Can anyone see what's going wrong here?
Thanks,
Greg
import win32con as wc, win32ui as ui, win32gui as gui
from OpenGL import WGL as wgl
def main():
# Create device context and bitmap
win = ui.CreateFrame()
win.CreateWindow(None, "", 0, (0, 0, 1, 1), None, None, 0, 0)
dc0 = win.GetDC()
dc = dc0.CreateCompatibleDC(dc0)
bm = ui.CreateBitmap()
bm.CreateCompatibleBitmap(dc0, 10, 10)
dc.SelectObject(bm)
hdc = dc.GetSafeHdc()
print "Bitmap:"
dump_bitmap(bm)
# Create pixel format descriptor
flags = wgl.PFD_SUPPORT_OPENGL | wgl.PFD_DRAW_TO_BITMAP #|
wgl.PFD_SUPPORT_GDI
pf = wgl.PIXELFORMATDESCRIPTOR()
pf.dwFlags = flags & 0xffffffff
pf.cColorBits = 32
pf.iLayerType = wgl.PFD_MAIN_PLANE
# Choose pixel format
ipf = wgl.ChoosePixelFormat(hdc, pf)
print "Using pixel format no.", ipf
pf2 = wgl.PIXELFORMATDESCRIPTOR()
wgl.DescribePixelFormat(hdc, ipf, pf2.nSize, pf2)
print "Pixel format chosen:"
dump_pixelformat(pf2)
# Set pixel format and create opengl context
print "Setting pixel format"
wgl.SetPixelFormat(hdc, ipf, pf2)
print "Creating opengl context"
ctx = wgl.wglCreateContext(hdc)
print "Context created"
def dump_pixelformat(pf):
print "nSize =", pf.nSize
print "nVersion =", pf.nVersion
print "dwFlags = 0x%08x" % pf.dwFlags
print "iPixelType =", pf.iPixelType
print "cColorBits =", pf.cColorBits
print "cRedBits =", pf.cRedBits
print "cRedShift =", pf.cRedShift
print "cGreenBits =", pf.cGreenBits
print "cGreenShift =", pf.cGreenShift
print "cBlueBits =", pf.cBlueBits
print "cBlueShift =", pf.cBlueShift
print "cAlphaBits =", pf.cAlphaBits
print "cAlphaShift =", pf.cAlphaShift
print "cAccumBits =", pf.cAccumBits
print "cAccumRedBits =", pf.cAccumRedBits
print "cAccumGreenBits =", pf.cAccumGreenBits
print "cAccumBlueBits =", pf.cAccumBlueBits
print "cDepthBits =", pf.cDepthBits
print "cStencilBits =", pf.cStencilBits
print "cAuxBuffers =", pf.cAuxBuffers
print "iLayerType =", pf.iLayerType
print "bReserved =", pf.bReserved
print "dwLayerMask =", pf.dwLayerMask
print "dwVisibleMask =", pf.dwVisibleMask
print "dwDamageMask =", pf.dwDamageMask
def dump_bitmap(bm):
info = bm.GetInfo()
print "bmType =", info['bmType']
print "bmWidth =", info['bmWidth']
print "bmHeight =", info['bmHeight']
print "bmWidthBytes =", info['bmWidthBytes']
print "bmPlanes =", info['bmPlanes']
print "bmBitsPixel =", info['bmBitsPixel']
main()
_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32