Raymond Liu | 23 Jul 21:17 2014
Picon

One window handling another window's events.

Hi! I have two subclasses of pyglet, InfoWindow and MainWindow. I have one instance of each, info_window and main_window. This is just a toy example. I want info_window to display the mouse coordinates when it's in main_window, not when it's in itself. I thought obviously I need to use the on_mouse_motion event. But when I use this event in info_window, it only catches mouse motion in itself, not main_window. So the question is, how do I make info_window handle the on_mouse_motion event that occurs in main_window?

I realise that there are other ways of achieving my desired behaviour, but I thought it would be quite nice to be able to achieve it the way I described above, that is, handling another window's event. Is it possible?

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Jose Luis Da | 15 Jul 17:31 2014

How to listen for a specific event?

Hi all, 

I want to, within a loop, check at a certain point if the left button of the mouse, for example, has been pressed. I know that you have to use the method "on_mouse_press", but I do not know how to assign the return of the function to a variable, because I do not know how to call this function at a certain point.

Is there a way to bypass "on_mouse_press" and call directly a method that only listens to the mouse?


Thank you,
jl

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
snheath | 10 Jul 09:33 2014

Screen tearing in compositing WM

Hey all,
Just noticed that when you play my game in a linux system using a window manager with compositing
turned on (I'm using MATE) you get a lot of screen tearing, even when vsync is enabled.  Does
anyone know what causes this, and what I can do to avoid it?

Example video here: https://www.youtube.com/watch?v=3ROPYmIuJmw

Thanks,
Simon

--

-- 
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Raymond Liu | 6 Jul 17:05 2014
Picon

Error in the docs

Hi! Just spotted a slight error in the 1.2 docs page, here, where a sentence appears as "Locations in the path beginning with an ampersand (‘’ <at> ’’ symbol) specify Python packages." I'd like to politely point out that the " <at> " symbol is not ampersand. The ampersand symbol is "&"; the " <at> " symbol is the "at sign". Check wikipedia.

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Raymond Liu | 6 Jul 16:49 2014
Picon

Migrating from PyGame, enlarge image by 2.

Hi! I've been using PyGame until now. I'm no expert at PyGame, and have been told that Pyglet is more pythonic and elegant. Having had a brief stroll through the programming guide, I agree! I love the decorators for one thing.

I'm building a GUI app for myself, and one of the most important funcionalities is that it is able to display images at 2x, 4x, or 8x its original size, and that the enlargement be done jaggieless. I know that PyGame has pygame.transform.scale2x() that does this. Is there an equivalent Pyglet way of doing this? I had a quick read through the programming guide and couldn't find anything. I'd be happy even with a non-jaggieless way of scaling images. Please help. Thank you!

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Aldy Syahdeini | 4 Jul 08:54 2014
Picon

Asking about pyglet ability

Hey, I need to make a 3d model of colliery, I have used direct3d (managed directx) but it I got stuck on picking 3d point.
now,I try to find alternative library such us pyglet. 
So I have collection of random x,y,z point (in txt) and I try to make terrain, because the point is random some of my friend suggest 
using tin ( triangulated irregular network ) to make it look solid, is there any alternative solution in pyglet for generating solid terrain of random points?
I also need to click on the point on the terrain so I know the x,y,z positition of the point, is this possible in pyglet?
thanks.

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Peter Vaňušanik | 28 Jun 04:55 2014
Picon

Re: Draw on texture/buffer

Shouldn't you be abusing your son? :P

On Sat, Jun 28, 2014 at 12:51 AM, Gendo Ikari <komradstudios <at> gmail.com> wrote:
Hi.
I want to use pyglet to compose images from text, other images, etc... (rotations, resizings, and so on). I do not need any window. I'm just using pyglet as a nice layer upon opengl to manipulate textures.
I've got a few questions.
1) How can I change the active framebuffer?
2) How can I draw on a specific image/texture? (blit is not enough, not all pyglet objects have a blit_into method).
3) How can I save image with specific DPI?
Thank you in advance.

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Gendo Ikari | 28 Jun 00:51 2014
Picon

Draw on texture/buffer

Hi.
I want to use pyglet to compose images from text, other images, etc... (rotations, resizings, and so on). I do not need any window. I'm just using pyglet as a nice layer upon opengl to manipulate textures.
I've got a few questions.
1) How can I change the active framebuffer?
2) How can I draw on a specific image/texture? (blit is not enough, not all pyglet objects have a blit_into method).
3) How can I save image with specific DPI?
Thank you in advance.

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Ruben Arutyunov | 27 Jun 20:16 2014
Picon

How can i play previous file from the queue?

Hi, I'm trying to play mp3 files using pyglet. And I need to get and play previous file from the queue. There is a method next, but I couldn't find any method for getting previous. How can I do that?

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
Jose Luis Da | 26 Jun 16:15 2014

Pyglet in OSX: blank screen with config context

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"]
    
    
        
    <at> 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
    
    <at> 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()
    
            
    <at> 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
        
    <at> 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

--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.
snheath | 26 Jun 02:40 2014

Line drawing in pyglet

Hi all,

So I'm planning on making a game that uses a lot of vector-y line graphics, and I was trying to figure out the
best way of doing this, since it's not really something pyglet is designed for.  The best method appears to
be to create VertexLists and draw them with GL_LINES.  I would essentially be making something equivalent
to the Sprite class, but just drawing in a different way.  The problem with this is that then I have to create
entirely new sets of lines for each new position and rotation and such, essentially doing the affine
transforms in software (which is probably okay but doing heavy math in Python always makes me cautious),
and then update the VertexList pushing the new points out to the graphics card on each draw call.  The other
option is to build the matrices and have vertex shaders do the transform, or use the glTranslate/glRotate
functions and try not to munge pyglet's drawing state up too much in the process.

So, basically, am I understanding my options correctly, and does anyone have any suggestions on what might
be the best approach?  I know enough about OpenGL to use it badly and really prefer avoiding it if possible,
but it would also be nice to be able to draw fairly complicated shapes (a few hundred verts maybe).

Thanks,
Simon

--

-- 
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users+unsubscribe <at> googlegroups.com.
To post to this group, send email to pyglet-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.


Gmane