Initial GLFW fixes
This commit is contained in:
parent
4373f59cdb
commit
45db8cdd22
10 changed files with 204 additions and 155 deletions
68
.gitignore
vendored
68
.gitignore
vendored
|
|
@ -1,15 +1,55 @@
|
|||
# build folders
|
||||
gltools/build/
|
||||
gltool/@docs/build/
|
||||
gltool/@docs/html/
|
||||
# compiled python files
|
||||
*.pyc
|
||||
*.pyo
|
||||
# python extension modules
|
||||
*.pyd
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
# libraries
|
||||
*.dll
|
||||
*.a
|
||||
# object files
|
||||
*.o
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
bin/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
.tox/
|
||||
.coverage
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
# Mr Developer
|
||||
.mr.developer.cfg
|
||||
.project
|
||||
.pydevproject
|
||||
|
||||
# Rope
|
||||
.ropeproject
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
*.pot
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# gltools build
|
||||
MANIFEST
|
||||
|
|
|
|||
1
Makefile
1
Makefile
|
|
@ -32,6 +32,7 @@ clean:
|
|||
-rm gltools/@src/Config.pxi
|
||||
-rm gltools/gltools.cpp gltools.so gltools/gltools.so MANIFEST
|
||||
-find gltools -iname '*.so' -exec rm {} \;
|
||||
-find gltools -iname '*.dll' -exec rm {} \;
|
||||
-find gltools -iname '*.pyc' -exec rm {} \;
|
||||
-find gltools -iname '*.pyo' -exec rm {} \;
|
||||
-find gltools -iname '*.pyd' -exec rm {} \;
|
||||
10
README.rst
10
README.rst
|
|
@ -21,22 +21,16 @@ Building
|
|||
|
||||
* Python 2.7/3.x and Cython 0.17 or later.
|
||||
* The geotools_ library.
|
||||
* GLFW_ v3.0 (not released, must be build from GIT repo)
|
||||
* GLFW_ v3.0
|
||||
* OpenGL headers
|
||||
|
||||
Prebuild installers are available on the pypi_ site
|
||||
for the Windows platform.
|
||||
|
||||
For Linux build scripts are available for ArchLinux in the AUR_
|
||||
repository. These could be adapted to other Linux distros.
|
||||
|
||||
Note that currently I can not find a way to install the required
|
||||
Cython 'pxd' files with distutils and this file has to be copied
|
||||
manually.
|
||||
|
||||
History
|
||||
=======
|
||||
|
||||
* v0.2.1 : Updated to released version of GLFW3
|
||||
* v0.1.1 : Added missing files and fix building against GLFW3 trunk.
|
||||
|
||||
Documentation
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <GL/glfw3.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
#define GLEXTPROCSIZE 27
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
cdef extern from "GL/glfw3.h":
|
||||
cdef extern from "GLFW/glfw3.h":
|
||||
ctypedef unsigned int GLenum
|
||||
ctypedef unsigned char GLboolean
|
||||
ctypedef unsigned int GLbitfield
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
cdef extern from "GL/glfw3.h":
|
||||
cdef extern from "GLFW/glfw3.h":
|
||||
cdef enum:
|
||||
GLFW_VERSION_MAJOR
|
||||
GLFW_VERSION_MINOR
|
||||
|
|
@ -169,10 +169,6 @@ cdef extern from "GL/glfw3.h":
|
|||
GLFW_JOYSTICK_15
|
||||
GLFW_JOYSTICK_16
|
||||
GLFW_JOYSTICK_LAST
|
||||
|
||||
# glfwCreateWindow modes
|
||||
GLFW_WINDOWED
|
||||
GLFW_FULLSCREEN
|
||||
|
||||
# glfwGetWindowParam tokens
|
||||
GLFW_ACTIVE
|
||||
|
|
@ -199,8 +195,6 @@ cdef extern from "GL/glfw3.h":
|
|||
# The following constants are used with both glfwGetWindowParam
|
||||
# and glfwWindowHint
|
||||
GLFW_CLIENT_API
|
||||
GLFW_OPENGL_VERSION_MAJOR
|
||||
GLFW_OPENGL_VERSION_MINOR
|
||||
GLFW_OPENGL_FORWARD_COMPAT
|
||||
GLFW_OPENGL_DEBUG_CONTEXT
|
||||
GLFW_OPENGL_PROFILE
|
||||
|
|
@ -258,23 +252,28 @@ cdef extern from "GL/glfw3.h":
|
|||
# OpenGL function pointer type
|
||||
ctypedef void (*GLFWglproc)()
|
||||
|
||||
# Monitor handle type
|
||||
cdef struct GLFWmonitor:
|
||||
pass
|
||||
|
||||
# Window handle type
|
||||
ctypedef void* GLFWwindow
|
||||
|
||||
cdef struct GLFWwindow:
|
||||
pass
|
||||
|
||||
# Function pointer types
|
||||
ctypedef void (* GLFWerrorfun)(int,char*)
|
||||
ctypedef void (* GLFWwindowsizefun)(GLFWwindow,int,int)
|
||||
ctypedef int (* GLFWwindowclosefun)(GLFWwindow)
|
||||
ctypedef void (* GLFWwindowrefreshfun)(GLFWwindow)
|
||||
ctypedef void (* GLFWwindowfocusfun)(GLFWwindow,int)
|
||||
ctypedef void (* GLFWwindowiconifyfun)(GLFWwindow,int)
|
||||
ctypedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int)
|
||||
ctypedef void (* GLFWcursorposfun)(GLFWwindow,int,int)
|
||||
ctypedef void (* GLFWcursorenterfun)(GLFWwindow,int)
|
||||
ctypedef void (* GLFWscrollfun)(GLFWwindow,double,double)
|
||||
ctypedef void (* GLFWkeyfun)(GLFWwindow,int,int)
|
||||
ctypedef void (* GLFWcharfun)(GLFWwindow,int)
|
||||
|
||||
ctypedef void (* GLFWwindowsizefun)(GLFWwindow *,int,int)
|
||||
ctypedef int (* GLFWwindowclosefun)(GLFWwindow *)
|
||||
ctypedef void (* GLFWwindowrefreshfun)(GLFWwindow *)
|
||||
ctypedef void (* GLFWwindowfocusfun)(GLFWwindow *,int)
|
||||
ctypedef void (* GLFWwindowiconifyfun)(GLFWwindow *,int)
|
||||
ctypedef void (* GLFWmousebuttonfun)(GLFWwindow *,int,int)
|
||||
ctypedef void (* GLFWcursorposfun)(GLFWwindow *,double,double)
|
||||
ctypedef void (* GLFWcursorenterfun)(GLFWwindow *,int)
|
||||
ctypedef void (* GLFWscrollfun)(GLFWwindow *,double,double)
|
||||
ctypedef void (* GLFWkeyfun)(GLFWwindow *,int,int)
|
||||
ctypedef void (* GLFWcharfun)(GLFWwindow *,int)
|
||||
ctypedef void (* GLFWmonitorfun)(c_GLFWmonitor,int)
|
||||
|
||||
# The video mode structure used by glfwGetVideoModes
|
||||
cdef struct _GLFWvidmode:
|
||||
|
|
@ -283,14 +282,16 @@ cdef extern from "GL/glfw3.h":
|
|||
int redBits
|
||||
int blueBits
|
||||
int greenBits
|
||||
int refreshRate
|
||||
|
||||
ctypedef _GLFWvidmode GLFWvidmode
|
||||
|
||||
# Gamma ramp
|
||||
cdef struct _GLFWgammaramp:
|
||||
unsigned short red[GLFW_GAMMA_RAMP_SIZE]
|
||||
unsigned short green[GLFW_GAMMA_RAMP_SIZE]
|
||||
unsigned short blue[GLFW_GAMMA_RAMP_SIZE]
|
||||
unsigned short* red
|
||||
unsigned short* green
|
||||
unsigned short* blue
|
||||
unsigned int size
|
||||
|
||||
ctypedef _GLFWgammaramp GLFWgammaramp
|
||||
|
||||
|
|
@ -304,56 +305,68 @@ cdef extern from "GL/glfw3.h":
|
|||
int glfwGetError()
|
||||
char* glfwErrorString(int error)
|
||||
void glfwSetErrorCallback(GLFWerrorfun cbfun)
|
||||
|
||||
|
||||
# Monitor handling
|
||||
GLFWmonitor *glfwGetMonitors(int* count)
|
||||
GLFWmonitor *glfwGetPrimaryMonitor()
|
||||
void glfwGetMonitorPos(GLFWmonitor *monitor, int* xpos, int* ypos)
|
||||
void glfwGetMonitorPhysicalSize(GLFWmonitor *monitor, int* width, int* height)
|
||||
char* glfwGetMonitorName(GLFWmonitor *monitor)
|
||||
GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
|
||||
|
||||
# Video mode functions
|
||||
GLFWvidmode* glfwGetVideoModes(int* count)
|
||||
void glfwGetDesktopMode(GLFWvidmode* mode)
|
||||
|
||||
const GLFWvidmode* glfwGetVideoMode(GLFWmonitor *monitor)
|
||||
|
||||
# Gamma ramp functions
|
||||
void glfwSetGamma(float gamma)
|
||||
void glfwGetGammaRamp(GLFWgammaramp* ramp)
|
||||
void glfwSetGammaRamp(GLFWgammaramp* ramp)
|
||||
void glfwSetGamma(GLFWmonitor *monitor, float gamma)
|
||||
GLFWgammaramp* glfwGetGammaRamp(GLFWmonitor *monitor)
|
||||
void glfwSetGammaRamp(GLFWmonitor *monitor, GLFWgammaramp* ramp)
|
||||
|
||||
# Window handling
|
||||
void glfwDefaultWindowHints()
|
||||
void glfwWindowHint(int target, int hint)
|
||||
GLFWwindow glfwCreateWindow(int width, int height, int mode, char* title, GLFWwindow share)
|
||||
void glfwDestroyWindow(GLFWwindow window)
|
||||
void glfwSetWindowTitle(GLFWwindow window, char* title)
|
||||
void glfwGetWindowSize(GLFWwindow window, int* width, int* height)
|
||||
void glfwSetWindowSize(GLFWwindow window, int width, int height)
|
||||
void glfwGetWindowPos(GLFWwindow window, int* xpos, int* ypos)
|
||||
void glfwSetWindowPos(GLFWwindow window, int xpos, int ypos)
|
||||
void glfwIconifyWindow(GLFWwindow window)
|
||||
void glfwRestoreWindow(GLFWwindow window)
|
||||
void glfwShowWindow(GLFWwindow window)
|
||||
void glfwHideWindow(GLFWwindow window)
|
||||
int glfwGetWindowParam(GLFWwindow window, int param)
|
||||
void glfwSetWindowUserPointer(GLFWwindow window, void* pointer)
|
||||
void* glfwGetWindowUserPointer(GLFWwindow window)
|
||||
void glfwSetWindowSizeCallback(GLFWwindow window, GLFWwindowsizefun cbfun)
|
||||
void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cbfun)
|
||||
void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfun cbfun)
|
||||
void glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cbfun)
|
||||
void glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfun cbfun)
|
||||
GLFWwindow * glfwCreateWindow(int width, int height, char* title, GLFWmonitor *monitor, GLFWwindow * share)
|
||||
int glfwWindowShouldClose(GLFWwindow * window)
|
||||
void glfwSetWindowShouldClose(GLFWwindow * window, int value)
|
||||
void glfwDestroyWindow(GLFWwindow * window)
|
||||
void glfwSetWindowTitle(GLFWwindow * window, char* title)
|
||||
void glfwGetWindowSize(GLFWwindow * window, int* width, int* height)
|
||||
void glfwSetWindowSize(GLFWwindow * window, int width, int height)
|
||||
void glfwGetWindowPos(GLFWwindow * window, int* xpos, int* ypos)
|
||||
void glfwSetWindowPos(GLFWwindow * window, int xpos, int ypos)
|
||||
void glfwIconifyWindow(GLFWwindow * window)
|
||||
void glfwRestoreWindow(GLFWwindow * window)
|
||||
void glfwShowWindow(GLFWwindow * window)
|
||||
void glfwHideWindow(GLFWwindow * window)
|
||||
GLFWmonitor *glfwGetWindowMonitor(GLFWwindow * window)
|
||||
int glfwGetWindowParam(GLFWwindow * window, int param)
|
||||
void glfwSetWindowUserPointer(GLFWwindow * window, void* pointer)
|
||||
void* glfwGetWindowUserPointer(GLFWwindow * window)
|
||||
void glfwSetWindowSizeCallback(GLFWwindow * window, GLFWwindowsizefun cbfun)
|
||||
void glfwSetWindowCloseCallback(GLFWwindow * window, GLFWwindowclosefun cbfun)
|
||||
void glfwSetWindowRefreshCallback(GLFWwindow * window, GLFWwindowrefreshfun cbfun)
|
||||
void glfwSetWindowFocusCallback(GLFWwindow * window, GLFWwindowfocusfun cbfun)
|
||||
void glfwSetWindowIconifyCallback(GLFWwindow * window, GLFWwindowiconifyfun cbfun)
|
||||
|
||||
# Event handling
|
||||
void glfwPollEvents()
|
||||
void glfwWaitEvents()
|
||||
|
||||
# Input handling
|
||||
int glfwGetInputMode(GLFWwindow window, int mode)
|
||||
void glfwSetInputMode(GLFWwindow window, int mode, int value)
|
||||
int glfwGetKey(GLFWwindow window, int key)
|
||||
int glfwGetMouseButton(GLFWwindow window, int button)
|
||||
void glfwGetCursorPos(GLFWwindow window, int* xpos, int* ypos)
|
||||
void glfwSetCursorPos(GLFWwindow window, int xpos, int ypos)
|
||||
void glfwGetScrollOffset(GLFWwindow window, double* xoffset, double* yoffset)
|
||||
void glfwSetKeyCallback(GLFWwindow window, GLFWkeyfun cbfun)
|
||||
void glfwSetCharCallback(GLFWwindow window, GLFWcharfun cbfun)
|
||||
void glfwSetMouseButtonCallback(GLFWwindow window, GLFWmousebuttonfun cbfun)
|
||||
void glfwSetCursorPosCallback(GLFWwindow window, GLFWcursorposfun cbfun)
|
||||
void glfwSetCursorEnterCallback(GLFWwindow window, GLFWcursorenterfun cbfun)
|
||||
void glfwSetScrollCallback(GLFWwindow window, GLFWscrollfun cbfun)
|
||||
int glfwGetInputMode(GLFWwindow * window, int mode)
|
||||
void glfwSetInputMode(GLFWwindow * window, int mode, int value)
|
||||
int glfwGetKey(GLFWwindow * window, int key)
|
||||
int glfwGetMouseButton(GLFWwindow * window, int button)
|
||||
void glfwGetCursorPos(GLFWwindow * window, double* xpos, double* ypos)
|
||||
void glfwSetCursorPos(GLFWwindow * window, double xpos, double ypos)
|
||||
void glfwGetScrollOffset(GLFWwindow * window, double* xoffset, double* yoffset)
|
||||
void glfwSetKeyCallback(GLFWwindow * window, GLFWkeyfun cbfun)
|
||||
void glfwSetCharCallback(GLFWwindow * window, GLFWcharfun cbfun)
|
||||
void glfwSetMouseButtonCallback(GLFWwindow * window, GLFWmousebuttonfun cbfun)
|
||||
void glfwSetCursorPosCallback(GLFWwindow * window, GLFWcursorposfun cbfun)
|
||||
void glfwSetCursorEnterCallback(GLFWwindow * window, GLFWcursorenterfun cbfun)
|
||||
void glfwSetScrollCallback(GLFWwindow * window, GLFWscrollfun cbfun)
|
||||
|
||||
# Joystick input
|
||||
int glfwGetJoystickParam(int joy, int param)
|
||||
|
|
@ -361,18 +374,18 @@ cdef extern from "GL/glfw3.h":
|
|||
int glfwGetJoystickButtons(int joy, unsigned char* buttons, int numbuttons)
|
||||
|
||||
# Clipboard
|
||||
void glfwSetClipboardString(GLFWwindow window, char* string)
|
||||
char* glfwGetClipboardString(GLFWwindow window)
|
||||
void glfwSetClipboardString(GLFWwindow * window, char* string)
|
||||
char* glfwGetClipboardString(GLFWwindow * window)
|
||||
|
||||
# Time
|
||||
double glfwGetTime()
|
||||
void glfwSetTime(double time)
|
||||
|
||||
# OpenGL support
|
||||
void glfwMakeContextCurrent(GLFWwindow window)
|
||||
GLFWwindow glfwGetCurrentContext()
|
||||
void glfwSwapBuffers(GLFWwindow window)
|
||||
void glfwMakeContextCurrent(GLFWwindow * window)
|
||||
GLFWwindow * glfwGetCurrentContext()
|
||||
void glfwSwapBuffers(GLFWwindow * window)
|
||||
void glfwSwapInterval(int interval)
|
||||
int glfwExtensionSupported(char* extension)
|
||||
GLFWglproc glfwGetProcAddress(char* procname)
|
||||
void glfwCopyContext(GLFWwindow src, GLFWwindow dst, unsigned long mask)
|
||||
void glfwCopyContext(GLFWwindow * src, GLFWwindow * dst, unsigned long mask)
|
||||
|
|
@ -46,22 +46,22 @@ cpdef SetTime(double time):
|
|||
glfwSetTime(time)
|
||||
|
||||
# gamma value
|
||||
cpdef SetGamma(float gamma):
|
||||
cpdef SetGamma(Window window, float gamma):
|
||||
'''
|
||||
Set gamma value
|
||||
'''
|
||||
Init()
|
||||
glfwSetGamma(gamma)
|
||||
Init()
|
||||
glfwSetGamma(glfwGetWindowMonitor(<GLFWwindow *>window.thisptr), gamma)
|
||||
|
||||
# get desktop size
|
||||
cpdef tuple GetDesktopSize():
|
||||
cpdef tuple GetDesktopSize(Window window):
|
||||
'''
|
||||
Return desktop size
|
||||
'''
|
||||
cdef GLFWvidmode vidmode
|
||||
cdef GLFWvidmode *vidmode
|
||||
|
||||
Init()
|
||||
glfwGetDesktopMode(&vidmode)
|
||||
vidmode = glfwGetVideoMode(glfwGetWindowMonitor(<GLFWwindow *>window.thisptr))
|
||||
return vidmode.width, vidmode.height
|
||||
|
||||
|
||||
|
|
@ -74,8 +74,7 @@ cdef class Window:
|
|||
'''
|
||||
def __init__(self, int width = -1, int height = -1, title = None,
|
||||
bint fullscreen = False):
|
||||
cdef GLFWvidmode vidmode
|
||||
cdef int mode = GLFW_WINDOWED
|
||||
cdef GLFWvidmode *vidmode
|
||||
cdef char *c_title
|
||||
|
||||
# Initialise GLFW
|
||||
|
|
@ -90,49 +89,43 @@ cdef class Window:
|
|||
glfwWindowHint(GLFW_DEPTH_BITS, 24)
|
||||
glfwWindowHint(GLFW_STENCIL_BITS, 8)
|
||||
|
||||
glfwWindowHint(GLFW_OPENGL_VERSION_MAJOR, 2)
|
||||
glfwWindowHint(GLFW_OPENGL_VERSION_MINOR, 1)
|
||||
|
||||
# open window
|
||||
if width < 0 or height < 0:
|
||||
# default to desktop size
|
||||
glfwGetDesktopMode(&vidmode)
|
||||
vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor())
|
||||
width, height = vidmode.width, vidmode.height
|
||||
glfwWindowHint(GLFW_RED_BITS, vidmode.redBits)
|
||||
glfwWindowHint(GLFW_GREEN_BITS, vidmode.greenBits)
|
||||
glfwWindowHint(GLFW_BLUE_BITS, vidmode.blueBits)
|
||||
|
||||
if fullscreen:
|
||||
mode = GLFW_FULLSCREEN
|
||||
|
||||
# decode to UTF-8
|
||||
if title is None:
|
||||
title = ''
|
||||
bytetext = unicode(title).encode('UTF-8','ignore')
|
||||
c_title = bytetext
|
||||
|
||||
self.thisptr = glfwCreateWindow(width, height, mode, c_title, NULL)
|
||||
self.thisptr = glfwCreateWindow(width, height, c_title, glfwGetPrimaryMonitor(), NULL)
|
||||
if self.thisptr == NULL:
|
||||
raise GLError('failed to open window')
|
||||
|
||||
# Set pointer back to this class for callbacks
|
||||
glfwSetWindowUserPointer(<GLFWwindow>self.thisptr, <void *>self)
|
||||
glfwSetWindowUserPointer(<GLFWwindow *>self.thisptr, <void *>self)
|
||||
|
||||
# Set callback functions
|
||||
glfwSetWindowSizeCallback(<GLFWwindow>self.thisptr, cb_onSize)
|
||||
glfwSetWindowRefreshCallback(<GLFWwindow>self.thisptr, cb_onRefresh)
|
||||
glfwSetCursorPosCallback(<GLFWwindow>self.thisptr, cb_onCursorPos)
|
||||
glfwSetMouseButtonCallback(<GLFWwindow>self.thisptr, cb_onMouseButton)
|
||||
glfwSetKeyCallback(<GLFWwindow>self.thisptr, cb_onKey)
|
||||
glfwSetCharCallback(<GLFWwindow>self.thisptr, cb_onChar)
|
||||
glfwSetWindowCloseCallback(<GLFWwindow>self.thisptr, cb_onClose)
|
||||
glfwSetWindowFocusCallback(<GLFWwindow>self.thisptr, cb_onFocus)
|
||||
glfwSetCursorEnterCallback(<GLFWwindow>self.thisptr, cb_onEnter)
|
||||
glfwSetScrollCallback(<GLFWwindow>self.thisptr, cb_onScroll)
|
||||
glfwSetWindowIconifyCallback(<GLFWwindow>self.thisptr, cb_onIconify)
|
||||
glfwSetWindowSizeCallback(<GLFWwindow *>self.thisptr, cb_onSize)
|
||||
glfwSetWindowRefreshCallback(<GLFWwindow *>self.thisptr, cb_onRefresh)
|
||||
glfwSetCursorPosCallback(<GLFWwindow *>self.thisptr, cb_onCursorPos)
|
||||
glfwSetMouseButtonCallback(<GLFWwindow *>self.thisptr, cb_onMouseButton)
|
||||
glfwSetKeyCallback(<GLFWwindow *>self.thisptr, cb_onKey)
|
||||
glfwSetCharCallback(<GLFWwindow *>self.thisptr, cb_onChar)
|
||||
glfwSetWindowCloseCallback(<GLFWwindow *>self.thisptr, cb_onClose)
|
||||
glfwSetWindowFocusCallback(<GLFWwindow *>self.thisptr, cb_onFocus)
|
||||
glfwSetCursorEnterCallback(<GLFWwindow *>self.thisptr, cb_onEnter)
|
||||
glfwSetScrollCallback(<GLFWwindow *>self.thisptr, cb_onScroll)
|
||||
glfwSetWindowIconifyCallback(<GLFWwindow *>self.thisptr, cb_onIconify)
|
||||
|
||||
# Get window size (may be different than the requested size)
|
||||
glfwGetWindowSize(<GLFWwindow>self.thisptr, &width, &height);
|
||||
glfwGetWindowSize(<GLFWwindow *>self.thisptr, &width, &height);
|
||||
self.onSize(width, max(1, height))
|
||||
|
||||
def __dealloc__(self):
|
||||
|
|
@ -148,14 +141,14 @@ cdef class Window:
|
|||
bytetext = unicode(title).encode('UTF-8','ignore')
|
||||
c_title = bytetext
|
||||
|
||||
glfwSetWindowTitle(<GLFWwindow>self.thisptr, c_title)
|
||||
glfwSetWindowTitle(<GLFWwindow *>self.thisptr, c_title)
|
||||
|
||||
cpdef tuple getSize(self):
|
||||
'''
|
||||
Get window size
|
||||
'''
|
||||
cdef int width, height
|
||||
glfwGetWindowSize(<GLFWwindow>self.thisptr, &width, &height)
|
||||
glfwGetWindowSize(<GLFWwindow *>self.thisptr, &width, &height)
|
||||
return width, height
|
||||
|
||||
cpdef setSize(self, int width, int height):
|
||||
|
|
@ -164,64 +157,64 @@ cdef class Window:
|
|||
'''
|
||||
if width <= 0 or height <= 0:
|
||||
raise GLError('window size not valid')
|
||||
glfwSetWindowSize(<GLFWwindow>self.thisptr, width, height)
|
||||
glfwSetWindowSize(<GLFWwindow *>self.thisptr, width, height)
|
||||
|
||||
cpdef setClipboard(self, content):
|
||||
'''
|
||||
Set clipboard text
|
||||
'''
|
||||
glfwSetClipboardString(<GLFWwindow>self.thisptr, content)
|
||||
glfwSetClipboardString(<GLFWwindow *>self.thisptr, content)
|
||||
|
||||
cpdef getClipboard(self):
|
||||
'''
|
||||
Get clipboard text
|
||||
'''
|
||||
cdef const_char *content = glfwGetClipboardString(<GLFWwindow>self.thisptr)
|
||||
cdef const_char *content = glfwGetClipboardString(<GLFWwindow *>self.thisptr)
|
||||
return content
|
||||
|
||||
cpdef iconify(self):
|
||||
'''
|
||||
Iconify window
|
||||
'''
|
||||
glfwIconifyWindow(<GLFWwindow>self.thisptr)
|
||||
glfwIconifyWindow(<GLFWwindow *>self.thisptr)
|
||||
|
||||
cpdef restore(self):
|
||||
'''
|
||||
Restore window from iconification
|
||||
'''
|
||||
glfwRestoreWindow(<GLFWwindow>self.thisptr)
|
||||
glfwRestoreWindow(<GLFWwindow *>self.thisptr)
|
||||
|
||||
cpdef show(self):
|
||||
'''
|
||||
Show window
|
||||
'''
|
||||
glfwShowWindow(<GLFWwindow>self.thisptr)
|
||||
glfwShowWindow(<GLFWwindow *>self.thisptr)
|
||||
|
||||
cpdef hide(self):
|
||||
'''
|
||||
Hide window
|
||||
'''
|
||||
glfwHideWindow(<GLFWwindow>self.thisptr)
|
||||
glfwHideWindow(<GLFWwindow *>self.thisptr)
|
||||
|
||||
cpdef close(self):
|
||||
'''
|
||||
Stop main loop and close window
|
||||
'''
|
||||
self.running = False
|
||||
glfwDestroyWindow(<GLFWwindow>self.thisptr)
|
||||
glfwDestroyWindow(<GLFWwindow *>self.thisptr)
|
||||
glfwTerminate()
|
||||
|
||||
cpdef makeContextCurrent(self):
|
||||
'''
|
||||
Make window openGL context current
|
||||
'''
|
||||
glfwMakeContextCurrent(<GLFWwindow>self.thisptr)
|
||||
glfwMakeContextCurrent(<GLFWwindow *>self.thisptr)
|
||||
|
||||
cpdef swapBuffers(self):
|
||||
'''
|
||||
Swap front and back buffers
|
||||
'''
|
||||
glfwSwapBuffers(<GLFWwindow>self.thisptr)
|
||||
glfwSwapBuffers(<GLFWwindow *>self.thisptr)
|
||||
|
||||
cpdef mainLoop(self):
|
||||
'''
|
||||
|
|
@ -231,18 +224,18 @@ cdef class Window:
|
|||
handled to avoid to quick update.
|
||||
'''
|
||||
# keep waiting for events until running is False
|
||||
cdef int x, y, lastX, lastY
|
||||
cdef double x, y, lastX, lastY
|
||||
cdef double t
|
||||
|
||||
glfwSetCursorPosCallback(<GLFWwindow>self.thisptr, NULL)
|
||||
glfwGetCursorPos(<GLFWwindow>self.thisptr, &lastX, &lastY)
|
||||
glfwSetCursorPosCallback(<GLFWwindow *>self.thisptr, NULL)
|
||||
glfwGetCursorPos(<GLFWwindow *>self.thisptr, &lastX, &lastY)
|
||||
self.running = True
|
||||
while True:
|
||||
# Wait for new events
|
||||
glfwWaitEvents()
|
||||
|
||||
# Avoid to quick update due to mouse move
|
||||
glfwGetCursorPos(<GLFWwindow>self.thisptr, &x, &y)
|
||||
glfwGetCursorPos(<GLFWwindow *>self.thisptr, &x, &y)
|
||||
if x != lastX or y != lastY:
|
||||
# in mouse move
|
||||
t = glfwGetTime()
|
||||
|
|
@ -251,7 +244,7 @@ cdef class Window:
|
|||
if glfwGetTime() - t > .025:
|
||||
break
|
||||
|
||||
glfwGetCursorPos(<GLFWwindow>self.thisptr, &x, &y)
|
||||
glfwGetCursorPos(<GLFWwindow *>self.thisptr, &x, &y)
|
||||
self.onCursorPos(x, y)
|
||||
|
||||
lastX, lastY = x, y
|
||||
|
|
@ -276,7 +269,7 @@ cdef class Window:
|
|||
'''
|
||||
pass
|
||||
|
||||
cpdef onCursorPos(self, int x, int y):
|
||||
cpdef onCursorPos(self, double x, double y):
|
||||
'''
|
||||
Callback on change of mouse cursor position
|
||||
'''
|
||||
|
|
@ -331,7 +324,7 @@ cdef class Window:
|
|||
return False
|
||||
|
||||
# callback functions
|
||||
cdef void cb_onSize(GLFWwindow window, int w, int h):
|
||||
cdef void cb_onSize(GLFWwindow *window, int w, int h):
|
||||
cdef Window self = <Window>glfwGetWindowUserPointer(window)
|
||||
|
||||
try:
|
||||
|
|
@ -339,14 +332,14 @@ cdef void cb_onSize(GLFWwindow window, int w, int h):
|
|||
except Exception as err:
|
||||
self.error = err
|
||||
|
||||
cdef void cb_onRefresh(GLFWwindow window):
|
||||
cdef void cb_onRefresh(GLFWwindow *window):
|
||||
cdef Window self = <Window>glfwGetWindowUserPointer(window)
|
||||
try:
|
||||
self.onRefresh()
|
||||
except Exception as err:
|
||||
self.error = err
|
||||
|
||||
cdef void cb_onCursorPos(GLFWwindow window, int x, int y):
|
||||
cdef void cb_onCursorPos(GLFWwindow *window, double x, double y):
|
||||
cdef Window self = <Window>glfwGetWindowUserPointer(window)
|
||||
|
||||
try:
|
||||
|
|
@ -354,7 +347,7 @@ cdef void cb_onCursorPos(GLFWwindow window, int x, int y):
|
|||
except Exception as err:
|
||||
self.error = err
|
||||
|
||||
cdef void cb_onMouseButton(GLFWwindow window, int button, int action):
|
||||
cdef void cb_onMouseButton(GLFWwindow *window, int button, int action):
|
||||
cdef Window self = <Window>glfwGetWindowUserPointer(window)
|
||||
|
||||
try:
|
||||
|
|
@ -362,7 +355,7 @@ cdef void cb_onMouseButton(GLFWwindow window, int button, int action):
|
|||
except Exception as err:
|
||||
self.error = err
|
||||
|
||||
cdef void cb_onKey(GLFWwindow window, int key, int action):
|
||||
cdef void cb_onKey(GLFWwindow *window, int key, int action):
|
||||
cdef Window self = <Window>glfwGetWindowUserPointer(window)
|
||||
|
||||
try:
|
||||
|
|
@ -370,7 +363,7 @@ cdef void cb_onKey(GLFWwindow window, int key, int action):
|
|||
except Exception as err:
|
||||
self.error = err
|
||||
|
||||
cdef void cb_onChar(GLFWwindow window, int ch):
|
||||
cdef void cb_onChar(GLFWwindow *window, int ch):
|
||||
cdef Window self = <Window>glfwGetWindowUserPointer(window)
|
||||
cdef char st[2]
|
||||
|
||||
|
|
@ -382,7 +375,7 @@ cdef void cb_onChar(GLFWwindow window, int ch):
|
|||
except Exception as err:
|
||||
self.error = err
|
||||
|
||||
cdef void cb_onFocus(GLFWwindow window, int status):
|
||||
cdef void cb_onFocus(GLFWwindow *window, int status):
|
||||
cdef Window self = <Window>glfwGetWindowUserPointer(window)
|
||||
|
||||
try:
|
||||
|
|
@ -390,11 +383,11 @@ cdef void cb_onFocus(GLFWwindow window, int status):
|
|||
except Exception as err:
|
||||
self.error = err
|
||||
|
||||
cdef void cb_onEnter(GLFWwindow window, int status):
|
||||
cdef void cb_onEnter(GLFWwindow *window, int status):
|
||||
cdef Window self = <Window>glfwGetWindowUserPointer(window)
|
||||
self.onEnter(status)
|
||||
|
||||
cdef void cb_onScroll(GLFWwindow window, double dx, double dy):
|
||||
cdef void cb_onScroll(GLFWwindow *window, double dx, double dy):
|
||||
cdef Window self = <Window>glfwGetWindowUserPointer(window)
|
||||
|
||||
try:
|
||||
|
|
@ -402,7 +395,7 @@ cdef void cb_onScroll(GLFWwindow window, double dx, double dy):
|
|||
except Exception as err:
|
||||
self.error = err
|
||||
|
||||
cdef void cb_onIconify(GLFWwindow window, int status):
|
||||
cdef void cb_onIconify(GLFWwindow *window, int status):
|
||||
cdef Window self = <Window>glfwGetWindowUserPointer(window)
|
||||
|
||||
try:
|
||||
|
|
@ -410,7 +403,7 @@ cdef void cb_onIconify(GLFWwindow window, int status):
|
|||
except Exception as err:
|
||||
self.error = err
|
||||
|
||||
cdef int cb_onClose(GLFWwindow window):
|
||||
cdef int cb_onClose(GLFWwindow *window):
|
||||
cdef Window self = <Window>glfwGetWindowUserPointer(window)
|
||||
cdef int ret
|
||||
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ cpdef Init()
|
|||
cpdef Terminate()
|
||||
cpdef double GetTime()
|
||||
cpdef SetTime(double time)
|
||||
cpdef SetGamma(float gamma)
|
||||
cpdef tuple GetDesktopSize()
|
||||
cpdef SetGamma(Window window, float gamma)
|
||||
cpdef tuple GetDesktopSize(Window window)
|
||||
|
||||
cdef class Window:
|
||||
cdef void *thisptr
|
||||
|
|
@ -75,7 +75,7 @@ cdef class Window:
|
|||
cpdef mainLoop(self)
|
||||
cpdef onSize(self, int w, int h)
|
||||
cpdef onRefresh(self)
|
||||
cpdef onCursorPos(self, int x, int y)
|
||||
cpdef onCursorPos(self, double x, double y)
|
||||
cpdef onMouseButton(self, int button, int action)
|
||||
cpdef onKey(self, int key, int action)
|
||||
cpdef onChar(self, ch)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,11 @@ if sys.platform == 'win32':
|
|||
LIBS.append('user32')
|
||||
LIBS.append('gdi32')
|
||||
OBJECTS.append('glfw3.lib')
|
||||
|
||||
elif sys.platform == 'msys':
|
||||
LIBS.append('OPENGL32')
|
||||
LIBS.append('glfw3dll')
|
||||
COMPILE_ARGS.append("-fpermissive")
|
||||
|
||||
elif sys.platform == 'darwin':
|
||||
LINK_ARGS.extend(['-framework', 'OpenGL', '-arch', 'x86_64'])
|
||||
|
|
@ -120,7 +125,10 @@ application in Python/Cython with support for:
|
|||
),
|
||||
],
|
||||
|
||||
cmdclass = {'build_ext': build_ext}
|
||||
cmdclass = {'build_ext': build_ext},
|
||||
packages=[''],
|
||||
package_dir={'': 'gltools'},
|
||||
package_data={'': ['*.pxd']},
|
||||
)
|
||||
except:
|
||||
print('Traceback\n:%s\n' % str(sys.exc_info()[-2]))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
MAJOR = 0
|
||||
MINOR = 1
|
||||
MINOR = 2
|
||||
BUILD = 1
|
||||
STRING = "%d.%d.%d" % (MAJOR,MINOR,BUILD)
|
||||
Loading…
Reference in a new issue