Merge pull request #390 from openscad/win64offscreen

enable cmdline offscreen rendering with win64- fix ambiguous unicode stu...
felipesanches-svg
Marius Kintel 2013-06-06 12:32:29 -07:00
commit 2db5b5f856
1 changed files with 28 additions and 5 deletions

View File

@ -108,15 +108,33 @@ bool create_wgl_dummy_context(OffscreenContext &ctx)
wc.style = CS_OWNDC; wc.style = CS_OWNDC;
wc.lpfnWndProc = WndProc; wc.lpfnWndProc = WndProc;
wc.hInstance = inst; wc.hInstance = inst;
wc.lpszClassName = (LPCWSTR)"OpenSCAD"; wc.lpszClassName = L"OpenSCAD";
RegisterClass( &wc ); ATOM class_atom = RegisterClassW( &wc );
HWND window = CreateWindow( (LPCWSTR)"OpenSCAD", (LPCWSTR)"OpenSCAD", if ( class_atom == 0 ) {
WS_CAPTION | WS_POPUPWINDOW, //| WS_VISIBLE, cerr << "MS GDI - RegisterClass failed\n";
0, 0, ctx.width, ctx.height, NULL, NULL, inst, NULL ); cerr << "last-error code: " << GetLastError() << "\n";
return false;
}
LPCTSTR lpClassName = L"OpenSCAD";
LPCTSTR lpWindowName = L"OpenSCAD";
DWORD dwStyle = WS_CAPTION | WS_POPUPWINDOW; // | WS_VISIBLE
int x = 0;
int y = 0;
int nWidth = ctx.width;
int nHeight = ctx.height;
HWND hWndParent = NULL;
HMENU hMenu = NULL;
HINSTANCE hInstance = inst;
LPVOID lpParam = NULL;
HWND window = CreateWindowW( lpClassName, lpWindowName, dwStyle, x, y,
nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam );
if ( window==NULL ) { if ( window==NULL ) {
cerr << "MS GDI - CreateWindow failed\n"; cerr << "MS GDI - CreateWindow failed\n";
cerr << "last-error code: " << GetLastError() << "\n";
return false; return false;
} }
@ -127,6 +145,7 @@ bool create_wgl_dummy_context(OffscreenContext &ctx)
HDC dev_context = GetDC( window ); HDC dev_context = GetDC( window );
if ( dev_context == NULL ) { if ( dev_context == NULL ) {
cerr << "MS GDI - GetDC failed\n"; cerr << "MS GDI - GetDC failed\n";
cerr << "last-error code: " << GetLastError() << "\n";
return false; return false;
} }
@ -145,18 +164,21 @@ bool create_wgl_dummy_context(OffscreenContext &ctx)
chosenformat = ChoosePixelFormat( dev_context, &pixformat ); chosenformat = ChoosePixelFormat( dev_context, &pixformat );
if (chosenformat==0) { if (chosenformat==0) {
cerr << "MS GDI - ChoosePixelFormat failed\n"; cerr << "MS GDI - ChoosePixelFormat failed\n";
cerr << "last-error code: " << GetLastError() << "\n";
return false; return false;
} }
bool spfok = SetPixelFormat( dev_context, chosenformat, &pixformat ); bool spfok = SetPixelFormat( dev_context, chosenformat, &pixformat );
if (!spfok) { if (!spfok) {
cerr << "MS GDI - SetPixelFormat failed\n"; cerr << "MS GDI - SetPixelFormat failed\n";
cerr << "last-error code: " << GetLastError() << "\n";
return false; return false;
} }
HGLRC gl_render_context = wglCreateContext( dev_context ); HGLRC gl_render_context = wglCreateContext( dev_context );
if ( gl_render_context == NULL ) { if ( gl_render_context == NULL ) {
cerr << "MS WGL - wglCreateContext failed\n"; cerr << "MS WGL - wglCreateContext failed\n";
cerr << "last-error code: " << GetLastError() << "\n";
ReleaseDC( ctx.window, ctx.dev_context ); ReleaseDC( ctx.window, ctx.dev_context );
return false; return false;
} }
@ -164,6 +186,7 @@ bool create_wgl_dummy_context(OffscreenContext &ctx)
bool mcok = wglMakeCurrent( dev_context, gl_render_context ); bool mcok = wglMakeCurrent( dev_context, gl_render_context );
if (!mcok) { if (!mcok) {
cerr << "MS WGL - wglMakeCurrent failed\n"; cerr << "MS WGL - wglMakeCurrent failed\n";
cerr << "last-error code: " << GetLastError() << "\n";
return false; return false;
} }