glcanvas attribList

21 views
Skip to first unread message

R Fritz

unread,
Nov 13, 2009, 2:32:34 AM11/13/09
to wxPython-users
I'm looking for a good example of how this is used. The WxWidgets docs
indicate that it's supposed to be a 0-terminated array of integers. Is
the wxPython version supposed to be a Python list or a Python array?
Is the zero still required, or does wxPython automatically provide it?

While I'm waiting for the source to download so that I can go digging,
I figure I'll ask.

Robin Dunn

unread,
Nov 13, 2009, 1:52:46 PM11/13/09
to wxpytho...@googlegroups.com
On 11/12/09 11:32 PM, R Fritz wrote:
>
> I'm looking for a good example of how this is used. The WxWidgets docs
> indicate that it's supposed to be a 0-terminated array of integers. Is
> the wxPython version supposed to be a Python list or a Python array?
> Is the zero still required, or does wxPython automatically provide it?

Any python sequence will work, and wxPython will add the terminating
zero for you. Here are the typemaps used for that parameter:


%typemap(in) int *attribList (int *temp) {
int i;
if (PySequence_Check($input)) {
int size = PyObject_Length($input);
temp = new int[size+1];
for (i = 0; i < size; i++) {
temp[i] = PyInt_AsLong(PySequence_GetItem($input, i));
}
temp[size] = 0;
$1 = temp;
}
}

%typemap(freearg) int *attribList
{
delete [] $1;
}

--
Robin Dunn
Software Craftsman
http://wxPython.org

R Fritz

unread,
Nov 13, 2009, 3:38:47 PM11/13/09
to wxPython-users
Thank you. Now maybe I can get my WxPython/OpenSceneGraph app going
on Mac.

Randolph

R Fritz

unread,
Nov 14, 2009, 7:21:48 PM11/14/09
to wxPython-users
Thank you. I wrote the following for use with my OSG code, following
the model of OSG's viewerWX:
@staticmethod
def gen_OpenGL_attributes():
return [
wx.glcanvas.WX_GL_DOUBLEBUFFER,
wx.glcanvas.WX_GL_RGBA,
wx.glcanvas.WX_GL_DEPTH_SIZE, 8,
wx.glcanvas.WX_GL_STENCIL_SIZE, 8]


For the interested, I found that WxWidgets maps those constants to the
local OpenGL environment's constants in the appropriate glcanvas.cpp.
So, for instance, in the Mac Carbon environment, those attributes are
translated to AGL_DOUBLEBUFFER, AGL_RGBA, AGL_DEPTH_SIZE, and
AGL_STENCIL_SIZE.

However, my problem turned out to be somewhat different; it turns out
that the OpenGL canvas width and height are initially returned as
(0,0) on the Mac, and passing those values to
osgViewer::Viewer::setUpViewerAsEmbeddedInWindow confused the OSG
camera it in a way that later resizes would not reset. Hacking the
code to pass an initial (1,1) as the width and height made it work...I
hope.
Reply all
Reply to author
Forward
0 new messages