使用int而不是float的pyglet.gl

2024-09-30 16:38:26 发布

您现在位置:Python中文网/ 问答频道 /正文

from opensimplex import OpenSimplex
from pyglet.gl import *
gen = OpenSimplex()
def noise(nx, ny):
    return gen.noise2d(nx, ny) / 2.0 + 0.5

value = []
height = 10
width = 10
scl = 10
offsetx = -10
offsety = -10
class windowed(pyglet.window.Window):
    def __init__(self,*args,**kwargs):
        super().__init__(*args,**kwargs)
        self.set_minimum_size(400,300)
    def on_draw(self):
        glClear(GL_COLOR_BUFFER_BIT)
        #batch = pyglet.graphics.Batch()
        for y in range(10):
            #print("y")
            glBegin(GL_LINE_LOOP)
            for x in range(10):
                #print("x")
                #glColor3f( 1, 1, 1 )
                glVertex3f(float((x+offsetx)*scl),float((y+offsety)*scl),0.0)
                glVertex3f(float((x+offsetx)*scl),float((y+1+offsety)*scl),0.0)

            glEnd()
        #batch.draw()
    def on_resize(self,w,h):
        glViewport(0,0,w,h)
window = windowed(720,720,"yeet",resizable = True)
pyglet.clock.tick()
pyglet.app.run()

如何将glVertex3f更改为使用整数值而不是浮点数 我试图做地形噪声的事情,但是用python。Idk,如果可能的话,但如果是的话,那就太好了。如果你们中有人知道,你能告诉我怎么做,把它放在哪里吗


Tags: fromimportselfdeffloatgenpygletnx