Search Results

Search found 27 results on 2 pages for 'pyglet'.

Page 1/2 | 1 2  | Next Page >

  • Pyglet OpenGL drawing anti-aliasing

    - by Jared Forsyth
    I've been looking around for a way to anti-alias lines in OpenGL, but none of them seem to work... here's some example code: import pyglet from pyglet.gl import * window = pyglet.window.Window(resizable=True) @window.event def on_draw(): window.clear() pyglet.gl.glColor4f(1.0,0,0,1.0) glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glEnable (GL_BLEND) glEnable (GL_LINE_SMOOTH); glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE) glLineWidth (3) pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i', (10, 15, 300, 305)) ) pyglet.app.run() Can anyone see what I am doing wrong?

    Read the article

  • Pyglet: How to use second screen's vsync

    - by BaldDude
    does anybody know if it's possible to use the vsync of the second monitor instead of the first one with pyglet? I have 2 monitors, one running at 60Hz and the other at 120Hz. I want to be able to set my application on whatever monitors I have, and have the application use the monitor's rate to swap the buffers. This needs to be cross platform. I found this information... pyglet.window But I was wondering if anybody knows a way... Thanks for your help.

    Read the article

  • 2D animation example in pyglet (python) looping through 2 images/sprites every x seconds

    - by Bentley4
    Suppose you have two images: step1.png and step2.png . Can anyone show me a very simple example in pyglet how to loop through those 2 images say every 0.5 seconds? The character doesn't have to move, just a simple black screen with a fixed region wherein the two images continually change every 0.5 secs. I know how to make a character move, shoot projectiles etc. but I just can't figure out how to control the looping speed of the images.

    Read the article

  • Pyglet vs. PyQt

    - by L. De Leo
    I need to implement a really simple card game. As the game logic is written in Python I chose to stick with some Python framework even if my goal is to develop a Windows only version. I also don't like to work with .NET so I ruled out Iron Python + WPF. I tried to write a simple prototype with Pyglet but soon discovered that I will have to do a lot of stuff by hand: things like detecting mouseover events and finding which card was clicked on and moving it, etc... very low level and unnecessary for my use-case. So I thought it might be easier to do things in PyQt. Do you reckon it would be feasible to use PyQt for implementing a simple card game? Will I have higher level events I can work with?

    Read the article

  • motion computation from video using pyglet in python

    - by kuaywai
    Hi, I am writing a simple motion detection program but i want it to be cross platform so im using python and the pyglet library since it provides a simple way to load videos in different formats (specially wmv and mpeg). So far i have the code given below which loads the movie and plays it in a window. Now i need to: 1) grab frame at time t and t-1 2) do a subtraction to see which pixels are active for motion detection. any ideas on how to grab frames and to skip over frames and is it possible to put the pixel values into a matrix in numpy or something directly from pyglet? or should look into using something other than pyglet? thanks kuaywai import pyglet import sys window = pyglet.window.Window(resizable=True) window.set_minimum_size(320,200) window.set_caption('Motion detect 1.0') video_intro = pyglet.resource.media('movie1.wmv') player = pyglet.media.Player() player.queue(video_intro) print 'calculating movie size...' if not player.source or not player.source.video_format: sys.exit myWidth = player.source.video_format.width myHeight = player.source.video_format.height if player.source.video_format.sample_aspect 1: myWidth *= player.source.video_format.sample_aspect elif player.source.video_format.sample_aspect < 1: myHeight /= player.source.video_format.sample_aspect print 'its size is %d,%d' % (myWidth,myHeight) player.play() @window.event def on_draw(): window.clear() (w,h) = window.get_size() player.get_texture().blit(0, h-myHeight, width=myWidth, height=myHeight) pyglet.app.run()

    Read the article

  • How to keep pyglet from clearing the screen ?

    - by mayasky
    I want to draw a scene and sequentially add lines to it. But pyglet keeps updating without control :( , so all I get is blinks from pyglet.gl import * window=pyglet.window.Window() def drawline(): ... @window.event def on_draw(): drawline() pyglet.app.run() should I change the decorator(if there exist options) or what? Thanks!

    Read the article

  • Will I have an easier time learning OpenGL in Pygame or Pyglet? (NeHe tutorials downloaded)

    - by shadowprotocol
    I'm looking between PyGame and Pyglet, Pyglet seems to be somewhat newer and more Pythony, but it's last release according to Wikipedia is January '10. PyGame seems to have more documentation, more recent updates, and more published books/tutorials on the web for learning. I downloaded both the Pyglet and PyGame versions of the NeHe OpenGL tutorials (Lessons 1-10) which cover this material: lesson01 - Setting up the window lesson02 - Polygons lesson03 - Adding color lesson04 - Rotation lesson05 - 3D lesson06 - Textures lesson07 - Filters, Lighting, input lesson08 - Blending (transparency) lesson09 - 2D Sprites in 3D lesson10 - Moving in a 3D world What do you guys think? Is my hunch that I'll be better off working with PyGame somewhat warranted?

    Read the article

  • How to draw image in memory manually in pyglet?

    - by Mossen
    In pyglet, I want to create an image buffer in memory, then set the bytes manually, then draw it. I tried making a 3x3 red square like this in my draw() function: imageData = pyglet.image.ImageData(3, 3, 'RGB', [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 ]) imageData.blit(10, 10) ...but at runtime, Python complains: ctypes.ArgumentError: argument 9: <type 'exceptions.TypeError'>: wrong type Is this the right approach? Am I missing a step? How can I fix this?

    Read the article

  • pyglet and animated gif

    - by wtzolt
    Hello, I have a message box pop up when a certain operation is being executed sort of "wait..." window and I want to have a "loading" *.gif animation there to lighten up the mood :) Anyways I can't seem to figure out how to make this work. It's a complete mess. I tried calling through class but i get loads of errors to do with pyglet itself. class messageBox: def __init__(self, lbl_msg = 'Message here', dlg_title = ''): self.wTree = gtk.glade.XML('msgbox.glade') self.wTree.get_widget('label1').set_text(lbl_msg) self.wTree.get_widget('dialog1').set_title(dlg_title) ????sprite = pyglet.sprite.Sprite(pyglet.resource.animation("wait.gif")) ????self.wTree.get_widget('waitt').set_from_file(sprite) [email protected] ????def on_draw(): ???? win.clear() ???? sprite.draw() handlers = { 'on_okbutton1_clicked':self.gg } self.wTree.signal_autoconnect( handlers ) self.wTree.get_widget("dialog1").set_keep_above(True) def done(self): self.wTree.get_widget('dialog1').destroy() def gg(self,w): self.wTree.get_widget('dialog1').destroy() --------- @yieldsleep def popup(self, widget, data=None): self.msg = messageBox('Wait...','') ?what to call here? yield 500 print '1' yield 500 print '2' yield 500 print '3' self.msg.done() self.msg = messageBox('Done! ','') yield 700 self.msg.done()

    Read the article

  • putpixel with pyglet

    - by pts
    I'm new to pyglet. I'd like to change a pixel from black to white at each on_draw iteration. So after 1000 iterations, there should be exactly 1000 white pixels in the window. However, I'd like to avoid calling 1000 draw operations in on_draw for that. So I'd like to create an image, do an RGB putpixel on the image, and blit the image to the screen. How can I do that? The pyglet documentation, the examples and the source code aren't too helpful on this.

    Read the article

  • How can I resize pixel art in Pyglet without making it blurry?

    - by Renold
    I have a tileset of 8x8 pixel images, and I want to resize them in my game so they'd be double that (16x16 pixels, e.g. turning each pixel into a 2x2 block.) What I'm trying to achieve is a Minecraft-like effect, where you have small pixel images scale to larger blockier pixels. In Pyglet, the sprite's scale property blurs the pixels. Is there some other way? Update: So I changed my code, but I'm still having the same issue (nothing changed.) Of course, the GL commands are kind of mysterious to me: gl.glEnable(gl.GL_TEXTURE_2D) image = resource.image('tileset.png') texture = image.get_texture() gl.glBindTexture(gl.GL_TEXTURE_2D, texture.id) gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST) texture.width = 16 # resize from 8x8 to 16x16 texture.height = 16 image.blit(100, 30) # draw Is there something else I should try?

    Read the article

  • Frame Buffers wont work with pyglet.

    - by Matthew Mitchell
    I have this code: def setup_framebuffer(surface): #Create texture if not done already if surface.texture is None: create_texture(surface) #Render child to parent if surface.frame_buffer is None: surface.frame_buffer = glGenFramebuffersEXT(1) glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, surface.frame_buffer) glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, surface.texture, 0) glPushAttrib(GL_VIEWPORT_BIT) glViewport(0,0,surface._scale[0],surface._scale[1]) glMatrixMode(GL_PROJECTION) glLoadIdentity() #Load the projection matrix gluOrtho2D(0,surface._scale[0],0,surface._scale[1]) glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, surface.frame_buffer) for this despite the second parameter printing as 1 for a test I did, I get: glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, surface.frame_buffer) I only got this after implementing pyglet. GLUT is too limited. Thank you.

    Read the article

  • "TypeError: draw() takes exactly 1 non-keyword argument (3 given)"

    - by Amorack
    I wrote this code to open a window with Pyglet in Python... import pyglet from pyglet import window class Window(pyglet.window.Window): def __init__(self): super(Window, self).__init__() myLabel = pyglet.text.Label("Prototype") windowText = myLabel.draw(Window, "Hello World", font_name = "Times New Roman", font_size = 36, color = (193, 205, 193, 255)) def on_draw(self): self.clear() self.label.draw() if __name__ == '__main__': window = Window() pyglet.app.run() however every time I run it I get this error: TypeError: draw() takes exactly 1 non-keyword argument (3 given) AFAIK the "(3 given)" means the problem is with the font_size or color arguments but I'm not sure. Could someone explain what's wrong and help me make this work?

    Read the article

  • OpenGL basics: calling glDrawElements once per object

    - by Bethor
    Hi all, continuing on from my explorations of the basics of OpenGL (see this question), I'm trying to figure out the basic principles of drawing a scene with OpenGL. I am trying to render a simple cube repeated n times in every direction. My method appears to yield terrible performance : 1000 cubes brings performance below 50fps (on a QuadroFX 1800, roughly a GeForce 9600GT). My method for drawing these cubes is as follows: done once: set up a vertex buffer and array buffer containing my cube vertices in model space set up an array buffer indexing the cube for drawing as 12 triangles done for each frame: update uniform values used by the vertex shader to move all cubes at once done for each cube, for each frame: update uniform values used by the vertex shader to move each cube to its position call glDrawElements to draw the positioned cube Is this a sane method ? If not, how does one go about something like this ? I'm guessing I need to minimize calls to glUniform, glDrawElements, or both, but I'm not sure how to do that. Full code for my little test : (depends on gletools and pyglet) I'm aware that my init code (at least) is really ugly; I'm concerned with the rendering code for each frame right now, I'll move to something a little less insane for the creation of the vertex buffers and such later on. import pyglet from pyglet.gl import * from pyglet.window import key from numpy import deg2rad, tan from gletools import ShaderProgram, FragmentShader, VertexShader, GeometryShader vertexData = [-0.5, -0.5, -0.5, 1.0, -0.5, 0.5, -0.5, 1.0, 0.5, -0.5, -0.5, 1.0, 0.5, 0.5, -0.5, 1.0, -0.5, -0.5, 0.5, 1.0, -0.5, 0.5, 0.5, 1.0, 0.5, -0.5, 0.5, 1.0, 0.5, 0.5, 0.5, 1.0] elementArray = [2, 1, 0, 1, 2, 3,## back face 4, 7, 6, 4, 5, 7,## front face 1, 3, 5, 3, 7, 5,## top face 2, 0, 4, 2, 4, 6,## bottom face 1, 5, 4, 0, 1, 4,## left face 6, 7, 3, 6, 3, 2]## right face def toGLArray(input): return (GLfloat*len(input))(*input) def toGLushortArray(input): return (GLushort*len(input))(*input) def initPerspectiveMatrix(aspectRatio = 1.0, fov = 45): frustumScale = 1.0 / tan(deg2rad(fov) / 2.0) fzNear = 0.5 fzFar = 300.0 perspectiveMatrix = [frustumScale*aspectRatio, 0.0 , 0.0 , 0.0 , 0.0 , frustumScale, 0.0 , 0.0 , 0.0 , 0.0 , (fzFar+fzNear)/(fzNear-fzFar) , -1.0, 0.0 , 0.0 , (2*fzFar*fzNear)/(fzNear-fzFar), 0.0 ] return perspectiveMatrix class ModelObject(object): vbo = GLuint() vao = GLuint() eao = GLuint() initDone = False verticesPool = [] indexPool = [] def __init__(self, vertices, indexing): super(ModelObject, self).__init__() if not ModelObject.initDone: glGenVertexArrays(1, ModelObject.vao) glGenBuffers(1, ModelObject.vbo) glGenBuffers(1, ModelObject.eao) glBindVertexArray(ModelObject.vao) initDone = True self.numIndices = len(indexing) self.offsetIntoVerticesPool = len(ModelObject.verticesPool) ModelObject.verticesPool.extend(vertices) self.offsetIntoElementArray = len(ModelObject.indexPool) ModelObject.indexPool.extend(indexing) glBindBuffer(GL_ARRAY_BUFFER, ModelObject.vbo) glEnableVertexAttribArray(0) #position glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ModelObject.eao) glBufferData(GL_ARRAY_BUFFER, len(ModelObject.verticesPool)*4, toGLArray(ModelObject.verticesPool), GL_STREAM_DRAW) glBufferData(GL_ELEMENT_ARRAY_BUFFER, len(ModelObject.indexPool)*2, toGLushortArray(ModelObject.indexPool), GL_STREAM_DRAW) def draw(self): glDrawElements(GL_TRIANGLES, self.numIndices, GL_UNSIGNED_SHORT, self.offsetIntoElementArray) class PositionedObject(object): def __init__(self, mesh, pos, objOffsetUf): super(PositionedObject, self).__init__() self.mesh = mesh self.pos = pos self.objOffsetUf = objOffsetUf def draw(self): glUniform3f(self.objOffsetUf, self.pos[0], self.pos[1], self.pos[2]) self.mesh.draw() w = 800 h = 600 AR = float(h)/float(w) window = pyglet.window.Window(width=w, height=h, vsync=False) window.set_exclusive_mouse(True) pyglet.clock.set_fps_limit(None) ## input forward = [False] left = [False] back = [False] right = [False] up = [False] down = [False] inputs = {key.Z: forward, key.Q: left, key.S: back, key.D: right, key.UP: forward, key.LEFT: left, key.DOWN: back, key.RIGHT: right, key.PAGEUP: up, key.PAGEDOWN: down} ## camera camX = 0.0 camY = 0.0 camZ = -1.0 def simulate(delta): global camZ, camX, camY scale = 10.0 move = scale*delta if forward[0]: camZ += move if back[0]: camZ += -move if left[0]: camX += move if right[0]: camX += -move if up[0]: camY += move if down[0]: camY += -move pyglet.clock.schedule(simulate) @window.event def on_key_press(symbol, modifiers): global forward, back, left, right, up, down if symbol in inputs.keys(): inputs[symbol][0] = True @window.event def on_key_release(symbol, modifiers): global forward, back, left, right, up, down if symbol in inputs.keys(): inputs[symbol][0] = False ## uniforms for shaders camOffsetUf = GLuint() objOffsetUf = GLuint() perspectiveMatrixUf = GLuint() camRotationUf = GLuint() program = ShaderProgram( VertexShader(''' #version 330 layout(location = 0) in vec4 objCoord; uniform vec3 objOffset; uniform vec3 cameraOffset; uniform mat4 perspMx; void main() { mat4 translateCamera = mat4(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, cameraOffset.x, cameraOffset.y, cameraOffset.z, 1.0f); mat4 translateObject = mat4(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, objOffset.x, objOffset.y, objOffset.z, 1.0f); vec4 modelCoord = objCoord; vec4 positionedModel = translateObject*modelCoord; vec4 cameraPos = translateCamera*positionedModel; gl_Position = perspMx * cameraPos; }'''), FragmentShader(''' #version 330 out vec4 outputColor; const vec4 fillColor = vec4(1.0f, 1.0f, 1.0f, 1.0f); void main() { outputColor = fillColor; }''') ) shapes = [] def init(): global camOffsetUf, objOffsetUf with program: camOffsetUf = glGetUniformLocation(program.id, "cameraOffset") objOffsetUf = glGetUniformLocation(program.id, "objOffset") perspectiveMatrixUf = glGetUniformLocation(program.id, "perspMx") glUniformMatrix4fv(perspectiveMatrixUf, 1, GL_FALSE, toGLArray(initPerspectiveMatrix(AR))) obj = ModelObject(vertexData, elementArray) nb = 20 for i in range(nb): for j in range(nb): for k in range(nb): shapes.append(PositionedObject(obj, (float(i*2), float(j*2), float(k*2)), objOffsetUf)) glEnable(GL_CULL_FACE) glCullFace(GL_BACK) glFrontFace(GL_CW) glEnable(GL_DEPTH_TEST) glDepthMask(GL_TRUE) glDepthFunc(GL_LEQUAL) glDepthRange(0.0, 1.0) glClearDepth(1.0) def update(dt): print pyglet.clock.get_fps() pyglet.clock.schedule_interval(update, 1.0) @window.event def on_draw(): with program: pyglet.clock.tick() glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) glUniform3f(camOffsetUf, camX, camY, camZ) for shape in shapes: shape.draw() init() pyglet.app.run()

    Read the article

  • Axis Aligned Billboard: how to make the object look at camera

    - by user19787
    I am trying to make an Axis Aligned Billboard with Pyglet. I have looked at several tutorials, but they only show me how to get the Up,Right,and Look vectors. So far this is what I have: target = cam.pos look = norm( target - billboard.pos ) right = norm( Vector3(0,1,0)*look ) up = look*right gluLookAt( look.x, look.y, look.z, self.pos.x, self.pos.y, self.pos.z, up.x, up.y, up.z ) This does nothing for me visibly. Any idea what I'm doing wrong?

    Read the article

  • How do I implement camera axis aligned billboards?

    - by user19787
    I am trying to make an axis-aligned billboard with Pyglet. I have looked at several tutorials, but they only show me how to get the up, right, and look vectors. So far this is what I have: target = cam.pos look = norm(target - billboard.pos) right = norm(Vector3(0,1,0) * look) up = look * right gluLookAt( look.x, look.y, look.z, self.pos.x, self.pos.y, self.pos.z, up.x, up.y, up.z ) This does nothing for me visibly. Any idea what I'm doing wrong?

    Read the article

  • Python "draw() must be called with Label instance as first argument (got _WindowMetaclass instance i

    - by Amorack
    This is a class I made using Python with pyglet to display a window. class Window(pyglet.window.Window): def __init__(self): super(Window, self).__init__() pyglet.text.Label("Prototype") windowText = text.Label.draw(Window, "Hello World", font_name = "Times New Roman", font_size = 36, color = (193, 205, 193, 255)) def on_draw(self): self.clear() self.label.draw() Every time I try to run it I get the error "TypeError: unbound method draw() must be called with Label instance as first argument (got _WindowMetaclass instance instead)". I'm pretty sure I know what I have to do (find how to get Label's instance) just not how to do it. Could someone help me understand how to make this work?

    Read the article

  • IronPython and Nodebox in C#

    - by proxylittle
    My plan: I'm trying to setup my C# project to communicate with Nodebox to call a certain function which populates a graph and draws it in a new window. Current situation: [fixed... see Update2] I have already included all python-modules needed, but im still getting a Library 'GL' not found it seems that the pyglet module needs a reference to GL/gl.h, but can't find it due to IronPython behaviour. Requirement: The project needs to stay as small as possible without installing new packages. Thats why i have copied all my modules into the project-folder and would like to keep it that or a similar way. My question: Is there a certain workaround for my problem or a fix for the library-folder missmatch. Have read some articles about Tao-Opengl and OpenTK but can't find a good solution. Update1: Updated my sourcecode with a small pyglet window-rendering example. Problem is in pyglet and referenced c-Objects. How do i include them in my c# project to be called? No idea so far... experimenting alittle now. Keeping you updated. SampleCode C#: ScriptRuntimeSetup setup = Python.CreateRuntimeSetup(null); ScriptRuntime runtime = new ScriptRuntime(setup); ScriptEngine engine = Python.GetEngine(runtime); ScriptSource source = engine.CreateScriptSourceFromFile("test.py"); ScriptScope scope = engine.CreateScope(); source.Execute(scope); SampleCode Python (test.py): from nodebox.graphics import * from nodebox.graphics.physics import Vector, Boid, Flock, Obstacle flock = Flock(50, x=-50, y=-50, width=700, height=400) flock.sight(80) def draw(canvas): canvas.clear() flock.update(separation=0.4, cohesion=0.6, alignment=0.1, teleport=True) for boid in flock: push() translate(boid.x, boid.y) scale(0.5 + boid.depth) rotate(boid.heading) arrow(0, 0, 15) pop() canvas.size = 600, 300 def main(canvas): canvas.run(draw) Update2: Line 139 [pyglet/lib.py] sys.platform is not win32... there was the error. Fixed it by just using the line: from pyglet.gl.lib_wgl import link_GL, link_GLU, link_WGL Now the following Error: 'module' object has no attribute '_getframe' Kind of a pain to fix it. Updating with results... Update3: Fixed by adding following line right after first line in C#-Code: setup.Options["Frames"] = true; Current Problem: No module named unicodedata, but in Python26/DLLs is only a *.pyd file`. So.. how do i implement it now?!

    Read the article

  • Brainworkshop won't go fullscreen

    - by user1777025
    I am unable to run brainworkshop in fullscreen mode. After correctly changing the config.ini file to launch the script in fullscreen mode all I get is a window of the same size as before but with no frame or title bar, aligned to the top right (below the menu bar and to the right of the edge of the screen). I tried posting a screenshot but as I'm a new user I wasn't allowed to... I tried looking around in the pyglet files to see if I could find anything that might be causing this but it's all beyond me. Any suggestions? Right after posting this I relaunched the script and now the same borderless, resizeable window is launched aligned to the bottom right hand corner of the screen... I'm running ubuntu 12.04 and brainworkshop 4.8.4.

    Read the article

  • Fastest python/C++ multimedia library

    - by Matthew Mitchell
    I'm using pyglet for my OpenGL based game but is it the fastest library out there which has a python wrapper? I could create a C++ extension and use any C++ multimedia library. Are there any C++ libraries that are worth investing time into or is it not worth the extra work? Thank you.

    Read the article

1 2  | Next Page >