I have been trying read up a lot on opengl drawing using python and have been trying to create a script which display a text and a 2d shape on the viewport (a rectangle or square). From reading the blender docs I could only find little to no information about it and only got me to display text. The 2d shape drawing is still out of my knowledge. In this code I'm trying to draw a text and a draw a 2d quad in a modal operator but unfortunately the quad doesn't show up but the text is working properly.
How do I draw a 2d shape in a modal operator using bgl ?
import bpy import blf import bgl def draw_textandbox(self, context): font_id = 0 x_offset = 0 y_offset = 0 #The Text------------------------- bgl.glColor4f(1,1,1,0.8) blf.position(font_id, 80, 500, 0) blf.size(font_id, 27, 70) blf.draw(font_id, "LEVELS:" ) #The Box, This is the part i wanted to work but unfortunately it doesnt bgl.glColor4f(1,0,0,0.8) bgl.glBegin(bgl.GL_QUADS) bgl.glVertex2f(200, 400) bgl.glEnd()