ivanperez-keera / gloss-gtk Goto Github PK
View Code? Open in Web Editor NEWEmbed gloss in Gtk+ programs using gtkglext
License: Other
Embed gloss in Gtk+ programs using gtkglext
License: Other
This project adds a new backend to gloss that can be used to embed gloss images/animations/simulations in GTK+ applications. It uses the gtkglext package available in Hackage. Current status is: not finished, still under development. Do not use (I'm not joking here) in production just yet. How this works: in the arguments to 'display', use the InWidget constructor, and pass a Gtk container as first argument. The canvas will be added to the container using Graphics.UI.Gtk.containerAdd. QUICK STATUS OVERVIEW | Feature | Status | |----------------------+------------------------| | Animations | Working | | Simulations | Working | | Games | Working | | Mouse interaction | Working | | Fonts | Working | | Keyboard interaction | Not tested, might work | | Background colours | Not working | The contents of the original README file follows. -- 8 Coats of GLOSS ----------------------------------------------------------- Gloss hides the pain of drawing simple vector graphics behind a nice data type and a few display functions. EXAMPLE Getting something on the screen is as easy as: import Graphics.Gloss main = display (InWindow "Nice Window" (200, 200) (10, 10)) white (Circle 80) USAGE Once the window is open you can use the following: * Quit - esc-key. * Move Viewport - left-click drag, arrow keys. * Rotate Viewport - right-click drag, control-left-click drag, or home/end-keys. * Zoom Viewport - mouse wheel, or page up/down-keys. OTHER THINGS Animations and simulations can be constructed similarly using the 'animate' and 'simulate' functions. Games with user input can be constructed with the 'play' function. See the gloss-examples package for more. ------------------------------------------------------------------------------- Release Notes: For 1.7.0: * Tweaked circle level-of-detail reduction code. * Increased frame rate cap to 100hz. Thanks to Doug Burke * Primitives for drawing arcs and sectors. Thanks to Thomas DuBuisson * IO versions of animate, simplate and play. For 1.6.0: Thanks to Anthony Cowley * Full screen mode display mode. For 1.5.0: * O(1) Conversion of ForeignPtrs to bitmaps. * An extra flag on the Bitmap constructor allows bitmaps to be cached in texture memory between frames. For 1.4.0: * Added texture caching. Thanks to Christiaan Baaij: * Refactoring of Gloss internals to support multiple window manager backends. * Support for using GLFW as the window library instead of GLUT. GLUT is still the default, but to use GLFW install gloss with: cabal install gloss --flags=\"GLFW -GLUT\" For 1.3.0: * Various wibbles for GHC 7.1 Thanks to Ben Lambert-Smith: * New support for displaying bitmap files. For 1.2.0: * Cleaned up module hierarchy. * Added line-line intersection utils. * Enabled -Wall and fixed all warnings. * Various wibbles for GHC 7.0 Thanks to Thomas DuBuisson: * Fixed a bug causing motion events to give the wrong position. Thanks to Stephan Maka: * Fixed a space leak in simulate mode when the window was hidden. For 1.1.0: * Added game mode. * Added QuadTree and Extent structures. * Added simple ray casting.
Hi,
I tried doing some basic keyboard handling in gloss-gtk and found that a couple of things needed to be modified for it in order to work. I attach my email to the Gloss mailing list on Google Groups. It describes the (very few) changes needed. My repo is currently too far customized to submit a pull req though.
Hi guys,
I have just tried gloss-gtk and it's pretty cool. I had to fix some things to make it run but they're mostly straightforward for anyone, just use cabal sandbox and cabal unpack so that you can fix up issues in dependencies. One tricky part was getting keyboard input to work. I was using the GTK backend (Hadn't tried the GLUT or GLFW ones). What gloss-gtk does is it takes a gtk window and attaches a canvas to it and puts glut in it. There were a couple of issues. First of all, in Graphics/UI/GLUTGtk.hs I had to change:
_ <- canvas `on` keyPressEvent $ tryEvent $ handleKey Down
_ <- canvas `on` keyReleaseEvent $ tryEvent $ handleKey Up
to
_ <- container `on` keyPressEvent $ tryEvent $ handleKey Down
_ <- container `on` keyReleaseEvent $ tryEvent $ handleKey Up
because the canvas itself wasn't getting any keyboard input.
Second of all, that disabled tabbing out of the window. So in Graphics/Gloss/Internals/Interface/Backend/GtkGL.hs, in callbackKeyMouse, I had to add this guard:
| key' == Just (SpecialKey KeyTab)
= throw (PatternMatchFail "cannot handle Tab")
and obviously import the right values:
import Control.Exception (throw, PatternMatchFail(..))
That worked perfectly. Now I can get keyboard input and it works quite well. For example I added an "undo" action to the "draw" example in gloss-gtk. I extracted the examples to a separate cabal package so that I can build them easily.
I am still trying to figure out how to do antialiasing in Gloss. Has anyone got any tips? I would be very grateful. I think the animations could look much cooler with antialiasing.
Thanks!
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.