def visit_array(self, type, *args, **kwargs):
raise NotImplementedError
+ def visit_blob(self, type, *args, **kwargs):
+ raise NotImplementedError
+
def visit_enum(self, type, *args, **kwargs):
raise NotImplementedError
type = self.visit(array.type)
return Array(type, array.length)
+ def visit_blob(self, blob):
+ type = self.visit(blob.type)
+ return Blob(type, blob.size)
+
def visit_enum(self, enum):
return enum
class Array(Type):
def __init__(self, type, length):
- Type.__init__(self, type.expr + " *", 'P' + type.id)
+ Type.__init__(self, type.expr + " *")
self.type = type
self.length = length
return True
+class Blob(Type):
+
+ def __init__(self, type, size):
+ Type.__init__(self, type.expr + ' *')
+ self.type = type
+ self.size = size
+
+ def visit(self, visitor, *args, **kwargs):
+ return visitor.visit_blob(self, *args, **kwargs)
+
+ def dump(self, instance):
+ print ' Log::LiteralBlob(%s, %s);' % (instance, self.size)
+
+
class Struct(Concrete):
def __init__(self, name, members):
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef _GL_HELPERS_HPP_
+#define _GL_HELPERS_HPP_
+
+
+#include <cassert>
+
+static inline size_t
+__gl_image_size(GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth, GLint border) {
+ size_t bits_per_channel;
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ bits_per_channel = 8;
+ break;
+ default:
+ assert(0);
+ bits_per_channel = 0;
+ break;
+ }
+
+ size_t bits_per_pixel;
+ switch (format) {
+ case GL_RGB:
+ bits_per_pixel = bits_per_channel * 3;
+ break;
+ default:
+ assert(0);
+ bits_per_pixel = 0;
+ break;
+ }
+
+ size_t row_stride = (width*bits_per_pixel + 7)/8;
+
+ size_t slice_stride = height*row_stride;
+
+ return depth*slice_stride;
+}
+
+#endif /* _GL_HELPERS_HPP_ */
DllFunction(Void, "glTexParameterfv", [(GLenum, "target"), (GLenum, "pname"), (Pointer(Const(GLfloat)), "params")]),
DllFunction(Void, "glTexParameteri", [(GLenum, "target"), (GLenum, "pname"), (GLint, "param")]),
DllFunction(Void, "glTexParameteriv", [(GLenum, "target"), (GLenum, "pname"), (Pointer(Const(GLint)), "params")]),
- DllFunction(Void, "glTexImage1D", [(GLenum, "target"), (GLint, "level"), (GLint, "internalformat"), (GLsizei, "width"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Pointer(Const(GLvoid)), "pixels")]),
- DllFunction(Void, "glTexImage2D", [(GLenum, "target"), (GLint, "level"), (GLint, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Pointer(Const(GLvoid)), "pixels")]),
+ DllFunction(Void, "glTexImage1D", [(GLenum, "target"), (GLint, "level"), (GLint, "internalformat"), (GLsizei, "width"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__gl_image_size(format, type, width, 1, 1, border)"), "pixels")]),
+ DllFunction(Void, "glTexImage2D", [(GLenum, "target"), (GLint, "level"), (GLint, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__gl_image_size(format, type, width, height, 1, border)"), "pixels")]),
DllFunction(Void, "glTexEnvf", [(GLenum, "target"), (GLenum, "pname"), (GLfloat, "param")]),
DllFunction(Void, "glTexEnvfv", [(GLenum, "target"), (GLenum, "pname"), (Pointer(Const(GLfloat)), "params")]),
DllFunction(Void, "glTexEnvi", [(GLenum, "target"), (GLenum, "pname"), (GLint, "param")]),
DllFunction(Void, "glMinmax", [(GLenum, "target"), (GLenum, "internalformat"), (GLboolean, "sink")]),
DllFunction(Void, "glResetHistogram", [(GLenum, "target")]),
DllFunction(Void, "glResetMinmax", [(GLenum, "target")]),
- DllFunction(Void, "glTexImage3D", [(GLenum, "target"), (GLint, "level"), (GLint, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Pointer(Const(GLvoid)), "pixels")]),
+ DllFunction(Void, "glTexImage3D", [(GLenum, "target"), (GLint, "level"), (GLint, "internalformat"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLint, "border"), (GLenum, "format"), (GLenum, "type"), (Blob(Const(GLvoid), "__gl_image_size(format, type, width, height, depth, border)"), "pixels")]),
DllFunction(Void, "glTexSubImage3D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLsizei, "width"), (GLsizei, "height"), (GLsizei, "depth"), (GLenum, "format"), (GLenum, "type"), (Pointer(Const(GLvoid)), "pixels")]),
DllFunction(Void, "glCopyTexSubImage3D", [(GLenum, "target"), (GLint, "level"), (GLint, "xoffset"), (GLint, "yoffset"), (GLint, "zoffset"), (GLint, "x"), (GLint, "y"), (GLsizei, "width"), (GLsizei, "height")]),
DllFunction(Void, "glActiveTextureARB", [(GLenum, "texture")]),
print '#include <GL/glxext.h>'
print
print '#include "log.hpp"'
+ print '#include "glhelpers.hpp"'
print
print 'extern "C" {'
print