glutMouseFunc() not working in python?Whenver i click on window to put pixel it get c


from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *


def init():
    glClearColor(1.0,1.0,1.0,0.0)
    glMatrixMode(GL_PROJECTION)
    gluOrtho2D(0,640,0,480)
    glMatrixMode(GL_MODELVIEW)

def bound_it(x, y,fillColor=[], bc=[]):
    color=[]
    glReadPixels(x,y,1.0,1.0,GL_RGB,GL_FLOAT,color)
    if((color[0]!=bc[0] or color[1]!=bc[1] or color[2]!=bc[2])and(color[0]!=fillColor[0] or color[1]!=fillColor[1] or color[2]!=fillColor[2])):
        glColor3f(fillColor[0],fillColor[1],fillColor[2])
        glBegin(GL_POINTS)
        glVertex2i(x,y)
        glEnd()
        glFlush()
        bound_it(x+1,y,fillColor,bc)
        bound_it(x,y+1,fillColor,bc)
        bound_it(x-1,y,fillColor,bc)
        bound_it(x,y-1,fillColor,bc)
             
def mouse(btn,state,x,y):
          x1=x
          y1=480-y
          if(btn==GLUT_LEFT_BUTTON and state==GLUT_DOWN):
                  bcol=[1,0,0]
                  color=[0,0,1]
                  bound_it(x1,y1,color,bcol)
    
def display():
    glLineWidth(3)
    glPointSize(2)
    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(1,0,0)
    list1=list(map(int,input("Enter All the X Coordinates as a list less than 640:").split()))
    list2=list(map(int,input("Enter All the Y Coordinates as a list less than 480:").split()))
    n=len(list1)
    glBegin(GL_LINE_LOOP)
    for i in range(0,n):
        glVertex2i(list1[i],list2[i])
    glEnd()
    glFlush()
      
glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(640,800)
glutInitWindowPosition(200,300)
glutCreateWindow("Boundary Filling:4 pixel".encode())
glutDisplayFunc(display)
glutMouseFunc(mouse)
init()
glutMainLoop()

  1. Don’t try to put the entire post in the title.
  2. Use
 or 

tags for code. This is particularly important for Python as it uses whitespace for block structure.
3.

Where does that 480 come from? You would normally use [var]height-1-y[/var] to translate coordinates from top-left-origin (used by most windowing systems and GUI toolkits) to bottom-left-origin (used by OpenGL).