Re: Problems with simple pyopengl program
"Mike C. Fletcher" <[email protected]>
| Newsgroups | gmane.comp.python.opengl.user |
|---|---|
| Message-ID | <[email protected]> |
On 12-02-22 07:47 PM, James Gao wrote:
> Hi everyone,
> I'm trying to get a very very simple pass-through shader to work in
> pyopengl. I compiled and tested a simple C program, available here:
> http://pastebin.com/FGVxUUXH
> This program works exactly as expected -- a red plane is drawn,
> completely covering the screen.
>
> I tried to make the *exact* duplicate of this C program here:
> http://pastebin.com/dYbbXTY1
> This apparently does not work. Only the gray glClear color is
> displayed, and the two triangles are never drawn.
>
> Any insight into why this isn't working?
You need to modify the calls which are using voidp offsets to explicitly
create GLvoidp instances, the integer 0 values are being interpreted as
single-value arrays and the result is a useless offset:
glVertexAttribPointer( posidx, 2, GL_FLOAT, GL_FALSE, 4*2, GLvoidp(0))
# Draw the two triangles
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebuf);
glDrawElements(
GL_TRIANGLES, # mode
6, # count
GL_UNSIGNED_SHORT, # type
GLvoidp(0) # element array buffer offset
)
This is a mis-feature of the wrapping in PyOpenGL allowing you to pass
in an integer where an array is expected.
HTH,
Mike
--
________________________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://www.vrplumber.com
http://blog.vrplumber.com
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net