rougier / pyglfw Goto Github PK
View Code? Open in Web Editor NEWPython bindings for GLFW 3.0
Python bindings for GLFW 3.0
# ----------------------------------------------------------------------------- # GLFW - An OpenGL framework # API version: 3.0.1 # WWW: http://www.glfw.org/ # ---------------------------------------------------------------------------- # Copyright (c) 2002-2006 Marcus Geelnard # Copyright (c) 2006-2010 Camilla Berglund # # Python bindings - Copyright (c) 2013 Nicolas P. Rougier # # This software is provided 'as-is', without any express or implied # warranty. In no event will the authors be held liable for any damages # arising from the use of this software. # # Permission is granted to anyone to use this software for any purpose, # including commercial applications, and to alter it and redistribute it # freely, subject to the following restrictions: # # 1. The origin of this software must not be misrepresented; you must not # claim that you wrote the original software. If you use this software # in a product, an acknowledgment in the product documentation would # be appreciated but is not required. # # 2. Altered source versions must be plainly marked as such, and must not # be misrepresented as being the original software. # # 3. This notice may not be removed or altered from any source # distribution. # # -----------------------------------------------------------------------------
Only one letter shown as title when creating a window on Windows. Except that, everything works fine. If I deleted the explicit title parameter, only a G
is shown at the position of the title.
How to solve that?
The system is Windows 10 and with Python 3.7.3. The version of GLFW is 3.3.
There is no setup.py file, so installation via pip is not currently possible.
Hi, first of all, thanks for maintaining this wrapper. I just tried to get full screen mode working under Mac OS X (El Capitan) and I'm getting a segfault when trying to use the monitor information functions. This python code will crash:
import glfw
glfw.glfwInit()
monitor = glfw.glfwGetPrimaryMonitor()
print("Monitor:", monitor, type(monitor))
print(glfw.glfwGetVideoModes(monitor))
This will print:
Monitor: 441455392 <class 'int'>
Segmentation fault: 11
I'm finding it a bit strange that monitor is listed with type 'int'... shouldn't it be size_t or similar?
The equivalent C++ code works fine. I'll try it on a 64 bit Linux machine tomorrow.
On python3, glfw.glfwGetVideoMode(monitor) will fail with the following error:
File "/home/drluke/prog/cockamamie/pyglfw/glfw.py", line 576, in glfwGetVideoMode
return (c_mode.width,
AttributeError: 'LP_GLFWvidmode' object has no attribute 'width'
One working fix is to change the function from
def glfwGetVideoMode(monitor):
_glfw.glfwGetVideoMode.restype = POINTER(GLFWvidmode)
c_mode = _glfw.glfwGetVideoMode(monitor)
return (c_mode.width,
c_mode.height,
c_mode.redBits,
c_mode.blueBits,
c_mode.greenBits,
c_mode.refreshRate )
to
def glfwGetVideoMode(monitor):
_glfw.glfwGetVideoMode.restype = POINTER(GLFWvidmode)
c_mode = _glfw.glfwGetVideoMode(monitor)
return (c_mode[0].width,
c_mode[0].height,
c_mode[0].redBits,
c_mode[0].blueBits,
c_mode[0].greenBits,
c_mode[0].refreshRate )
I am not certain if this breaks functionality for python2 though, so I didn't yet submit a pullrequest.
What file should _glfw_file point to?
_glfw = ctypes.CDLL(_glfw_file)
Or the GLFW_LIBRARY system variable if you will.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.