fixes most bugs
This commit is contained in:
parent
325da79fac
commit
dede00377e
7 changed files with 321 additions and 262 deletions
|
@ -15,7 +15,8 @@ class Light:
|
||||||
depthshaderId = -1
|
depthshaderId = -1
|
||||||
|
|
||||||
def getDepthProgram(self, vertexshader=-1, geometryshader=-1):
|
def getDepthProgram(self, vertexshader=-1, geometryshader=-1):
|
||||||
if ((vertexshader,geometryshader) not in self.programId.keys() and vertexshader != -1 and geometryshader != -1):
|
if ((
|
||||||
|
vertexshader, geometryshader) not in self.programId.keys() and vertexshader != -1 and geometryshader != -1):
|
||||||
if self.depthshaderId == -1:
|
if self.depthshaderId == -1:
|
||||||
with open('./Lights/depthfragment.glsl', 'r') as f:
|
with open('./Lights/depthfragment.glsl', 'r') as f:
|
||||||
fragment_shader_string = f.read()
|
fragment_shader_string = f.read()
|
||||||
|
@ -37,18 +38,18 @@ class Light:
|
||||||
return -1
|
return -1
|
||||||
return self.programId[(vertexshader, geometryshader)]
|
return self.programId[(vertexshader, geometryshader)]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._ModelviewProjectionMatrix = np.identity(4)
|
self._ModelviewProjectionMatrix = np.identity(4)
|
||||||
self._pos = [0, 0, 0]
|
self._pos = [0, 0, 0]
|
||||||
self._lightColor = [1, 1, 1]
|
self._lightColor = [1, 1, 1]
|
||||||
self.FramebufferId = -1
|
self.FramebufferId = -1
|
||||||
self.DepthBuffer = -1
|
self.DepthBuffer = -1
|
||||||
|
self.map_size = 1024
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lightColor(self):
|
def lightColor(self):
|
||||||
return self._lightColor
|
return self._lightColor
|
||||||
|
|
||||||
@lightColor.setter
|
@lightColor.setter
|
||||||
def lightColor(self, value):
|
def lightColor(self, value):
|
||||||
self._lightColor = value
|
self._lightColor = value
|
||||||
|
@ -76,15 +77,20 @@ class Light:
|
||||||
new = True
|
new = True
|
||||||
glClearColor(1.0, 1.0, 1.0, 1.0)
|
glClearColor(1.0, 1.0, 1.0, 1.0)
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, self.FramebufferId)
|
glBindFramebuffer(GL_FRAMEBUFFER, self.FramebufferId)
|
||||||
#glCullFace(GL_FRONT)
|
glCullFace(GL_FRONT)
|
||||||
glViewport(0, 0, 512, 512)
|
glViewport(0, 0, self.map_size, self.map_size)
|
||||||
if new:
|
if new:
|
||||||
if self.DepthBuffer == -1:
|
if self.DepthBuffer == -1:
|
||||||
self.DepthBuffer = glGenTextures(1)
|
self.DepthBuffer = glGenTextures(1)
|
||||||
glBindTexture(GL_TEXTURE_2D, self.DepthBuffer)
|
glBindTexture(GL_TEXTURE_2D, self.DepthBuffer)
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0,GL_DEPTH_COMPONENT, 512, 512, 0,GL_DEPTH_COMPONENT, GL_FLOAT, None)
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, self.map_size, self.map_size, 0, GL_DEPTH_COMPONENT, GL_FLOAT, None)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER)
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER)
|
||||||
|
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, np.array([0, 0, 0], dtype=np.float32))
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, self.FramebufferId, 0)
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, self.FramebufferId, 0)
|
||||||
|
|
||||||
DrawBuffers = [GL_NONE]
|
DrawBuffers = [GL_NONE]
|
||||||
|
@ -98,4 +104,3 @@ class Light:
|
||||||
glDrawBuffers(DrawBuffers)
|
glDrawBuffers(DrawBuffers)
|
||||||
glClearColor(0.0, 0.0, 0.0, 1.0)
|
glClearColor(0.0, 0.0, 0.0, 1.0)
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0)
|
glBindFramebuffer(GL_FRAMEBUFFER, 0)
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ def lookAt(eyeX,eyeY,eyeZ,cX,cY,cZ,upX,upY,upZ):
|
||||||
|
|
||||||
return np.transpose(mat)
|
return np.transpose(mat)
|
||||||
|
|
||||||
|
|
||||||
def orthogonalMatrix(r, l, t, b, f, n):
|
def orthogonalMatrix(r, l, t, b, f, n):
|
||||||
mat = np.matrix([
|
mat = np.matrix([
|
||||||
[2 / (r - l), 0, 0, -(r + l) / (r - l)],
|
[2 / (r - l), 0, 0, -(r + l) / (r - l)],
|
||||||
|
@ -42,6 +43,7 @@ def perspectiveMatrix(fovy,aspect,znear,zfar):
|
||||||
|
|
||||||
return np.transpose(mat)
|
return np.transpose(mat)
|
||||||
|
|
||||||
|
|
||||||
def translate(x, y, z):
|
def translate(x, y, z):
|
||||||
mat = np.matrix([[1, 0, 0, x],
|
mat = np.matrix([[1, 0, 0, x],
|
||||||
[0, 1, 0, y],
|
[0, 1, 0, y],
|
||||||
|
@ -50,16 +52,20 @@ def translate(x, y, z):
|
||||||
|
|
||||||
return np.transpose(mat)
|
return np.transpose(mat)
|
||||||
|
|
||||||
|
|
||||||
def rotate(x, y, z, d4=False):
|
def rotate(x, y, z, d4=False):
|
||||||
if not d4:
|
if not d4:
|
||||||
mat = np.matrix([[1, 0, 0], [0, math.cos(x), -math.sin(x)], [0, math.sin(x), math.cos(x)]], np.float32)
|
mat = np.matrix([[1, 0, 0], [0, math.cos(x), -math.sin(x)], [0, math.sin(x), math.cos(x)]], np.float32)
|
||||||
mat = mat * np.matrix([[math.cos(y), 0, -math.sin(y)], [0, 1, 0], [math.sin(y), 0, math.cos(y)]], np.float32)
|
mat = mat * np.matrix([[math.cos(y), 0, -math.sin(y)], [0, 1, 0], [math.sin(y), 0, math.cos(y)]], np.float32)
|
||||||
mat = mat * np.matrix([[math.cos(z), -math.sin(z), 0], [math.sin(z), math.cos(z), 0], [0, 0, 1]], np.float32)
|
mat = mat * np.matrix([[math.cos(z), -math.sin(z), 0], [math.sin(z), math.cos(z), 0], [0, 0, 1]], np.float32)
|
||||||
else:
|
else:
|
||||||
mat = np.matrix([[1, 0, 0, 0], [0, math.cos(x), -math.sin(x), 0], [0, math.sin(x), math.cos(x), 0], [0, 0, 0, 1]], np.float32)
|
mat = np.matrix(
|
||||||
mat = mat * np.matrix([[math.cos(y), 0, -math.sin(y), 0], [0, 1, 0, 0], [math.sin(y), 0, math.cos(y), 0], [0, 0, 0, 1]], np.float32)
|
[[1, 0, 0, 0], [0, math.cos(x), -math.sin(x), 0], [0, math.sin(x), math.cos(x), 0], [0, 0, 0, 1]],
|
||||||
mat = mat * np.matrix([[math.cos(z), -math.sin(z), 0, 0], [math.sin(z), math.cos(z), 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]], np.float32)
|
np.float32)
|
||||||
|
mat = mat * np.matrix(
|
||||||
|
[[math.cos(y), 0, -math.sin(y), 0], [0, 1, 0, 0], [math.sin(y), 0, math.cos(y), 0], [0, 0, 0, 1]],
|
||||||
|
np.float32)
|
||||||
|
mat = mat * np.matrix(
|
||||||
|
[[math.cos(z), -math.sin(z), 0, 0], [math.sin(z), math.cos(z), 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],
|
||||||
|
np.float32)
|
||||||
return np.transpose(mat)
|
return np.transpose(mat)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,15 @@ from OpenGL.GL import *
|
||||||
from Objects.Objects import *
|
from Objects.Objects import *
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
class Cube(Object):
|
class Cube(Object):
|
||||||
GeometryShaderId = -1
|
GeometryShaderId = -1
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Object.__init__(self)
|
Object.__init__(self)
|
||||||
if (Cube.GeometryShaderId == -1):
|
if (Cube.GeometryShaderId == -1):
|
||||||
self.initializeShader()
|
self.initializeShader()
|
||||||
|
|
||||||
def initializeShader(self) -> bool:
|
def initializeShader(self) -> bool:
|
||||||
with open('./Objects/Cube/cube_geometry.glsl', 'r') as f:
|
with open('./Objects/Cube/cube_geometry.glsl', 'r') as f:
|
||||||
geometry_shader_string = f.read()
|
geometry_shader_string = f.read()
|
||||||
|
|
|
@ -1,18 +1,25 @@
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
|
|
||||||
class Object:
|
class Object:
|
||||||
GeometryShaderId = -1
|
GeometryShaderId = -1
|
||||||
|
|
||||||
def draw(self) -> bool:
|
def draw(self) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def initializeShader(self) -> bool:
|
def initializeShader(self) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.pos = np.zeros((3))
|
self.pos = np.zeros((3))
|
||||||
self.color = np.zeros((3,))
|
self.color = np.zeros((3,))
|
||||||
self.programmId = -1
|
self.programmId = -1
|
||||||
|
|
||||||
def translate(self, M):
|
def translate(self, M):
|
||||||
self.pos = np.array((np.concatenate((self.pos, [1])) * M)[0, 0:3])[0]
|
self.pos = np.array((np.concatenate((self.pos, [1])) * M)[0, 0:3])[0]
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def setColor(self, R, G, B):
|
def setColor(self, R, G, B):
|
||||||
self.color[0] = R
|
self.color[0] = R
|
||||||
self.color[1] = G
|
self.color[1] = G
|
||||||
|
|
|
@ -22,6 +22,7 @@ def check_error(message):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class Structure:
|
class Structure:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.Objects = {}
|
self.Objects = {}
|
||||||
|
@ -52,10 +53,11 @@ class Structure:
|
||||||
self.vais = {}
|
self.vais = {}
|
||||||
|
|
||||||
for key, objects in self.Objects.items():
|
for key, objects in self.Objects.items():
|
||||||
tvai = GLuint(-1)
|
tvai = GLuint(0)
|
||||||
tpbi = -1
|
tpbi = GLuint(0)
|
||||||
tcbi = -1
|
tcbi = GLuint(0)
|
||||||
tsbi = -1
|
tsbi = GLuint(0)
|
||||||
|
|
||||||
glGenVertexArrays(1, tvai)
|
glGenVertexArrays(1, tvai)
|
||||||
glBindVertexArray(tvai)
|
glBindVertexArray(tvai)
|
||||||
|
|
||||||
|
@ -69,7 +71,7 @@ class Structure:
|
||||||
positions.append(o.pos[0])
|
positions.append(o.pos[0])
|
||||||
positions.append(o.pos[1])
|
positions.append(o.pos[1])
|
||||||
positions.append(o.pos[2])
|
positions.append(o.pos[2])
|
||||||
glBufferData(GL_ARRAY_BUFFER, np.asarray(positions), GL_STATIC_DRAW)
|
glBufferData(GL_ARRAY_BUFFER, np.array(positions, dtype=np.float32), GL_STATIC_DRAW)
|
||||||
glVertexAttribPointer(vid, 3, GL_FLOAT, GL_FALSE, 0, None)
|
glVertexAttribPointer(vid, 3, GL_FLOAT, GL_FALSE, 0, None)
|
||||||
check_error("Could not create position buffer")
|
check_error("Could not create position buffer")
|
||||||
|
|
||||||
|
@ -80,7 +82,7 @@ class Structure:
|
||||||
colors.append(o.color[2])
|
colors.append(o.color[2])
|
||||||
tcbi = glGenBuffers(1)
|
tcbi = glGenBuffers(1)
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, tcbi)
|
glBindBuffer(GL_ARRAY_BUFFER, tcbi)
|
||||||
glBufferData(GL_ARRAY_BUFFER, np.asarray(colors), GL_STATIC_DRAW)
|
glBufferData(GL_ARRAY_BUFFER, np.array(colors, dtype=np.float32), GL_STATIC_DRAW)
|
||||||
vc = glGetAttribLocation(key, "MyInColor")
|
vc = glGetAttribLocation(key, "MyInColor")
|
||||||
if vc != -1:
|
if vc != -1:
|
||||||
glEnableVertexAttribArray(vc)
|
glEnableVertexAttribArray(vc)
|
||||||
|
@ -95,7 +97,7 @@ class Structure:
|
||||||
sizes.append(o.size[2])
|
sizes.append(o.size[2])
|
||||||
tsbi = glGenBuffers(1)
|
tsbi = glGenBuffers(1)
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, tsbi)
|
glBindBuffer(GL_ARRAY_BUFFER, tsbi)
|
||||||
glBufferData(GL_ARRAY_BUFFER, np.asarray(sizes), GL_STATIC_DRAW)
|
glBufferData(GL_ARRAY_BUFFER, np.array(sizes, dtype=np.float32), GL_STATIC_DRAW)
|
||||||
vs = glGetAttribLocation(key, "MyInSize")
|
vs = glGetAttribLocation(key, "MyInSize")
|
||||||
if vs != -1:
|
if vs != -1:
|
||||||
glEnableVertexAttribArray(vs)
|
glEnableVertexAttribArray(vs)
|
||||||
|
@ -150,11 +152,13 @@ class Structure:
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
class CompoundStructure:
|
class CompoundStructure:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.Structures = []
|
self.Structures = []
|
||||||
|
|
||||||
def addStructure(self, structure : Structure, M : np.matrix = np.identity(4, np.float), R : np.matrix = np.identity(3, np.float)):
|
def addStructure(self, structure: Structure, M: np.matrix = np.identity(4, np.float),
|
||||||
|
R: np.matrix = np.identity(3, np.float)):
|
||||||
self.Structures.append((structure, M, R))
|
self.Structures.append((structure, M, R))
|
||||||
|
|
||||||
def render(self, projMatrix, geometryRotMatrix, alternateprograms=None):
|
def render(self, projMatrix, geometryRotMatrix, alternateprograms=None):
|
||||||
|
|
|
@ -21,13 +21,19 @@ const float specFactor = 1.0;
|
||||||
const float shininess = 16.0;
|
const float shininess = 16.0;
|
||||||
const float screenGamma = 2.2;
|
const float screenGamma = 2.2;
|
||||||
const float pitl = 2*3.14159265359 / 16.0;
|
const float pitl = 2*3.14159265359 / 16.0;
|
||||||
const float circlelength = 700.0;
|
const float circlelength = 100000.0;
|
||||||
|
|
||||||
bool isVisible(int i, vec2 offs, float lambertian)
|
bool isVisible(int i, vec2 offs, float lambertian)
|
||||||
{
|
{
|
||||||
float bias = 0.005*tan(acos(lambertian));
|
// float bias = 0.005*tan(acos(lambertian));
|
||||||
bias = clamp(bias,0.0,0.01);//*tan(acos(dot(normal,-normalize(lightpos[i] - pos.xyz))));
|
// bias = clamp(bias,0.0,0.01);//*tan(acos(dot(normal,-normalize(lightpos[i] - pos.xyz))));
|
||||||
return !(texture(ShadowMaps[i],lightviewpos[i].xy + offs).x < (lightviewpos[i].z - bias));
|
// return !(texture(ShadowMaps[i],lightviewpos[i].xy + offs).x < (lightviewpos[i].z - bias));
|
||||||
|
|
||||||
|
vec2 size = textureSize(ShadowMaps[i], 0);
|
||||||
|
float bias = (1.0 / (10.0 * max(size.x, size.y)))*sin(acos(lambertian));
|
||||||
|
// bias = 0.0001*(1.0 - lambertian);
|
||||||
|
// bias = max(bias, 0.001);
|
||||||
|
return !((texture(ShadowMaps[i],lightviewpos[i].xy + offs).x) < (lightviewpos[i].z - bias));
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
|
@ -36,7 +42,7 @@ void main()
|
||||||
|
|
||||||
for(int i = 0; i < numLights; i++){
|
for(int i = 0; i < numLights; i++){
|
||||||
vec3 lightDir = -normalize(lightpos[i] - pos.xyz);
|
vec3 lightDir = -normalize(lightpos[i] - pos.xyz);
|
||||||
float lambertian = max(dot(normalize(normal),lightDir),0.0);
|
float lambertian = dot(normalize(normal),lightDir);
|
||||||
float cosTheta = clamp(dot(normalize(normal),-lightDir), 0.0, 1.0);
|
float cosTheta = clamp(dot(normalize(normal),-lightDir), 0.0, 1.0);
|
||||||
float specular = 0;
|
float specular = 0;
|
||||||
vec3 viewDir = normalize(-pos.xyz);
|
vec3 viewDir = normalize(-pos.xyz);
|
||||||
|
@ -45,29 +51,25 @@ void main()
|
||||||
specular = int(lambertian > 0)*pow(specAngle, shininess);
|
specular = int(lambertian > 0)*pow(specAngle, shininess);
|
||||||
//int visible = int(!(texture(ShadowMaps,lightpos[i].xy/2 + vec2(0.5,0.5)).z < (lightpos[i].z)));
|
//int visible = int(!(texture(ShadowMaps,lightpos[i].xy/2 + vec2(0.5,0.5)).z < (lightpos[i].z)));
|
||||||
float visible = 0;
|
float visible = 0;
|
||||||
for(int j = 0; j < 4; j++){
|
int count = 0;
|
||||||
vec2 offs = vec2(cos(j*4*pitl),sin(j*4*pitl)) / circlelength;
|
|
||||||
visible += float(isVisible(i, offs,cosTheta)) * 1.0/16.0;
|
vec2 texelSize = 1.0 / textureSize(ShadowMaps[i], 0);
|
||||||
}
|
for(int x = -2; x <= 2; x++){
|
||||||
if(visible == 0.25)
|
for(int y = -2; y <= 2; y++){
|
||||||
visible = 1.0;
|
vec2 offs = vec2(x, y) * texelSize;
|
||||||
else
|
visible += float(int(isVisible(i, offs, lambertian))) * 1.0/25.0;
|
||||||
visible = 0;
|
}
|
||||||
for(int j = 0; j < 16; j++){
|
}
|
||||||
vec2 offs = vec2(cos(j*pitl),sin(j*pitl)) / circlelength;
|
bool condition = visible >= (1.0/5.0);
|
||||||
visible += float(isVisible(i, offs,cosTheta)) * 1.0/16.0;
|
visible = float(condition) * 1.0 + float(!condition) * visible;
|
||||||
}
|
|
||||||
colorLinear += (visible * 0.5 + 0.5) *(lambertian * diffuseFactor * colorin * lightColor[i] + specular * specFactor*colorin);
|
colorLinear += (visible * 0.5 + 0.0) *(lambertian * diffuseFactor * colorin * lightColor[i] + specular * specFactor*colorin) * (200.0/(length(lightpos[i] - pos.xyz) * length(lightpos[i] - pos.xyz)));
|
||||||
|
|
||||||
colorLinear /= dot(lightpos[i] - pos.xyz, lightpos[i] - pos.xyz)/200;
|
|
||||||
//colorLinear = vec3(visible * specular);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 colorGammaCorrected = colorLinear;//pow(colorLinear, vec3(1.0/screenGamma));
|
vec3 colorGammaCorrected = colorLinear;//pow(colorLinear, vec3(1.0/screenGamma));
|
||||||
|
|
||||||
|
colorOut = vec4(colorGammaCorrected,1.0);
|
||||||
//colorOut = vec4(colorin, 1.0)*max(dot(normal,normalize(vec3(0.0,0.0,10.0)-pos)),0.0);
|
|
||||||
colorOut = vec4(colorGammaCorrected,1.0) * float(gl_FragCoord.y <= 768 && gl_FragCoord.x <= 1024 && gl_FragCoord.x >= 0 && gl_FragCoord.y >= 0);
|
|
||||||
|
|
||||||
depth = gl_FragCoord.z;
|
depth = gl_FragCoord.z;
|
||||||
}
|
}
|
198
main.py
198
main.py
|
@ -1,3 +1,8 @@
|
||||||
|
import random
|
||||||
|
import sys
|
||||||
|
|
||||||
|
print('64' if sys.maxsize > 2 ** 32 else '32')
|
||||||
|
|
||||||
from wsgiref.validate import check_errors
|
from wsgiref.validate import check_errors
|
||||||
|
|
||||||
from OpenGL.GL.ARB.vertex_array_object import glDeleteVertexArrays
|
from OpenGL.GL.ARB.vertex_array_object import glDeleteVertexArrays
|
||||||
|
@ -28,10 +33,12 @@ program2_id = 0
|
||||||
program3_id = 0
|
program3_id = 0
|
||||||
start = time.time()
|
start = time.time()
|
||||||
frames = 0
|
frames = 0
|
||||||
width = 1024
|
width = 1920
|
||||||
height = 768
|
height = 1080
|
||||||
opening = 45
|
opening = 45
|
||||||
l = Light()
|
l = Light()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
lm = LightingManager()
|
lm = LightingManager()
|
||||||
# lm.addRenderStep(0,0)
|
# lm.addRenderStep(0,0)
|
||||||
|
@ -54,7 +61,6 @@ def main():
|
||||||
c = Cube()
|
c = Cube()
|
||||||
cuboid = Cuboid()
|
cuboid = Cuboid()
|
||||||
|
|
||||||
|
|
||||||
glClearColor(0., 0., 0., 1.)
|
glClearColor(0., 0., 0., 1.)
|
||||||
# glShadeModel(GL_SMOOTH)
|
# glShadeModel(GL_SMOOTH)
|
||||||
# glDisable(GL_CULL_FACE)
|
# glDisable(GL_CULL_FACE)
|
||||||
|
@ -82,8 +88,6 @@ def main():
|
||||||
# 0,0,0,
|
# 0,0,0,
|
||||||
# 0,1,0)
|
# 0,1,0)
|
||||||
# glPushMatrix()
|
# glPushMatrix()
|
||||||
glViewport(0, 0, w,h)
|
|
||||||
glFrustum(-10,10,-10,10,0.01,100)
|
|
||||||
|
|
||||||
with open('passthroughvertex.glsl', 'r') as f:
|
with open('passthroughvertex.glsl', 'r') as f:
|
||||||
vertex_shader_string = f.read()
|
vertex_shader_string = f.read()
|
||||||
|
@ -129,16 +133,25 @@ def main():
|
||||||
global struct, cstruct
|
global struct, cstruct
|
||||||
struct = Structure()
|
struct = Structure()
|
||||||
struct.addShape(program_id, Cube().translate(translate(0, 0, 1)).setColor(1, 1, 0))
|
struct.addShape(program_id, Cube().translate(translate(0, 0, 1)).setColor(1, 1, 0))
|
||||||
struct.addShape(program_id, Cube().translate(translate(1, 1, 0)).setColor(0, 0, 1))
|
# struct.addShape(program_id, Cube().translate(translate(1, 1, 0)).setColor(0, 0, 1))
|
||||||
struct.addShape(program_id, Cube().translate(translate(1, 0, 0)).setColor(0, 1, 0))
|
# struct.addShape(program_id, Cube().translate(translate(1, 0, 0)).setColor(0, 1, 0))
|
||||||
struct.addShape(program_id, Cube().translate(translate(1, -1, 0)).setColor(1, 0, 0))
|
# struct.addShape(program_id, Cube().translate(translate(1, -1, 0)).setColor(1, 0, 0))
|
||||||
struct.addShape(program_id, Cube().translate(translate(0, -1, 0)).setColor(0, 1, 0))
|
# struct.addShape(program_id, Cube().translate(translate(0, -1, 0)).setColor(0, 1, 0))
|
||||||
struct.addShape(program_id, Cube().translate(translate(-1, -1, 0)).setColor(0, 0, 1))
|
# struct.addShape(program_id, Cube().translate(translate(-1, -1, 0)).setColor(0, 0, 1))
|
||||||
struct.addShape(program_id, Cube().translate(translate(-1, 0, 0)).setColor(0, 1, 1))
|
# struct.addShape(program_id, Cube().translate(translate(-1, 0, 0)).setColor(0, 1, 1))
|
||||||
struct.addShape(program_id, Cube().translate(translate(-1, 1, 0)).setColor(1, 1, 1))
|
# struct.addShape(program_id, Cube().translate(translate(-1, 1, 0)).setColor(1, 1, 1))
|
||||||
struct.addShape(program_id, Cube().translate(translate(0, 1, 0)).setColor(0, 0, 1))
|
# struct.addShape(program_id, Cube().translate(translate(0, 1, 0)).setColor(0, 0, 1))
|
||||||
|
|
||||||
|
for x_pos in range(-10, 10, 1):
|
||||||
|
for y_pos in range(-10, 10):
|
||||||
|
struct.addShape(program_id, Cube().translate(translate(x_pos, y_pos, 0)).setColor(
|
||||||
|
random.randint(0, 100) / 100.0, random.randint(0, 100) / 100.0, random.randint(0, 100) / 100.0))
|
||||||
|
|
||||||
|
|
||||||
struct.buildvertexArrays()
|
struct.buildvertexArrays()
|
||||||
struct.clearVertexArrays()
|
|
||||||
|
# struct.clearVertexArrays()
|
||||||
|
|
||||||
cstruct = CompoundStructure()
|
cstruct = CompoundStructure()
|
||||||
cstruct.addStructure(struct)
|
cstruct.addStructure(struct)
|
||||||
|
|
||||||
|
@ -186,7 +199,6 @@ def main():
|
||||||
color.append(1)
|
color.append(1)
|
||||||
color.append(1)
|
color.append(1)
|
||||||
|
|
||||||
|
|
||||||
'''vai, pbi, cbi = create_vertex_buffers(np.array(v, dtype=np.float32),
|
'''vai, pbi, cbi = create_vertex_buffers(np.array(v, dtype=np.float32),
|
||||||
np.array(color, dtype=np.float32), program_id,
|
np.array(color, dtype=np.float32), program_id,
|
||||||
sizes=np.array(
|
sizes=np.array(
|
||||||
|
@ -222,19 +234,22 @@ def main():
|
||||||
glutMainLoop()
|
glutMainLoop()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
projMatrix = perspectiveMatrix(45.0, 400 / 400, 0.01, 100.0);
|
projMatrix = perspectiveMatrix(45.0, 400 / 400, 0.01, 100.0);
|
||||||
|
|
||||||
|
|
||||||
def check_error(message):
|
def check_error(message):
|
||||||
gl_error = glGetError()
|
gl_error = glGetError()
|
||||||
if (gl_error != GL_NO_ERROR):
|
if gl_error != GL_NO_ERROR:
|
||||||
print("Error: " + message)
|
print("Error: " + message)
|
||||||
if (gluErrorString(gl_error)):
|
if gluErrorString(gl_error):
|
||||||
print(gluErrorString(gl_error))
|
print(gluErrorString(gl_error))
|
||||||
else:
|
else:
|
||||||
print(hex(gl_error))
|
print(hex(gl_error))
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def create_vertex_buffers(positions, colors, program_id, sizes=np.array([])):
|
def create_vertex_buffers(positions, colors, program_id, sizes=np.array([])):
|
||||||
glEnableClientState(GL_VERTEX_ARRAY)
|
glEnableClientState(GL_VERTEX_ARRAY)
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY)
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY)
|
||||||
|
@ -282,34 +297,37 @@ def create_vertex_buffers(positions,colors,program_id,sizes=np.array([])):
|
||||||
glBindVertexArray(0)
|
glBindVertexArray(0)
|
||||||
return tvai, tpbi, tcbi
|
return tvai, tpbi, tcbi
|
||||||
|
|
||||||
|
|
||||||
def clear_buffer(buffer_id):
|
def clear_buffer(buffer_id):
|
||||||
glDisableVertexAttribArray(buffer_id)
|
glDisableVertexAttribArray(buffer_id)
|
||||||
glDeleteBuffers(1, [buffer_id])
|
glDeleteBuffers(1, [buffer_id])
|
||||||
|
|
||||||
|
|
||||||
def clear_vertex_array(va_id):
|
def clear_vertex_array(va_id):
|
||||||
glDeleteVertexArrays(1, va_id)
|
glDeleteVertexArrays(1, va_id)
|
||||||
check_error("Could not destroy vertex array")
|
check_error("Could not destroy vertex array")
|
||||||
|
|
||||||
|
|
||||||
vai, pbi, cbi = 0, 0, 0
|
vai, pbi, cbi = 0, 0, 0
|
||||||
vai2, pbi2, cbi2 = 0, 0, 0
|
vai2, pbi2, cbi2 = 0, 0, 0
|
||||||
vai3, pbi3, cbi3 = 0, 0, 0
|
vai3, pbi3, cbi3 = 0, 0, 0
|
||||||
rx = 0
|
rx = 0
|
||||||
ry = 0
|
ry = 0
|
||||||
|
|
||||||
|
|
||||||
def render(program_id, projMatrix, vai, x, y, z, alternateprograms=None):
|
def render(program_id, projMatrix, vai, x, y, z, alternateprograms=None):
|
||||||
|
|
||||||
global struct, cstruct
|
global struct, cstruct
|
||||||
|
|
||||||
cstruct.render(translate(x, y, z) * rotate(0, ry, 0, True) * projMatrix, rotate(rx, 0, 0), alternateprograms)
|
cstruct.render(translate(x, y, z) * rotate(0, ry, 0, True) * projMatrix, rotate(rx, 0, 0), alternateprograms)
|
||||||
|
'''
|
||||||
|
glUseProgram(program_id)
|
||||||
'''glUseProgram(program_id)
|
|
||||||
check_error("Renderingprogram is not initialized!")
|
check_error("Renderingprogram is not initialized!")
|
||||||
|
|
||||||
projection = glGetUniformLocation(program_id, 'projModelViewMatrix')
|
projection = glGetUniformLocation(program_id, 'projModelViewMatrix')
|
||||||
rot = glGetUniformLocation(program_id, 'rotMatrix')
|
rot = glGetUniformLocation(program_id, 'rotMatrix')
|
||||||
|
|
||||||
glUniformMatrix4fv(projection, 1, GL_FALSE, np.array(translate(x, y, z) * rotate(0,ry,0,True) * projMatrix))
|
glUniformMatrix4fv(projection, 1, GL_FALSE, np.array(translate(x, y, z) * rotate(rx, 0, 0, True) * projMatrix, dtype=np.float32))
|
||||||
glUniformMatrix3fv(rot, 1, GL_FALSE, np.array(rotate(rx, 0, 0)))
|
glUniformMatrix3fv(rot, 1, GL_FALSE, np.array(rotate(rx, 0, 0), dtype=np.float32))
|
||||||
|
|
||||||
|
|
||||||
glBindVertexArray(vai)
|
glBindVertexArray(vai)
|
||||||
|
@ -317,7 +335,9 @@ def render(program_id,projMatrix,vai,x,y,z,alternateprograms = None):
|
||||||
check_error("Rendering problem")
|
check_error("Rendering problem")
|
||||||
|
|
||||||
glBindVertexArray(0)
|
glBindVertexArray(0)
|
||||||
glUseProgram(0)'''
|
glUseProgram(0)
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
def display():
|
def display():
|
||||||
'''if time.time() - start >= 1:
|
'''if time.time() - start >= 1:
|
||||||
|
@ -328,7 +348,7 @@ def display():
|
||||||
else:
|
else:
|
||||||
global frames
|
global frames
|
||||||
frames += 1'''
|
frames += 1'''
|
||||||
|
glClearColor(0, 0, 0, 0)
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
||||||
|
|
||||||
global l
|
global l
|
||||||
|
@ -338,8 +358,17 @@ def display():
|
||||||
# newMat = orthogonalMatrix(10, -10, 10, -10, 10, -10) * lookAt(cx, cy, 5, 0, 0, 0, 0, 1,0) * np.identity(4)
|
# newMat = orthogonalMatrix(10, -10, 10, -10, 10, -10) * lookAt(cx, cy, 5, 0, 0, 0, 0, 1,0) * np.identity(4)
|
||||||
# newMat = translate(0, 0, -10) * newMat
|
# newMat = translate(0, 0, -10) * newMat
|
||||||
|
|
||||||
newMat = translate(-cx,-cy,-5)*lookAt(cx,cy,5,0,0,0,0,1,0) * perspectiveMatrix(opening,float(width)/float(height),0.01,100.0)
|
global projMatrix
|
||||||
oldMat = rotate(0, -0.5, 0, True) * projMatrix
|
projMatrix = perspectiveMatrix(45, float(width) / float(height), 0.01, 100.0)
|
||||||
|
|
||||||
|
newMat = translate(-cx, -cy, -2) * lookAt(cx, cy, 2, 0, 0, 0, 0, 1, 0) * perspectiveMatrix(opening,
|
||||||
|
float(l.map_size) /
|
||||||
|
float(l.map_size),
|
||||||
|
0.01, 100.0)
|
||||||
|
l.pos = [-cx, -cy, -2]
|
||||||
|
l.ModelviewProjectionMatrix = newMat
|
||||||
|
l.lightColor = [1, 1, 1]
|
||||||
|
|
||||||
glUseProgram(program3_id)
|
glUseProgram(program3_id)
|
||||||
widthid = glGetUniformLocation(program3_id, 'width')
|
widthid = glGetUniformLocation(program3_id, 'width')
|
||||||
heightid = glGetUniformLocation(program3_id, 'height')
|
heightid = glGetUniformLocation(program3_id, 'height')
|
||||||
|
@ -355,7 +384,8 @@ def display():
|
||||||
render(program3_id, newMat, vai, 0, 0, 0, altPrId)
|
render(program3_id, newMat, vai, 0, 0, 0, altPrId)
|
||||||
glFlush()
|
glFlush()
|
||||||
l.finishDepthMapping()
|
l.finishDepthMapping()
|
||||||
resize(width, height)
|
|
||||||
|
glClearColor(1, 0, 0, 0)
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
||||||
|
|
||||||
glUseProgram(program_id)
|
glUseProgram(program_id)
|
||||||
|
@ -368,16 +398,11 @@ def display():
|
||||||
glUniform1f(widthid, width)
|
glUniform1f(widthid, width)
|
||||||
glUniform1f(heightid, height)
|
glUniform1f(heightid, height)
|
||||||
|
|
||||||
|
|
||||||
lightProjModelViewMatrix = glGetUniformLocation(program_id, 'lightProjModelViewMatrix')
|
lightProjModelViewMatrix = glGetUniformLocation(program_id, 'lightProjModelViewMatrix')
|
||||||
numLights = glGetUniformLocation(program_id, 'numLights')
|
numLights = glGetUniformLocation(program_id, 'numLights')
|
||||||
lightpos = glGetUniformLocation(program_id, 'lightpos')
|
lightpos = glGetUniformLocation(program_id, 'lightpos')
|
||||||
lightcolorid = glGetUniformLocation(program_id, 'lightColor')
|
lightcolorid = glGetUniformLocation(program_id, 'lightColor')
|
||||||
|
|
||||||
l.pos = [-cx, -cy, -5]
|
|
||||||
l.ModelviewProjectionMatrix = newMat
|
|
||||||
l.lightColor = [1,1,1]
|
|
||||||
|
|
||||||
glUniformMatrix4fv(lightProjModelViewMatrix, 1, GL_FALSE, np.array(l.ModelviewProjectionMatrix))
|
glUniformMatrix4fv(lightProjModelViewMatrix, 1, GL_FALSE, np.array(l.ModelviewProjectionMatrix))
|
||||||
glUniform1iv(numLights, 1, 1)
|
glUniform1iv(numLights, 1, 1)
|
||||||
glUniform3fv(lightpos, 1, l.pos)
|
glUniform3fv(lightpos, 1, l.pos)
|
||||||
|
@ -388,14 +413,14 @@ def display():
|
||||||
glBindTexture(GL_TEXTURE_2D, l.DepthBuffer)
|
glBindTexture(GL_TEXTURE_2D, l.DepthBuffer)
|
||||||
glUniform1iv(texID, 1, 0)
|
glUniform1iv(texID, 1, 0)
|
||||||
|
|
||||||
render(program_id,projMatrix,vai,0,0,-10)
|
glViewport(0, 0, width, height)
|
||||||
|
render(program_id, translate(0, 0, -10) * lookAt(0, 0, 10, 0, 0, 0, 0, 1, 0) * projMatrix, vai, 0, 0, 0)
|
||||||
|
|
||||||
temp, _, _ = create_vertex_buffers(np.array([cx, cy, 5], dtype=np.float32),
|
# temp, _, _ = create_vertex_buffers(np.array([cx, cy, 5], dtype=np.float32),
|
||||||
np.array([1, 1, 0], dtype=np.float32), program_id)
|
# np.array([1, 1, 0], dtype=np.float32), program_id)
|
||||||
render(program_id, projMatrix, temp, 0, 0, -10)
|
# render(program_id, projMatrix, temp, 0, 0, -10)
|
||||||
# ry += 0.05
|
# ry += 0.05
|
||||||
|
|
||||||
|
|
||||||
glUseProgram(program2_id)
|
glUseProgram(program2_id)
|
||||||
check_error("Renderingprogram is not initialized!")
|
check_error("Renderingprogram is not initialized!")
|
||||||
|
|
||||||
|
@ -407,11 +432,11 @@ def display():
|
||||||
glBindVertexArray(vai2)
|
glBindVertexArray(vai2)
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6)
|
glDrawArrays(GL_TRIANGLES, 0, 6)
|
||||||
check_error("Rendering problem")
|
check_error("Rendering problem")
|
||||||
|
|
||||||
glBindVertexArray(0)
|
glBindVertexArray(0)
|
||||||
glUseProgram(0)
|
glUseProgram(0)
|
||||||
glFlush()
|
glFlush()
|
||||||
|
|
||||||
glFlush()
|
|
||||||
glutSwapBuffers()
|
glutSwapBuffers()
|
||||||
global rx
|
global rx
|
||||||
# rx += 0.025
|
# rx += 0.025
|
||||||
|
@ -419,48 +444,54 @@ def display():
|
||||||
glutPostRedisplay()
|
glutPostRedisplay()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
cx = 0
|
cx = 0
|
||||||
cy = 0
|
cy = 0
|
||||||
def display2():
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
|
||||||
global l
|
|
||||||
l.prepareForDepthMapping()
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
|
||||||
|
|
||||||
newMat = orthogonalMatrix(10, -10, 10, -10, 20, 0.01) * lookAt(-cx, -cy, 1, 0, 0, 0, 0, 1, 0) * np.identity(4)
|
|
||||||
newMat = translate(5,0,-10)*lookAt(-5,0,10,0,0,0,0,1,0) * projMatrix
|
|
||||||
oldMat = rotate(0,-0.5,0,True) * projMatrix
|
|
||||||
glUseProgram(program3_id)
|
|
||||||
widthid = glGetUniformLocation(program3_id, 'width')
|
|
||||||
heightid = glGetUniformLocation(program3_id, 'height')
|
|
||||||
nearid = glGetUniformLocation(program3_id, 'near')
|
|
||||||
farid = glGetUniformLocation(program3_id, 'far')
|
|
||||||
glUniform1f(nearid, 0.01)
|
|
||||||
glUniform1f(farid, 100)
|
|
||||||
glUniform1f(widthid, width)
|
|
||||||
glUniform1f(heightid, height)
|
|
||||||
render(program3_id, newMat,vai,0,0,0)
|
|
||||||
glFlush()
|
|
||||||
l.finishDepthMapping()
|
|
||||||
|
|
||||||
glUseProgram(program2_id)
|
# def display2():
|
||||||
check_error("Renderingprogram is not initialized!")
|
# glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
||||||
|
# global l
|
||||||
|
# l.prepareForDepthMapping()
|
||||||
|
# glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
||||||
|
#
|
||||||
|
# newMat = orthogonalMatrix(10, -10, 10, -10, 20, 0.01) * lookAt(-cx, -cy, 1, 0, 0, 0, 0, 1, 0) * np.identity(4)
|
||||||
|
# newMat = translate(5, 0, -10) * lookAt(-5, 0, 10, 0, 0, 0, 0, 1, 0) * projMatrix
|
||||||
|
# oldMat = rotate(0, -0.5, 0, True) * projMatrix
|
||||||
|
# glUseProgram(program3_id)
|
||||||
|
# widthid = glGetUniformLocation(program3_id, 'width')
|
||||||
|
# heightid = glGetUniformLocation(program3_id, 'height')
|
||||||
|
# nearid = glGetUniformLocation(program3_id, 'near')
|
||||||
|
# farid = glGetUniformLocation(program3_id, 'far')
|
||||||
|
# glUniform1f(nearid, 0.01)
|
||||||
|
# glUniform1f(farid, 100)
|
||||||
|
# glUniform1f(widthid, width)
|
||||||
|
# glUniform1f(heightid, height)
|
||||||
|
# render(program3_id, newMat, vai, 0, 0, 0)
|
||||||
|
# glFlush()
|
||||||
|
# l.finishDepthMapping()
|
||||||
|
#
|
||||||
|
# glUseProgram(program2_id)
|
||||||
|
# check_error("Renderingprogram is not initialized!")
|
||||||
|
#
|
||||||
|
# texID = glGetUniformLocation(program2_id, "Tex")
|
||||||
|
# glActiveTexture(GL_TEXTURE0)
|
||||||
|
# glBindTexture(GL_TEXTURE_2D, l.DepthBuffer)
|
||||||
|
# glUniform1i(texID, 0)
|
||||||
|
#
|
||||||
|
# glBindVertexArray(vai3)
|
||||||
|
# glDrawArrays(GL_TRIANGLES, 0, 6)
|
||||||
|
# check_error("Rendering problem")
|
||||||
|
# glBindVertexArray(0)
|
||||||
|
# glUseProgram(0)
|
||||||
|
# glFlush()
|
||||||
|
# glutSwapBuffers()
|
||||||
|
# glutPostRedisplay()
|
||||||
|
|
||||||
texID = glGetUniformLocation(program2_id, "Tex")
|
|
||||||
glActiveTexture(GL_TEXTURE0)
|
|
||||||
glBindTexture(GL_TEXTURE_2D,l.DepthBuffer)
|
|
||||||
glUniform1i(texID,0)
|
|
||||||
|
|
||||||
glBindVertexArray(vai3)
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6)
|
|
||||||
check_error("Rendering problem")
|
|
||||||
glBindVertexArray(0)
|
|
||||||
glUseProgram(0)
|
|
||||||
glFlush()
|
|
||||||
glutSwapBuffers()
|
|
||||||
glutPostRedisplay()
|
|
||||||
|
|
||||||
def resize(w, h):
|
def resize(w, h):
|
||||||
|
w = max(w, 1)
|
||||||
|
h = max(h, 1)
|
||||||
glViewport(0, 0, w, h)
|
glViewport(0, 0, w, h)
|
||||||
global projMatrix
|
global projMatrix
|
||||||
projMatrix = perspectiveMatrix(45.0, float(w) / float(h), 0.01, 100.0)
|
projMatrix = perspectiveMatrix(45.0, float(w) / float(h), 0.01, 100.0)
|
||||||
|
@ -471,33 +502,29 @@ def resize(w,h):
|
||||||
def keyboardHandler(key: int, x: int, y: int):
|
def keyboardHandler(key: int, x: int, y: int):
|
||||||
if key == b'\x1b':
|
if key == b'\x1b':
|
||||||
exit()
|
exit()
|
||||||
|
global rx
|
||||||
|
global cx
|
||||||
|
global cy
|
||||||
|
global opening
|
||||||
|
|
||||||
if key == b'+':
|
if key == b'+':
|
||||||
global rx
|
|
||||||
rx += 0.25
|
rx += 0.25
|
||||||
if key == b'-':
|
if key == b'-':
|
||||||
global rx
|
|
||||||
rx -= 0.25
|
rx -= 0.25
|
||||||
|
|
||||||
if key == b'w':
|
if key == b'w':
|
||||||
global cy
|
|
||||||
cy += 0.25
|
cy += 0.25
|
||||||
if key == b's':
|
if key == b's':
|
||||||
global cy
|
|
||||||
cy -= 0.25
|
cy -= 0.25
|
||||||
|
|
||||||
if key == b'a':
|
if key == b'a':
|
||||||
global cx
|
|
||||||
cx -= 0.25
|
cx -= 0.25
|
||||||
if key == b'd':
|
if key == b'd':
|
||||||
global cx
|
|
||||||
cx += 0.25
|
cx += 0.25
|
||||||
|
|
||||||
if key == b'q':
|
if key == b'q':
|
||||||
global opening
|
|
||||||
opening -= 0.25
|
opening -= 0.25
|
||||||
if key == b'e':
|
if key == b'e':
|
||||||
global opening
|
|
||||||
opening += 0.25
|
opening += 0.25
|
||||||
|
|
||||||
if key == b'r':
|
if key == b'r':
|
||||||
|
@ -505,9 +532,14 @@ def keyboardHandler(key:int,x:int,y:int):
|
||||||
glutPostRedisplay()
|
glutPostRedisplay()
|
||||||
# print(key,x,y)
|
# print(key,x,y)
|
||||||
|
|
||||||
|
|
||||||
def funcKeydHandler(key: int, x: int, y: int):
|
def funcKeydHandler(key: int, x: int, y: int):
|
||||||
if key == 11:
|
if key == 11:
|
||||||
glutFullScreenToggle()
|
glutFullScreenToggle()
|
||||||
# print(key)
|
# print(key)
|
||||||
|
|
||||||
if __name__ == '__main__': main()
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
rx = 0
|
||||||
|
ry = 0
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in a new issue