pyglet.gl使用整数而不是浮点数

时间:2019-03-11 19:58:10

标签: python pyglet

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以使用整数值而不是浮点数 我正在尝试做地形噪声之类的事情,https://www.youtube.com/watch?v=IKB1hWWedMk但在python中。如果可能的话,Idk,但如果可能的话,那会很好。如果您知道的话,您能告诉我该怎么做以及放在哪里

1 个答案:

答案 0 :(得分:0)

def inter(x,h):
    return x/h

忽略它的名称,因为我想不出该怎么称呼。这很有效,只是个白痴