File: test_glgetactiveuniform.py

package info (click to toggle)
pyopengl 3.1.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 14,668 kB
  • sloc: python: 108,024; makefile: 4
file content (31 lines) | stat: -rw-r--r-- 830 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
from __future__ import print_function
import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GL.shaders import *
from OpenGL.GL.ARB.shader_objects import glGetActiveUniformARB

vertex_shader = """
uniform float scale;
void main(void)
{
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex * scale;
}
"""
def main():
    pygame.init()
    disp = pygame.display.set_mode((1024, 768), OPENGL | DOUBLEBUF)

    program = compileProgram(
        compileShader( vertex_shader, GL_VERTEX_SHADER )
    )

    nu = glGetProgramiv(program, GL_ACTIVE_UNIFORMS)
    for i in range(nu):
        name, size, type = glGetActiveUniform(program, i)
        print('CORE - ', name, size, type)
        glGetActiveUniformARB( program, i )
        print('ARB  - ', name, size, type)

if __name__ == "__main__":
    main()