0
I was trying to create using Opengl, Python and pyglet, a flat triangle in a 3D space, I saw some tutorials on the internet, some videos on Youtube, and in the end I wrote this code down there, the problem is that it didn’t work as I expected, I thought if I tried to spin, I could see the flat triangle spinning, and when I moved the scenario away the triangle didn’t have to decrease?
import pyglet
from pyglet.gl import *
config = Config(sample_buffers=1, samples=8)
tela = pyglet.window.Window(height=500, width=500, config=config)
glViewport(0,0,500,500)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(35,1,0.1,1000)
glMatrixMode(GL_MODELVIEW)
@tela.event
def on_draw():
glBegin(GL_POLYGON)
glVertex3f(10,10,0)
glVertex3f(100,10,0)
glVertex3f(50,100,0)
glEnd()
glFlush()
@tela.event
def on_key_press(s,m):
tela.clear()
if s == pyglet.window.key.W:
glTranslatef(0,0,1)
if s == pyglet.window.key.S:
glTranslatef(0,0,-1)
if s == pyglet.window.key.A:
glRotatef(1,0,1,0)
if s == pyglet.window.key.D:
glRotatef(-1,0,1,0)
pyglet.app.run()
When I spin the code this appears:
And when I try to spin the scenery it happens:
Does anyone know where I’m going wrong?
add code as text, not as image. This makes it easier to help you.
– sant0will