Pyglet in OSX: blank screen with config context

85 views
Skip to first unread message

Jose Luis Da

unread,
Jun 26, 2014, 10:15:14 AM6/26/14
to pyglet...@googlegroups.com
Hi all, 

I am having problems with a pyglet script which works as expected in Windows, but it only displays a blank image in OSX. I have found that the reason of this blank screen is the config context option, which I use to activate the stencil as:

    allowstencil = pyglet.gl.Config(stencil_size=8)
    myWindow = pyglet.window.Window(config=allowstencil,fullscreen=False,screen=screens[0], visible = 0)

However, even if I initialize an empty config, for example, as:

    allowstencil = pyglet.gl.Config()

the resulting window is still empty.

The stencil is a requirement of the application and what has to be on the screen does not look good without it.

I have also used the command `pyglet.gl.gl_info.get_version()` in order to see if the versions on the mac and the windows are different. In mac this command gave `2.1 NVIDIA-1.6.24` and in windows `3.2.0`.

The code I am using is the following. Can anybody tell me how can I use the config context properly in OSX?

    import pyglet
    from pyglet.gl import *
    from pyglet.window import mouse, key
    import math 
    import time
    import ConfigParser
    import numpy as np # for randomize the trials
    import sys # debuging purposes
    import os
    
    ## Create pyglet window
    # Get screens
    screens = pyglet.window.get_platform().get_default_display().get_screens()
    allowstencil = pyglet.gl.Config(stencil_size=8)
    
    
    # Create window (not visible at start)
    #myWindow = pyglet.window.Window(config=allowstencil,fullscreen=False,screen=screens[0], visible = 0)
    myWindow = pyglet.window.Window(fullscreen=False,screen=screens[0]) # no stencil window
    
    ## Functions definition
    def create_filename():
        
        ## Create output data file name
        
        # Get subject and time information
        exp_name = 'pythonMigration'
        time_string = time.strftime("%y.%m.%d_%H.%M.%S", time.localtime())
        subject_name = "Name"
        
        textfilename = (exp_name + '_' + subject_name + '_' + time_string + '.txt')
        
        # Save output file in the folder "data"
        out_file_name = os.path.join('data', textfilename) 
        
        return out_file_name
    
    def ConfigFileToStruct(configfilename):
        # ConfigFileToStruct receives the string of the name of the configuration file to be read.
        # It will return a dict variable with the configuration parameters and values
    
        # config_struct will be the dict struture where all the configuration parameters will be stored
        config_struct = {}  
          
        # Initialize configParser
        config = ConfigParser.RawConfigParser()
        
        # Read file named configfilename
        config.read(configfilename)
         
        # Read sections of configuration file
        sectionlist = config.sections()
    
        # Read options of each section
        # optionlist will be an AxB array, where A is not defined and B is the len(sectionlist)
        optionlist = [[] for x in range(len(sectionlist))]
    
        
        for i in range(len(sectionlist)):
            # Read variables (options) from configuration file
            optionlist[i] = config.options(sectionlist[i])
            
            # Fill structure with sections
            config_struct[sectionlist[i]] = {}
            
            # Fill sections of structure with variables and values
            for j in range(len(optionlist[i])):
                config_struct[sectionlist[i]][optionlist[i][j]] = config.getfloat(sectionlist[i], optionlist[i][j])
    
        return(config_struct) #end of readconfigFile function
    
    def load_trial_parameters(trialsfile,trial):
        # trialsfile is the struct previously loaded by ConfigFileToStruct()
        # trial is the number of the trial to load parameters from
        global mylambda1, duty_cycle1, orientation1, speed1
        global mylambda2, duty_cycle2, orientation2, speed2
        global timeCurrentTrial
        
        ## GRATING PARAMETERS
         
        mylambda1 = trialsfile[str(trial)]["wavelength1"]
        duty_cycle1 = trialsfile[str(trial)]["duty_cycle1"]
        orientation1 = trialsfile[str(trial)]["orientation1"]
        speed_pix = trialsfile[str(trial)]["speed1"]
        speed1 = speed_pix / math.cos(math.radians(orientation1))
    
        #grating2
       
        mylambda2 = trialsfile[str(trial)]["wavelength2"]
        duty_cycle2 = trialsfile[str(trial)]["duty_cycle2"]
        orientation2 = trialsfile[str(trial)]["orientation2"]
        speed_pix = trialsfile[str(trial)]["speed2"]
        speed2 = speed_pix / math.cos(math.radians(orientation2))
        
        # other parameters
        timeCurrentTrial = trialsfile[str(trial)]["time"]
    
    
        
    def load_config_parameters(config):
        # config is the struct previously loaded by ConfigFileToStruct()
        
        # Declare variables, all are global, this function if for clearity purposes    
        global x0_pix, y0_pix
        global ysize_cm, aperture_color, numTheta, deltaTheta, x1, y1, apertRad_pix
        global x2, y2
        global red_color, cyan_color
        global stereo1, stereo2
        global fixp_color, surrp_color
        global time_fixp
        
        # calculate x, y center coordinates in pixels
        x0_myW = 0 # note that we consider center of screen to be 0,0 in My World Coordinates
        y0_myW = 0
        x0_pix = ((x0_myW/0.5) + 1)/2 * myWindow.width
        y0_pix = ((y0_myW/0.5) + 1)/2 * myWindow.height # center of screen
        
        apertureDiv = config["aperture_size"]["proportion"]
        apertRad_pix = myWindow.height / apertureDiv
        
        ## APERTURE PARAMETERS
            # Calculate circle for aperture
        aperture_color = (config["aperture_color"]["red"], config["aperture_color"]["green"], config["aperture_color"]["blue"])
        numTheta = int(config["radius"]["numtheta"])
        deltaTheta = 2 * math.pi / numTheta # == 0.0698
    #     
        ## GRATING PARAMETERS
        #grating1
        x1 = x0_pix - apertRad_pix
        y1 = y0_pix - apertRad_pix
        stereo1 = config["stereo"]["grating1"]
         
        #grating2
        x2 = x0_pix + apertRad_pix
        y2 = y0_pix + apertRad_pix
        stereo2 = config["stereo"]["grating2"]
        
        ## COLOR PARAMETERS
        red_color   = (config["red_color"]["red"], config["red_color"]["green"], config["red_color"]["blue"])
        cyan_color  = (config["cyan_color"]["red"], config["cyan_color"]["green"], config["cyan_color"]["blue"])
        
        # fixation point color
        fixp_color  = (config["fixp_color"]["red"], config["fixp_color"]["green"], config["fixp_color"]["blue"])
        surrp_color = (config["surrp_color"]["red"], config["surrp_color"]["green"], config["surrp_color"]["blue"])
        
        # fixation point time beginning trials
        time_fixp = config["time"]["time_fixp"]
    
    
        
    @myWindow.event
    def on_mouse_press(x, y, button, modifiers):
    #     On_mouse_press will be executed each time a mouse button is pressed
        global count, datatime, dataclick, datatrial
        global show_stim, show_trial_menu, trial, clockTrial, show_welcome
        
        global show_trial_menu_release, show_welcome_release
        
        timeNow = time.clock() - clockTrial
        
        
        if show_stim:
            
            if button == mouse.LEFT:
                datatrial[count] = trials_array[trial_counter]
                dataclick[count] = '-1'
                datatime[count] = timeNow - time_fixp
        
    
            if button == mouse.RIGHT:
                datatrial[count] = trials_array[trial_counter]
                dataclick[count] = '1'
                datatime[count] = timeNow - time_fixp
                
            count += 1
            
        elif show_trial_menu:
            show_trial_menu_release = 1
    
            
        elif show_welcome:
            show_welcome_release = 1
    
    @myWindow.event
    def on_mouse_release(x, y, button, modifiers):
    #     On_mouse_release will be executed each time a mouse button is release
        global count, dataclick, datatime, datatrial
        global show_stim, show_trial_menu, trial, clockTrial, show_welcome, trial_counter
        global show_trial_menu_release, show_welcome_release
        
        timeNow = time.clock() - clockTrial
        
        
        if show_stim:   
            if button == mouse.LEFT:
                datatrial[count] = trials_array[trial_counter]
                dataclick[count] = '-2'
                datatime[count] = timeNow - time_fixp
                    
            if button == mouse.RIGHT:
                datatrial[count] = trials_array[trial_counter]
                dataclick[count] = '2'
                datatime[count] = timeNow - time_fixp
            
            count += 1
        
        elif show_trial_menu & show_trial_menu_release:
            
            show_trial_menu_release = 0 
            
            show_stim = 1
            show_trial_menu = 0
            trial = trial + 1
            trial_counter = trial_counter + 1
            clockTrial = time.clock()
            
            
        elif show_welcome & show_welcome_release:
            
            show_welcome_release = 0
            show_welcome = 0
            show_stim = 1
            
            clockTrial = time.clock()
    
            
    @myWindow.event
    def on_close():
        #on_close is executed when mywindow is closed
        close_nicely()
        
    def close_nicely(): 
        #Write data to text file   
        for i in range(count):
            with open(out_file_name, 'a') as txtfile:
                txtfile.write(str(i) +'\t'+ str(datatime[i]) +'\t'+ str(dataclick[i]) +'\t'+ str(datatrial[i]) + '\n')
        
        print("closed nicely :)")
        
        myWindow.clear()
        myWindow.close()
                   
    def drawCircle(radius, circle_color, x, y):
        global numTheta, deltaTheta 
        
        glColor3f( circle_color[0] , circle_color[1], circle_color[2])
          
        for i in range (0, numTheta):
            cx1 = x + radius * math.sin(deltaTheta * i)
            cy1 = y + radius * math.cos(deltaTheta * i)
            cx2 = x + radius * math.sin(deltaTheta * (i+1))
            cy2 = y + radius * math.cos(deltaTheta * (i+1))
              
            glBegin( GL_TRIANGLES )
            glVertex2f(x, y )
            glVertex2f(cx1 , cy1 )
            glVertex2f(cx2 , cy2 )
            glEnd()
    
    def drawAperture():
        global aperture_color, numTheta, deltaTheta, x0_pix, y0_pix, apertRad_pix
        
        # Do we need the stencil commands in here? It does not change if I delete them
        # Enable stencil
        glClearStencil(0x0)
        glEnable(GL_STENCIL_TEST) 
         
        #define the region where the stencil is 1
        glClear(GL_STENCIL_BUFFER_BIT)
        glStencilFunc(GL_ALWAYS, 0x1, 0x1) #Always pass stencil functions test
        glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE) #Replace stencil value with reference value
        
        drawCircle(apertRad_pix, aperture_color, x0_pix, y0_pix)
    
    def drawGrating(x, y, fill_color, orientation, mylambda, duty_cycle):
        
        bar_length = 1500
        
        radio_aux = (2 * apertRad_pix) + mylambda #diameter 
        num_bars = int(1 + math.floor(radio_aux / mylambda))+3
      
        glStencilFunc (GL_EQUAL, 0x1, 0x1) 
        glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP)
            
        glLoadIdentity() #replace current matrix with the identity matrix
        glTranslatef(x, y, 0)
        glRotatef(orientation,0,0,1)    
        glTranslatef(-x, -y, 0)
    
        glColor3f( fill_color[0] , fill_color[1], fill_color[2] )
        
        glBlendFunc(GL_ZERO, GL_SRC_COLOR)  
        
        for i in range(num_bars):    
            
            x1 = mylambda * i + x
            x2 = (duty_cycle * mylambda) + (mylambda * i + x)
            
            glBegin(GL_QUADS)
            
            glVertex2f(x1, y - bar_length) 
            glVertex2f(x1, y + bar_length) 
            glVertex2f(x2, y + bar_length) 
            glVertex2f(x2, y - bar_length)
            
            glEnd()
        
        glBlendFunc(GL_ONE, GL_ZERO)
        glLoadIdentity()     
    
    def update_frames(dt):
        global x1, x2, timetrial, clockTrial, trial, show_stim, show_trial_menu
        
        timeNow = time.clock()
    
        if (show_stim) & ((timeNow-clockTrial) < (timeCurrentTrial + time_fixp)):
            # Load trial parameters
            load_trial_parameters(trialsfile,trials_array[trial_counter])
            
            motion_cycle1 = mylambda1/(math.cos(math.radians(orientation1)))
            motion_cycle2 = mylambda2/(math.cos(math.radians(orientation2)))
            
            initialpos1 = myWindow.width/2 - apertRad_pix - mylambda1/2
            initialpos2 = myWindow.width/2 - apertRad_pix + mylambda2/2
            
            # update position of grating 1:
            x1 = initialpos1 + math.fmod(speed1*(timeNow-clockTrial), motion_cycle1)
            
            # update position of grating 2:
            x2 = initialpos2 + math.fmod(speed2*(timeNow-clockTrial), motion_cycle2)
        
        elif ((show_stim) & (trial_counter < numtrials)):
            show_stim = 0
            show_trial_menu = 1
    
        elif ((show_stim == 0) & (trial_counter == numtrials-1)):
            close_nicely()
            pass
        
    @myWindow.event
    def on_draw():
        myWindow.clear()
    
    
        if show_stim:
            # For each frame of the stimulus:
            
            # clear the window
            myWindow.clear()
            
            load_trial_parameters(trialsfile, trials_array[trial_counter])
                    
            # Enable blending
            glEnable(GL_BLEND)
            pyglet.gl.glClearColor( 0.6, 0.6, 0.6, 0 )
            
            # Enable stencil
            glClearStencil(0x0)
            glEnable(GL_STENCIL_TEST) 
            
            # define the region where the stencil is 1
            glClear(GL_STENCIL_BUFFER_BIT)
            glStencilFunc(GL_ALWAYS, 0x1, 0x1) #Always pass stencil functions test
            glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE) #Replace stencil value with reference value
            
            # draw Aperture
            drawCircle(apertRad_pix, aperture_color, x0_pix, y0_pix) 
            
            # draw Fixation point and fixation surround
            drawCircle(apertRad_pix/15, fixp_color,  x0_pix, y0_pix)
            drawCircle(apertRad_pix/80, surrp_color, x0_pix, y0_pix)
    
            if (time.clock()-clockTrial)>time_fixp:
                # draw gratings
                
                Red  = red_color
                Cyan = cyan_color
                        
                drawGrating(x1 + stereo1, y1, Cyan, orientation1, mylambda1, duty_cycle1)
                drawGrating(x1 - stereo1, y1, Red,  orientation1, mylambda1, duty_cycle1)
                
                drawGrating(x2 + stereo2, y2, Red,  orientation2, mylambda2, duty_cycle2)
                drawGrating(x2 - stereo2, y2, Cyan, orientation2, mylambda2, duty_cycle2)
                
                glBlendFunc(GL_ONE, GL_ZERO)
    
        
        
        elif show_trial_menu:
            # For each frame of the in-between trials window
            
            myWindow.clear()
               
            #define the region where the stencil is 1
            glClear(GL_STENCIL_BUFFER_BIT)
            glStencilFunc(GL_ALWAYS, 0x1, 0x1) #Always pass stencil functions test
            glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE) #Replace stencil value with reference value
            
            labelInterval.draw()
           
            
        elif show_welcome:
            # For each frame of the welcome window
            
            myWindow.clear()
            
            glEnable(GL_BLEND)
            pyglet.gl.glClearColor( 0.6, 0.6, 0.6, 0 )
            
            labelWelcome.draw()
    
        myWindow.flip()
            
            
    ################################################################################################
    ## Main
    ################################################################################################
    
    if __name__ == "__main__":
             
        ## Check command-line arguments
        if len(sys.argv)>1:
            confignamefile = sys.argv[1]
            trialsnamefile = sys.argv[2]
            print("input received")
        else:
            print("no input received")
            confignamefile = "cfgfile.txt"
            trialsnamefile = "trialsfile.txt"
        
        # Load configuration parameters
        config = ConfigFileToStruct(confignamefile)
        if not config:
            print("CONFIG FILE EMPTY")
        else:
            print("CONFIG FILE LOADED")
            
        # Load trials file parameters
        trialsfile = ConfigFileToStruct(trialsnamefile)
        if not trialsfile:
            print("TRIALS FILE EMPTY")
            sys.exit()
        else:
            print("TRIALS FILE LOADED")
            numtrials = len(trialsfile)
            
    
        ## Initialize states of on_draw()
        show_welcome = 1
        show_stim = 0
        show_start_menu = 0
        show_trial_menu = 0
    
        show_trial_menu_release = 0 
    
        ## Load parameters
        randomize_trials = 1
        
        if randomize_trials:
            trials_array = np.random.permutation(numtrials) # goes from 0 to numtrials in random order
        else:
            trials_array = range(numtrials) # no random
        
        trial = 0
        trial_counter = 0
        
        load_config_parameters(config)
        load_trial_parameters(trialsfile,trials_array[trial_counter])
    
        ## Create output data file name
        out_file_name = create_filename()
    
        # Necessary variables for the data file
        count = 0
        dataclick   = [0]*15000
        datatime    = [0]*15000
        datatrial   = [0]*15000
        
        ## Message that will be shown between trials
        labelInterval = pyglet.text.Label("Click the mouse to start the next trial", font_name = 'Arial', 
                                      font_size = 20, x = myWindow.width/2, y = myWindow.height/2,
                                      anchor_x = "center", anchor_y = "center")
        
        ## Message that will be shown at startup
        textWelcome = "\t\t\t\tWelcome\n RIGHT click: Grating to the right is in front\n LEFT click: Grating to the left is in front\n\n LEFT click to start"
        labelWelcome = pyglet.text.Label(textWelcome, 
                                    font_name = 'Arial', font_size = 20, x = myWindow.width/2, y = myWindow.height/2, 
                                    multiline = True, width=600, anchor_x = "center", anchor_y = "center")
        
        
        ## Run stimulus
        
        # Set stimulus window to visible and mouse not visible
        myWindow.set_visible(1)
        myWindow.set_mouse_visible(0) 
        
        # initialize clock
        clockTrial = time.clock() # this clock will be reset for each trial    
    
        framerate = 1/60.0
        
        pyglet.clock.schedule_interval(update_frames,framerate)
    
        pyglet.app.run()


Thank you.
I have also posted this question in stackoverflow, for me it is easier to look the code in there, here is the link: http://stackoverflow.com/questions/24429153/pyglet-in-osx-blank-screen-with-config-context

"Juan J. Martínez"

unread,
Jun 26, 2014, 10:17:33 AM6/26/14
to pyglet...@googlegroups.com
On 26/06/14 15:15, Jose Luis Da wrote:
> Hi all,
>
> I am having problems with a pyglet script which works as expected in
> Windows, but it only displays a blank image in OSX. I have found that
> the reason of this blank screen is the config context option, which I
> use to activate the stencil as:
>

This rings a bell, could be this issue?

https://code.google.com/p/pyglet/issues/detail?id=532

Regards,

Juan

Jose Luis Da

unread,
Jun 26, 2014, 10:43:27 AM6/26/14
to pyglet...@googlegroups.com
Hi Juan, thank you for your response.

The attached code from the thread you linked give me the same output
('OpenGL version:', '2.1 NVIDIA-1.6.24')
('OpenGL 3.2 support:', False)

However, I do not have a lot of experience in pyglet, thus I do not know how to use the patch to solve this problem.

If I include the line pyglet.options['shadow_window'] == False I still get a blank screen.

I am using OSX 10.6, but I need the code to run on the recent OSX platforms too.


El dijous 26 de juny de 2014 16:17:33 UTC+2, Juan J. Martínez va escriure:

"Juan J. Martínez"

unread,
Jun 26, 2014, 11:00:23 AM6/26/14
to pyglet...@googlegroups.com
On 26/06/14 15:43, Jose Luis Da wrote:
> Hi Juan, thank you for your response.
>
> The attached code from the thread you linked give me the same output
> ('OpenGL version:', '2.1 NVIDIA-1.6.24')
> ('OpenGL 3.2 support:', False)
>
> However, I do not have a lot of experience in pyglet, thus I do not know
> how to use the patch to solve this problem.
>
> If I include the line *pyglet.options['shadow_window'] == False* I still
> get a blank screen.
>
> I am using OSX 10.6, but I need the code to run on the recent OSX
> platforms too.

OK, the "shadow window" is "easy" to understand (and hopefully I can
explain it heh), but I'm not sure if it's related to your problem. Keep
reading, just in case :)

When pyglet loads resources (images) it will create textures etc in your
GPU, so an opengl context is required.

If you load images *before* the opengl context is created (this is: when
the window is created), pyglet will create a "hidden" window with an
opengl context. Then it will share all the objects on that temporal
context with the final window when it's created.

This approach is really cool and makes everything simpler from the point
of view of the pyglet user without experience with opengl and the
internal on "how things work".

BUT sometimes this doesn't work too well (eg, crappy opengl drivers not
allowing shared opengl contexts -specially in Microsoft Windows-), and
apparently in the case described in that ticket.

Abstractions are useful until they get in the way. I never had a problem
with the shadow window until recently, and reviewing my old code it was
just a coincidence that I did things right loading resources after I
created the main window hah! :)

You can:

- disable the shadow window with the aforementioned option
- be sure you load all your resources *after* your window (and hence)
the opengl context is created

If you need a stencil (whatever that is; opengl newbie here!), it's
fine. If your problem is because of the shadow window and the shared
contexts, avoiding the shadow window should fix it!

More about this:

http://pyglet.org/doc-current/programming_guide/context.html#sharing-objects-between-contexts
http://pyglet.org/doc-current/internal/main.html#pyglet.options

Regards,

Juan

Adam Bark

unread,
Jun 26, 2014, 6:55:20 PM6/26/14
to pyglet...@googlegroups.com
On 26/06/14 15:43, Jose Luis Da wrote:
Hi Juan, thank you for your response.

The attached code from the thread you linked give me the same output
('OpenGL version:', '2.1 NVIDIA-1.6.24')
('OpenGL 3.2 support:', False)

However, I do not have a lot of experience in pyglet, thus I do not know how to use the patch to solve this problem.

If I include the line pyglet.options['shadow_window'] == False I still get a blank screen.

I am using OSX 10.6, but I need the code to run on the recent OSX platforms too.

So it isn't specifically the stencil buffer that is broken? Do you have the latest driver for your GPU? Do the pyglet examples display correctly?


El dijous 26 de juny de 2014 16:17:33 UTC+2, Juan J. Martínez va escriure:
On 26/06/14 15:15, Jose Luis Da wrote:
> Hi all,
>
> I am having problems with a pyglet script which works as expected in
> Windows, but it only displays a blank image in OSX. I have found that
> the reason of this blank screen is the config context option, which I
> use to activate the stencil as:
>

This rings a bell, could be this issue?

https://code.google.com/p/pyglet/issues/detail?id=532

Regards,

Juan
Good idea Juan but Jose is using all legacy drawing calls by the looks of it so a core profile would not work.

Da, Jose Luis

unread,
Jun 27, 2014, 4:45:38 AM6/27/14
to pyglet...@googlegroups.com
Juan: I do not think that the shadow window is the problem I have and I load all my resources after I initialize the context. Anyway, thank you for your response.

Adam: 
So it isn't specifically the stencil buffer that is broken? Do you have the latest driver for your GPU? Do the pyglet examples display correctly?
I do not think that the stencil buffer is broken. I think it is the openGL Config (pyglet.gl.Config) what does not work. I have tried other examples and old codes that work correctly when the openGL Config is not enabled. However, when I initialize the window in the following way, the pyglet window is completely blank:

allowstencil = pyglet.gl.Config()
window = pyglet.window.Window(config = allowstencil) 

Note that the pyglet.gl.Config() call is empty, but if I add the stencil option (below), the pyglet window is still blank.
allowstencil = pyglet.gl.Config(stencil_size=8)
window = pyglet.window.Window(config = allowstencil) 


And yes, I have the latest driver for my GPU.


Thank you for your answers!
jl


--
You received this message because you are subscribed to a topic in the Google Groups "pyglet-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyglet-users/Ml6B0yPKHkQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyglet-users...@googlegroups.com.
To post to this group, send email to pyglet...@googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Da, Jose Luis

unread,
Jul 8, 2014, 9:40:47 AM7/8/14
to pyglet...@googlegroups.com
Sorry to bother you again. Did I explain myself well? Just a reply, even if it was "I have no idea" would be fantastic!

Adam Bark

unread,
Jul 8, 2014, 6:34:58 PM7/8/14
to pyglet...@googlegroups.com
On 08/07/14 14:40, Da, Jose Luis wrote:
Sorry to bother you again. Did I explain myself well? Just a reply, even if it was "I have no idea" would be fantastic!


On 27 June 2014 09:45, Da, Jose Luis <joselu...@upf.edu> wrote:
Juan: I do not think that the shadow window is the problem I have and I load all my resources after I initialize the context. Anyway, thank you for your response.

Adam: 
So it isn't specifically the stencil buffer that is broken? Do you have the latest driver for your GPU? Do the pyglet examples display correctly?
I do not think that the stencil buffer is broken. I think it is the openGL Config (pyglet.gl.Config) what does not work. I have tried other examples and old codes that work correctly when the openGL Config is not enabled. However, when I initialize the window in the following way, the pyglet window is completely blank:

allowstencil = pyglet.gl.Config()
window = pyglet.window.Window(config = allowstencil) 

Note that the pyglet.gl.Config() call is empty, but if I add the stencil option (below), the pyglet window is still blank.
allowstencil = pyglet.gl.Config(stencil_size=8)
window = pyglet.window.Window(config = allowstencil) 


And yes, I have the latest driver for my GPU.


Thank you for your answers!
jl

Can you check this bit of the docs http://pyglet.org/doc-current/api/pyglet/pyglet.window.html#specifying-the-opengl-context-properties and see if the configuration is supported.

Da, Jose Luis

unread,
Jul 9, 2014, 10:05:42 AM7/9/14
to pyglet...@googlegroups.com
Hi Adam, thanks for your answer.

I have added this bit of code to see if the config is supported

allowstencil = pyglet.gl.Config(stencil_size=8)
if not allowstencil:
    print "no allowstencil"
    myWindow = pyglet.window.Window(fullscreen=False,screen=screens[0], visible = 0)
else:
    print "YES allowstencil"

    # Create window (not visible at start)
    myWindow = pyglet.window.Window(config=allowstencil,fullscreen=False,screen=screens[0], visible = 0)

And it is indeed supported. But the window is still blank.

Do you have any other idea why this may happen?


--

Adam Bark

unread,
Jul 9, 2014, 6:01:11 PM7/9/14
to pyglet...@googlegroups.com
Not really, sorry. Do other pyglet programs work fine? Have you run through the test suite? Can you test any other graphics cards so we can eliminate the graphics driver as the problem? Would you mind sharing the code or, better still, a minimal example of the problem in the hope that someone else running OSX will test it? Maybe open an issue on googlecode, post the code there and email a link.

Da, Jose Luis

unread,
Jul 10, 2014, 9:42:24 AM7/10/14
to pyglet...@googlegroups.com
Hi, 
Other pyglet programs run fine if they do not use a config.

I do not think it is the graphics card because I am running Windows OS in the same computer and the code runs fine there.

You can see the code in this github repository https://github.com/thisisjl/NuEyePlaid

Thank you, I really appreciate your time!
jl


--
Reply all
Reply to author
Forward
0 new messages