Pyglet GL_QUADS and GL_POLYGON not working properly

99封情书 提交于 2019-12-11 18:20:23

问题


I'm trying to write a simple game and for some reason the graphics primitives aren't working properly on my machine (Win7/NVIDIA Quadro K2100M). I'm trying to draw a rectangle but whenever I use GL_QUADS or GL_POLYGON it comes with a weird bend in it. It works with GL_QUAD_STRIP, oddly, but that's really not ideal since I don't want the ones I"m drawing to be connected. I really have no idea what the problem could be...

Example code:

import pyglet

window = pyglet.window.Window(width=400, height=400)
batch = pyglet.graphics.Batch()
white = [255]*4
batch.add(4, pyglet.gl.GL_QUADS, None, ('v2i',[10,10,10,50,390,10,390,50]), ('c4B',white*4))

batch.add(4, pyglet.gl.GL_POLYGON, None, ('v2i',[10,60,10,110,390,60,390,110]), ('c4B',white*4))
batch.add(4, pyglet.gl.GL_QUAD_STRIP, None, ('v2i',[10,120,10,170,390,120,390,170]), ('c4B',white*4))



@window.event
def on_draw():
    batch.draw()

pyglet.app.run()


回答1:


I'm so stupid: I put the points in the wrong order so it drew (top left, bottom left, top right, bottom right) and of course this would be the result X_X



来源:https://stackoverflow.com/questions/47628870/pyglet-gl-quads-and-gl-polygon-not-working-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!