I have an example program in PyQt5
I have a class:
class QGLControllerWidget(QtOpenGL.QGLWidget):
...
And a main program:
app = QtWidgets.QApplication([])
window = QGLControllerWidget() # this is my class
window.show() # I want to center the window on the screen
app.exec_()
Currently the window's location is somewhere between the center and the bottom right corner, please see the image:
How to center the window/widget on the screen in PyQt5?
03_alpha_blending.py
import struct
from PyQt5 import QtCore, QtOpenGL, QtWidgets
import ModernGL
class QGLControllerWidget(QtOpenGL.QGLWidget):
def __init__(self):
fmt = QtOpenGL.QGLFormat()
fmt.setVersion(3, 3)
fmt.setProfile(QtOpenGL.QGLFormat.CoreProfile)
fmt.setSampleBuffers(True)
self.timer = QtCore.QElapsedTimer()
super(QGLControllerWidget, self).__init__(fmt, None)
def initializeGL(self):
self.ctx = ModernGL.create_context()
prog = self.ctx.program([
self.ctx.vertex_shader('''
#version 330
in vec2 vert;
in vec4 vert_color;
out vec4 frag_color;
uniform vec2 scale;
uniform float rotation;
void main() {
frag_color = vert_color;
float r = rotation * (0.5 + gl_InstanceID * 0.05);
mat2 rot = mat2(cos(r), sin(r), -sin(r), cos(r));
gl_Position = vec4((rot * vert) * scale, 0.0, 1.0);
}
'''),
self.ctx.fragment_shader('''
#version 330
in vec4 frag_color;
out vec4 color;
void main() {
color = vec4(frag_color);
}
'''),
])
self.scale = prog.uniforms['scale']
self.rotation = prog.uniforms['rotation']
vbo = self.ctx.buffer(struct.pack(
'18f',
1.0, 0.0, 1.0, 0.0, 0.0, 0.5,
-0.5, 0.86, 0.0, 1.0, 0.0, 0.5,
-0.5, -0.86, 0.0, 0.0, 1.0, 0.5,
))
self.vao = self.ctx.simple_vertex_array(prog, vbo, ['vert', 'vert_color'])
self.timer.restart()
def paintGL(self):
self.ctx.viewport = (0, 0, self.width(), self.height())
self.ctx.clear(0.9, 0.9, 0.9)
self.scale.value = (self.height() / self.width() * 0.75, 0.75)
self.rotation.value = self.timer.elapsed() / 1000
self.ctx.enable(ModernGL.BLEND)
self.vao.render(instances=10)
self.ctx.finish()
self.update()
app = QtWidgets.QApplication([])
window = QGLControllerWidget()
window.show()
app.exec_()
You have to move the widget to the center of the screen, to know the size of the screen you must use QDesktopWidget, like the following:
app = QtWidgets.QApplication([])
window = QGLControllerWidget()
pos = QtWidgets.QDesktopWidget().rect().center() -window.rect().center()
window.move(pos)
window.show()
app.exec_()
Related
I'm considering switching to ModernGL over PyOpenGL, and I'm struggling to implement anything right now.
First of all, I would like to try the classic "triangle that changes shape using a time uniform and sine function", but I'm stuck on how to write to the uniform.
Here is what the documentation says about this:
A uniform is a global GLSL variable declared with the “uniform” storage qualifier. These act as
parameters that the user of a shader program can pass to that program.
In ModernGL, Uniforms can be accessed using Program.__getitem__() or Program.__iter__().
# Set a vec4 uniform
uniform['color'] = 1.0, 1.0, 1.0, 1.0
# Optionally we can store references to a member and set the value directly
uniform = program['color']
uniform.value = 1.0, 0.0, 0.0, 0.0
uniform = program['cameraMatrix']
uniform.write(camera_matrix)
This is my code:
import moderngl as mgl
import glfw
import numpy as np
import time
from math import sin
glfw.init()
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
window = glfw.create_window(800, 600, "__DELETEME__", None, None)
glfw.make_context_current(window)
context = mgl.create_context()
vertex_source = """
#version 330 core
in vec2 aPos;
uniform float time;
void main() {
gl_Position = vec4(aPos.x, aPos.y + sin(time), 0.0, 1.0);
}
"""
fragment_source = """
#version 330 core
out vec4 color;
void main(){
color = vec4(0.0, 0.0, 1.0, 1.0);
}
"""
program = context.program(vertex_shader=vertex_source, fragment_shader=fragment_source)
data = np.array([
0.5, 0,
-0.5, 0,
0, 0.5], dtype = "float32")
vbo = context.buffer(data.tobytes())
vao = context.vertex_array(program, vbo, "aPos")
uniform = program["time"]
uniform.value = 1.0
while not glfw.window_should_close(window):
now = time.time()
vao.render()
elapsed = time.time() - now
glfw.poll_events()
glfw.swap_buffers(window)
glfw.terminate()
Now it draws nothing. What am I doing wrong? Thanks!
The elapsed time is the difference between the start time and the current time. Get the start time before the application loop and compute the elapsed time in the loop in every frame:
start_time = time.time()
while not glfw.window_should_close(window):
elapsed = time.time() - start_time
# [...]
The value of the uniform "time" has to be updated continuously in the loop:
while not glfw.window_should_close(window):
# [...]
uniform.value = elapsed
You have to clear the display in every frame, in the application loop (See ModernGL Context):
while not glfw.window_should_close(window):
# [...]
context.clear(0.0, 0.0, 0.0)
vao.render()
Complete example:
import moderngl as mgl
import glfw
import numpy as np
import time
from math import sin
glfw.init()
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3)
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
window = glfw.create_window(800, 600, "__DELETEME__", None, None)
glfw.make_context_current(window)
context = mgl.create_context()
vertex_source = """
#version 330 core
in vec2 aPos;
uniform float time;
void main() {
gl_Position = vec4(aPos.x, aPos.y + sin(time), 0.0, 1.0);
}
"""
fragment_source = """
#version 330 core
out vec4 color;
void main(){
color = vec4(0.0, 0.0, 1.0, 1.0);
}
"""
program = context.program(vertex_shader=vertex_source, fragment_shader=fragment_source)
data = np.array([
0.5, 0,
-0.5, 0,
0, 0.5], dtype = "float32")
vbo = context.buffer(data.tobytes())
vao = context.vertex_array(program, vbo, "aPos")
uniform = program["time"]
uniform.value = 1.0
start_time = time.time()
while not glfw.window_should_close(window):
elapsed = time.time() - start_time
uniform.value = elapsed
context.clear(0.0, 0.0, 0.0)
vao.render()
glfw.poll_events()
glfw.swap_buffers(window)
glfw.terminate()
I am using the following code to render a rectangle on screen, using moderngl and moderngl_window. This is mostly derived from their examples:
import moderngl
import moderngl_window as mglw
import glfw
import numpy as np
import OpenGL.GL
import OpenGL.GLUT
import OpenGL.GLU
class MyWin(mglw.WindowConfig):
gl_version = (3, 3)
title = "Hello World"
window_size = (1280, 720)
aspect_ratio = 16/9;
resizable = True
samples = 4
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.prog = self.ctx.program(
vertex_shader='''
#version 330
in vec2 vert;
void main() {
gl_Position = vec4(vert.x, vert.y*1.7777, 0.0, 1.0);
}
''',
fragment_shader='''
#version 330
out vec4 color;
void main() {
color = vec4(0.3, 0.5, 1.0, 1.0);
}
''',
)
self.vertices = np.array([
-0.8, 0.8,
-0.8, -0.8,
0.8, -0.8,
0.8, 0.8,
-0.8, 0.8,
0.8,-0.8
])
self.vbo = self.ctx.buffer(self.vertices.astype('f4').tobytes())
# self.texCoordBuffer = self.ctx.buffer(texCoord.astype('f4').tobytes());
self.vao = self.ctx.simple_vertex_array(self.prog, self.vbo, 'vert');
# self.vao.bind(1,'f',self.texCoordBuffer,'2f');
# self.time = self.prog['time'];
#classmethod
def setVertices(self, vertices):
print("vertices have been set")
self.vertices = vertices
#classmethod
def run(cls):
mglw.run_window_config(cls);
def render(self, time, frame_time):
# self.time.value = time
self.ctx.clear(0.0, 0.0, 0.0)
self.vao.render()
but I can't figure out what function I need to call with moderngl to set the rendering mode to GL_LINES instead of GL_TRIANGLES
I think I need to call glDrawArraysbut I can't find how to access it with moderngl.
Thanks for your help!
You can choose the Primitive type by setting the mode argument when you invoke moderngl.VertexArray.render(). The default argument is TRIANGLES. Set the mode LINES for the primitive type GL_LINES:
self.vao.render()
self.vao.render(moderngl.LINES)
I am writing a python application using Kivy for rendering some graphics. I would like to find out how to get access to the current modelview matrix within kivy, the same matrix as in the vertex shader.
Here is my example code (Python 2.7, Kivy 1.9):
#!/usr/bin/env python
from kivy.app import App
from kivy.clock import Clock
from kivy.core.window import Window
from kivy.graphics import *
from kivy.graphics.transformation import Matrix
from kivy.resources import resource_find
from kivy.uix.widget import Widget
vertices = [0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
2.0, 0.0, 0.0, 0.0, 0.0, 1.0,
0.0, 2.0, 0.0, 0.0, 0.0, 1.0,
2.0, 2.0, 0.0, 0.0, 0.0, 1.0]
indices = [0, 1, 2, 1, 2, 3]
vformat = [(b'v_pos', 3, 'float'), (b'v_normal', 3, 'float')]
class Renderer(Widget):
def __init__(self, **kwargs):
super(Renderer, self).__init__(**kwargs)
self.canvas = RenderContext(compute_normal_mat=True)
self.canvas.shader.source = resource_find('simple.glsl')
with self.canvas:
PushMatrix()
Translate(0, -1, -3)
self.rot = Rotate(1, 0, 1, 0)
UpdateNormalMatrix()
self.mesh = Mesh(vertices=vertices, indices=indices,
fmt=vformat, mode='triangles')
PopMatrix()
Clock.schedule_interval(self.update_glsl, 1 / 60.)
def update_glsl(self, delta):
asp = self.width / float(self.height)
proj = Matrix().view_clip(-asp, asp, -1, 1, 1, 100, 1)
self.canvas['projection_mat'] = proj
self.rot.angle += delta * 100
print self.canvas['modelview_mat']
class RendererApp(App):
def build(self):
return Renderer()
if __name__ == "__main__":
RendererApp().run()
and the shader file simple.glsl:
---VERTEX SHADER-----------------------------------
attribute vec3 v_pos;
attribute vec3 v_normal;
uniform mat4 modelview_mat;
uniform mat4 projection_mat;
varying vec4 normal_vec;
void main (void) {
normal_vec = vec4(v_normal, 0.0);
gl_Position = projection_mat * modelview_mat * vec4(v_pos, 1.0);
}
---FRAGMENT SHADER---------------------------------
uniform mat4 normal_mat;
varying vec4 normal_vec;
void main (void){
vec4 v_normal = normalize( normal_mat * normal_vec ) ;
float theta = clamp(abs(dot(v_normal, vec4(0.0, 0.0, 1.0, 1.0))), 0.0, 1.0);
gl_FragColor = vec4(theta, theta, theta, 1.0);
}
In the function update_glsl I need the current modelview matrix for some calculations. I tried self.canvas['modelview_mat'], but this give me always the identity matrix.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I am looking for a simple modern OpenGL (3.2+)example in Python.
I tried with GLUT and freeGLUT, but I am not able to get a 3.2 context on OS X (Mavericks). (This seems to be a known issue with GLUT/freeGLUT).
GLFW seems to be a modern lightweight alternative to GLUT, but it doesn't seem to have an official Python binding, and I could not find a simple example that uses 3.2 core profile features of OpenGL with GLFW and Python.
(I struggled with this problem, and so it could be useful for others, I am answering below as per SO guidelines.)
The code below uses PyOpenGL, PIL (for textures), numpy, GLFW and the corresponding Python binding cyglfw3.
Here is a screenshot of the output:
The main code is appended below. It uses some utility methods from a file called glutils.py (for loading texture, compiling shaders, etc.) which you can find here:
https://github.com/electronut/pp/tree/master/simplegl
Code listing follows:
import OpenGL
from OpenGL.GL import *
from OpenGL.GLUT import *
import numpy, math, sys, os
import glutils
import cyglfw3 as glfw
strVS = """
#version 330 core
layout(location = 0) in vec3 aVert;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
uniform vec4 uColor;
uniform float uTheta;
out vec4 vCol;
out vec2 vTexCoord;
void main() {
// rotational transform
mat4 rot = mat4(
vec4( cos(uTheta), sin(uTheta), 0.0, 0.0),
vec4(-sin(uTheta), cos(uTheta), 0.0, 0.0),
vec4(0.0, 0.0, 1.0, 0.0),
vec4(0.0, 0.0, 0.0, 1.0)
);
// transform vertex
gl_Position = uPMatrix * uMVMatrix * rot * vec4(aVert, 1.0);
// set color
vCol = vec4(uColor.rgb, 1.0);
// set texture coord
vTexCoord = aVert.xy + vec2(0.5, 0.5);
}
"""
strFS = """
#version 330 core
in vec4 vCol;
in vec2 vTexCoord;
uniform sampler2D tex2D;
uniform bool showCircle;
out vec4 fragColor;
void main() {
if (showCircle) {
// discard fragment outside circle
if (distance(vTexCoord, vec2(0.5, 0.5)) > 0.5) {
discard;
}
else {
fragColor = texture(tex2D, vTexCoord);
}
}
else {
fragColor = texture(tex2D, vTexCoord);
}
}
"""
class Scene:
""" OpenGL 3D scene class"""
# initialization
def __init__(self):
# create shader
self.program = glutils.loadShaders(strVS, strFS)
glUseProgram(self.program)
self.pMatrixUniform = glGetUniformLocation(self.program,
'uPMatrix')
self.mvMatrixUniform = glGetUniformLocation(self.program,
"uMVMatrix")
self.colorU = glGetUniformLocation(self.program, "uColor")
# color
self.col0 = [1.0, 0.0, 0.0, 1.0]
# texture
self.tex2D = glGetUniformLocation(self.program, "tex2D")
# define quad vertices
quadV = [
-0.5, -0.5, 0.0,
0.5, -0.5, 0.0,
-0.5, 0.5, 0.0,
0.5, 0.5, 0.0
]
# set up vertex array object (VAO)
self.vao = glGenVertexArrays(1)
glBindVertexArray(self.vao)
# vertices
self.vertexBuffer = glGenBuffers(1)
glBindBuffer(GL_ARRAY_BUFFER, self.vertexBuffer)
vertexData = numpy.array(quadV, numpy.float32)
glBufferData(GL_ARRAY_BUFFER, 4*len(vertexData), vertexData,
GL_STATIC_DRAW)
# enable vertex array
glEnableVertexAttribArray(0)
# set buffer data
glBindBuffer(GL_ARRAY_BUFFER, self.vertexBuffer)
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, None)
# unbind VAO
glBindVertexArray(0)
# time
self.t = 0
# texture
self.texId = glutils.loadTexture('test.png')
# show circle?
self.showCircle = False
# step
def step(self):
# increment angle
self.t = (self.t + 1) % 360
# set shader angle in radians
glUniform1f(glGetUniformLocation(self.program, 'uTheta'),
math.radians(self.t))
# render
def render(self, pMatrix, mvMatrix):
# use shader
glUseProgram(self.program)
# set proj matrix
glUniformMatrix4fv(self.pMatrixUniform, 1, GL_FALSE, pMatrix)
# set modelview matrix
glUniformMatrix4fv(self.mvMatrixUniform, 1, GL_FALSE, mvMatrix)
# show circle?
glUniform1i(glGetUniformLocation(self.program, 'showCircle'),
self.showCircle)
# enable texture
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, self.texId)
glUniform1i(self.tex2D, 0)
# bind VAO
glBindVertexArray(self.vao)
# draw
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)
# unbind VAO
glBindVertexArray(0)
class RenderWindow:
"""GLFW Rendering window class"""
def __init__(self):
# save current working directory
cwd = os.getcwd()
# initialize glfw - this changes cwd
glfw.Init()
# restore cwd
os.chdir(cwd)
# version hints
glfw.WindowHint(glfw.CONTEXT_VERSION_MAJOR, 3)
glfw.WindowHint(glfw.CONTEXT_VERSION_MINOR, 3)
glfw.WindowHint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE)
glfw.WindowHint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
# make a window
self.width, self.height = 640, 480
self.aspect = self.width/float(self.height)
self.win = glfw.CreateWindow(self.width, self.height, "test")
# make context current
glfw.MakeContextCurrent(self.win)
# initialize GL
glViewport(0, 0, self.width, self.height)
glEnable(GL_DEPTH_TEST)
glClearColor(0.5, 0.5, 0.5,1.0)
# set window callbacks
glfw.SetMouseButtonCallback(self.win, self.onMouseButton)
glfw.SetKeyCallback(self.win, self.onKeyboard)
glfw.SetWindowSizeCallback(self.win, self.onSize)
# create 3D
self.scene = Scene()
# exit flag
self.exitNow = False
def onMouseButton(self, win, button, action, mods):
#print 'mouse button: ', win, button, action, mods
pass
def onKeyboard(self, win, key, scancode, action, mods):
#print 'keyboard: ', win, key, scancode, action, mods
if action == glfw.PRESS:
# ESC to quit
if key == glfw.KEY_ESCAPE:
self.exitNow = True
else:
# toggle cut
self.scene.showCircle = not self.scene.showCircle
def onSize(self, win, width, height):
#print 'onsize: ', win, width, height
self.width = width
self.height = height
self.aspect = width/float(height)
glViewport(0, 0, self.width, self.height)
def run(self):
# initializer timer
glfw.SetTime(0.0)
t = 0.0
while not glfw.WindowShouldClose(self.win) and not self.exitNow:
# update every x seconds
currT = glfw.GetTime()
if currT - t > 0.1:
# update time
t = currT
# clear
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
# build projection matrix
pMatrix = glutils.perspective(45.0, self.aspect, 0.1, 100.0)
mvMatrix = glutils.lookAt([0.0, 0.0, -2.0], [0.0, 0.0, 0.0],
[0.0, 1.0, 0.0])
# render
self.scene.render(pMatrix, mvMatrix)
# step
self.scene.step()
glfw.SwapBuffers(self.win)
# Poll for and process events
glfw.PollEvents()
# end
glfw.Terminate()
# main() function
def main():
print 'starting simpleglfw...'
rw = RenderWindow()
rw.run()
# call main
if __name__ == '__main__':
main()
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am having trouble passing projection and modelview matrices into the GLSL shader from my PyOpenGL code. My understanding is that OpenGL matrices are column major, but when I pass in projection and modelview matrices as shown, I don't see anything. I tried the transpose of the matrices, and it worked for the modelview matrix, but the projection matrix doesn't work either way. Here is the code:
import OpenGL
from OpenGL.GL import *
from OpenGL.GL.shaders import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
from OpenGL.GLUT.freeglut import *
from OpenGL.arrays import vbo
import numpy, math, sys
strVS = """
attribute vec3 aVert;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
uniform vec4 uColor;
varying vec4 vCol;
void main() {
// option #1 - fails
gl_Position = uPMatrix * uMVMatrix * vec4(aVert, 1.0);
// option #2 - works
gl_Position = vec4(aVert, 1.0);
// set color
vCol = vec4(uColor.rgb, 1.0);
}
"""
strFS = """
varying vec4 vCol;
void main() {
// use vertex color
gl_FragColor = vCol;
}
"""
# 3D scene
class Scene:
# initialization
def __init__(self):
# create shader
self.program = compileProgram(compileShader(strVS,
GL_VERTEX_SHADER),
compileShader(strFS,
GL_FRAGMENT_SHADER))
glUseProgram(self.program)
self.pMatrixUniform = glGetUniformLocation(self.program, 'uPMatrix')
self.mvMatrixUniform = glGetUniformLocation(self.program,
"uMVMatrix")
self.colorU = glGetUniformLocation(self.program, "uColor")
# attributes
self.vertIndex = glGetAttribLocation(self.program, "aVert")
# color
self.col0 = [1.0, 1.0, 0.0, 1.0]
# define quad vertices
s = 0.2
quadV = [
-s, s, 0.0,
-s, -s, 0.0,
s, s, 0.0,
s, s, 0.0,
-s, -s, 0.0,
s, -s, 0.0
]
# vertices
self.vertexBuffer = glGenBuffers(1)
glBindBuffer(GL_ARRAY_BUFFER, self.vertexBuffer)
vertexData = numpy.array(quadV, numpy.float32)
glBufferData(GL_ARRAY_BUFFER, 4*len(vertexData), vertexData,
GL_STATIC_DRAW)
# render
def render(self, pMatrix, mvMatrix):
# use shader
glUseProgram(self.program)
# set proj matrix
glUniformMatrix4fv(self.pMatrixUniform, 1, GL_FALSE, pMatrix)
# set modelview matrix
glUniformMatrix4fv(self.mvMatrixUniform, 1, GL_FALSE, mvMatrix)
# set color
glUniform4fv(self.colorU, 1, self.col0)
#enable arrays
glEnableVertexAttribArray(self.vertIndex)
# set buffers
glBindBuffer(GL_ARRAY_BUFFER, self.vertexBuffer)
glVertexAttribPointer(self.vertIndex, 3, GL_FLOAT, GL_FALSE, 0, None)
# draw
glDrawArrays(GL_TRIANGLES, 0, 6)
# disable arrays
glDisableVertexAttribArray(self.vertIndex)
class Renderer:
def __init__(self):
pass
def reshape(self, width, height):
self.width = width
self.height = height
self.aspect = width/float(height)
glViewport(0, 0, self.width, self.height)
glEnable(GL_DEPTH_TEST)
glDisable(GL_CULL_FACE)
glClearColor(0.8, 0.8, 0.8,1.0)
glutPostRedisplay()
def keyPressed(self, *args):
sys.exit()
def draw(self):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
# build projection matrix
fov = math.radians(45.0)
f = 1.0/math.tan(fov/2.0)
zN, zF = (0.1, 100.0)
a = self.aspect
pMatrix = numpy.array([f/a, 0.0, 0.0, 0.0,
0.0, f, 0.0, 0.0,
0.0, 0.0, (zF+zN)/(zN-zF), -1.0,
0.0, 0.0, 2.0*zF*zN/(zN-zF), 0.0], numpy.float32)
# modelview matrix
mvMatrix = numpy.array([1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.5, 0.0, -5.0, 1.0], numpy.float32)
# render
self.scene.render(pMatrix, mvMatrix)
# swap buffers
glutSwapBuffers()
def run(self):
glutInitDisplayMode(GLUT_RGBA)
glutInitWindowSize(400, 400)
self.window = glutCreateWindow("Minimal")
glutReshapeFunc(self.reshape)
glutDisplayFunc(self.draw)
glutKeyboardFunc(self.keyPressed) # Checks for key strokes
self.scene = Scene()
glutMainLoop()
glutInit(sys.argv)
prog = Renderer()
prog.run()
When I use option #2 in the shader without either matrix, I get the following output:
What am I doing wrong?