Skip to content

Commit 7561777

Browse files
committed
README: Include basic project information + markup
1 parent bd8061b commit 7561777

File tree

1 file changed

+76
-12
lines changed

1 file changed

+76
-12
lines changed

README.md

Lines changed: 76 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,86 @@
1+
# pyopengltk
2+
13
Tkinter - OpenGL Frame using ctypes
24

5+
* [pyopengltk on Github](https://github.com/jonwright/pyopengltk)
6+
* [pyopengltk on PyPI](https://pypi.org/project/pyopengltk/)
7+
38
An opengl frame for pyopengl-tkinter based on ctypes (no togl compilation)
49

510
Collected together by Jon Wright, Jan 2018.
611

7-
Based on the work of others
12+
## Basic Example
13+
14+
This example creates a window containing an `OpenGLFrame`
15+
filling the entire window. We configure it to animate
16+
(constantly redraw) clearing the screen using a green color.
17+
A simple framerate counter is included.
18+
The context information is printed to the terminal.
19+
20+
```python
21+
import time
22+
import tkinter
23+
from OpenGL import GL
24+
from pyopengltk import OpenGLFrame
25+
26+
class AppOgl(OpenGLFrame):
27+
28+
def initgl(self):
29+
"""Initalize gl states when the frame is created"""
30+
GL.glViewport(0, 0, self.width, self.height)
31+
GL.glClearColor(0.0, 1.0, 0.0, 0.0)
32+
self.start = time.time()
33+
self.nframes = 0
34+
35+
def redraw(self):
36+
"""Render a single frame"""
37+
GL.glClear(GL.GL_COLOR_BUFFER_BIT)
38+
tm = time.time() - self.start
39+
self.nframes += 1
40+
print("fps",self.nframes / tm, end="\r" )
41+
42+
43+
if __name__ == '__main__':
44+
root = tkinter.Tk()
45+
app = AppOgl(root, width=320, height=200)
46+
app.pack(fill=tkinter.BOTH, expand=tkinter.YES)
47+
app.animate = 1
48+
app.after(100, app.printContext)
49+
app.mainloop()
50+
```
51+
52+
The repository on Github also contains more examples.
53+
54+
## Install
55+
56+
From PyPI:
57+
58+
```
59+
pip install pyopengltk
60+
```
61+
62+
From source:
63+
64+
```
65+
git clone https://github.com/jonwright/pyopengltk
66+
cd pyopengltk
67+
pip install .
68+
```
69+
70+
## Attributions
71+
72+
Based on the work of others.
73+
74+
### C + Tcl/Tk example:
75+
76+
* Project URL : http://github.com/codeplea/opengl-tcltk/ (zlib license)
77+
* Article at : https://codeplea.com/opengl-with-c-and-tcl-tk
878

9-
C + Tcl/Tk example:
10-
http://github.com/codeplea/opengl-tcltk/
11-
(zlib license)
12-
Article at:
13-
https://codeplea.com/opengl-with-c-and-tcl-tk
79+
### Python + Tkinter (no pyopengl) example:
1480

15-
Python + Tkinter (no pyopengl) example:
16-
http://github.com/arcanosam/pytkogl/
17-
(The Code Project Open License)
18-
Article at
19-
http://www.codeproject.com/Articles/1073475/OpenGL-in-Python-with-TKinter
81+
* Project URL : http://github.com/arcanosam/pytkogl/ (The Code Project Open License)
82+
* Article at: http://www.codeproject.com/Articles/1073475/OpenGL-in-Python-with-TKinter
2083

21-
Large regions of code copied from pyopengl/Tk/__init__.py
84+
### pyopengl
2285

86+
* Large regions of code copied from `pyopengl/Tk/__init__.py`.

0 commit comments

Comments
 (0)