Shader doesn't compile with Python 3

Matt Williams <[email protected]> Sun, 14 Apr 2013 14:19:31 +0100
Newsgroups gmane.comp.python.opengl.user
Message-ID <CAD2qLTCuZs=E8ACik450f=YF5Fe_BsWCAurD8O+d1vPu7R38nA@mail.gmail.com>
Hi all,

I'm really enjoying using PyOpenGL. I've just switched over to using
Python3 but I've hit a problem with compiling my shaders. As an example,
consider this code:

---------- test.py

from OpenGL.GL import shaders, GL_VERTEX_SHADER

import pygame
screen = pygame.display.set_mode((800, 800), pygame.OPENGL)

VERTEX_SHADER = shaders.compileShader("""
    #version 130

    void main()
    {
    }
    """, GL_VERTEX_SHADER)

----------

I'm running all this on Linux (openSUSE 12.3) with the following
configuration:

GL_RENDERER: GeForce GTX 560 Ti/PCIe/SSE2
GL_VERSION: 4.3.0 NVIDIA 313.30
GL_SHADING_LANGUAGE_VERSION: 4.30 NVIDIA via Cg compiler

If I run this code with 'python test.py' then it runs fine (briefly flashes
a window without complaint). However, when running under Python 3 with
'python3 test.py' it gives the following error:

----------

Traceback (most recent call last):
  File "./test.py", line 14, in <module>
    """, GL_VERTEX_SHADER)
  File
"/home/matt/.local/lib/python3.3/site-packages/OpenGL/GL/shaders.py", line
233, in compileShader
    shaderType,
RuntimeError: ('Shader compile failure (0):\n0(1) : error C0130: invalid
character literal\n0(1) : error C0000: syntax error, unexpected special
error tag, expecting "::" at token "<error>"\n0(1) : error C0130: invalid
character literal\n', [b'\n\t#version 130\n\t\n\tvoid
main()\n\t{\n\t}\n\t'], GL_VERTEX_SHADER)

----------

Given that the first error is 'invalid character literal', I'm assuming
that this is an encoding problem. It looks like (as far as I can tell)
PyOpenGL is sending an ASCII-encoded byte string but maybe that's not what
is expected?

Is anyone else seeing this problem or can reproduce this? Or does anyone
have an idea of the reason it's happening or a fix for it?

Regards,
Matt Williams

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter

_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyopengl-users