glTranslatef not working within glBegin .. glEnd

前端 未结 2 751
感情败类
感情败类 2021-01-22 07:41

I\'m trying to draw 2 squares side by side of different colours, my problem is I can\'t get glTranslatef to move my second square to the right, the second square just draws over

相关标签:
2条回答
  • 2021-01-22 08:35

    You cannot translate inside a glBegin/glEnd block, you have break it up into two blocks.

    I recommend to start using glGetError() in your code, it will help you find mistakes like this.

    0 讨论(0)
  • 2021-01-22 08:36

    Only a certain subset of OpenGL commands is allowed between glBegin and glEnd. So, when you call glTranslate between those two calls, it is ignored.

    Remove glBegin and glEnd from display, and put in drawSquare - that should work.

    0 讨论(0)
提交回复
热议问题