File: util.inc

package info (click to toggle)
pyopengl 2.0.1.08-5.1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 19,484 kB
  • ctags: 9,036
  • sloc: pascal: 64,950; xml: 28,088; ansic: 20,696; python: 19,761; tcl: 668; makefile: 240; sh: 25
file content (47 lines) | stat: -rw-r--r-- 960 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
%include util.inc

#define CONST const
typedef long HDC;
typedef long HGLRC;
typedef unsigned int UINT;
typedef long HENHMETAFILE;
typedef void VOID;
typedef unsigned int DWORD;
typedef unsigned short WORD;
typedef float FLOAT;
typedef double DOUBLE;
typedef int BOOL;
typedef unsigned char BYTE;
typedef DWORD COLORREF;
typedef const char *LPCSTR;
typedef long PROC;

%{
#if PY_MAJOR_VERSION < 2
#define PyExc_WindowsError PyExc_OSError
#endif

int WGLErrOccurred()
{
	DWORD error = GetLastError();
	if (error != ERROR_SUCCESS)
	{
		LPSTR buffer;
		FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, error, 0, (LPSTR)&buffer, 0, NULL);
		PyErr_SetObject(PyExc_WindowsError, Py_BuildValue("is", error, buffer));
		LocalFree(buffer);
		return 1;
	}

	return 0;
}
%}


#define WGL_EXCEPTION_HANDLER()\
%except\
{\
	SetLastError(0);\
	$function\
	if (WGLErrOccurred()) return NULL;\
}