Comments (11)
Incidentally, if you do update the OpenGL docs section, you might want to point out that you have to do all the GL setup stuff lazily in the first draw call, not where you create the GlWindow. Until the draw call, there doesn't seem to be an OpenGL context, or at least I couldn't make one current.
from fltkhs.
I get it now: the lazy init of the context is why this works at all.
You create the GlWindow and call setMode on it before the context is created, because afterward it would be too late. At some point between then and the first draw call, FLTK creates the context. Then you can create your VAO etc. and start rendering.
from fltkhs.
There are two functions on GlWindow
:
setContext :: 'Ref' 'GlWindowBase' -> 'Ref' 'FlGlContext' -> 'IO' ()
setContextWithDestroyFlag :: 'Ref' 'GlWindowBase' -> 'Ref' 'FlGlContext' -> 'Bool' -> 'IO' ()
The Bool
flag in the latter, if True
, destroys the FlGlContext
passed in when the window's destructor is called.
I've honestly never done this as I'm not too familiar with OpenGL. If you successfully get this working on your platform do you mind posting to this issue? I'll make it part of the official documentation.
from fltkhs.
Hmm...it's a problem that what we need to pass in is an OpenGL context, and the API takes an FlGlContext. And the ways of creating OpenGL contexts in Haskell generally create e.g. GLFWWindow or SDLWindow or their particular wrapped versions of OpenGL contexts. I don't see a way to extract the actual underlying C context object and pass it around between APIs. They don't export it and you can't accept it anyway.
The most likely to succeed suggestion I've seen so far in the C world is to somehow create a hidden or offscreen core context window in a different API and then blit the bitmap across each frame. That might be doable in Haskell, depending on the other API chosen, but it'll be quite cumbersome.
The Google Groups thread above manages to get something working, but that's by hacking a new enum value into the FLTK source. I don't know how you feel about doing something so invasive in a wrapper library. We could add a new function to do that instead of altering the existing API, but it would still be functionality not published by the wrapped library. Of course, that's the whole point of this issue: that FLTK doesn't publish this functionality. But in C there are potentially reasonable ways to work around that, and in Haskell there don't seem to be.
from fltkhs.
Broadly speaking I'm ok adding functionality that FLTK doesn't provide but don't really want to patch the library. But perhaps the FLTK folks would be amenable to a PR? That would be the best solution because I have no problem bundling the FLTK master
branch into this project if it is merged, that's what I do now anyway and this in particular seems like really useful functionality.
from fltkhs.
Never mind! There's already an API that does it [with a small hack], that I hadn't previously found.
See https://www.fltk.org/doc-1.3/opengl.html#opengl3
In Haskell:
setMode glwin $ Modes [ModeDouble, ModeDepth, ModeOpenGL3]
There's a small problem in that getMode returns a Mode that's a bunch of bits orred together, which we can't take apart safely without blowing up on toEnum. But the error message told me the raw bits, so I went though the FLTK headers to see what they were [18 == ModeDouble | ModeDepth] and I just overwrote with that and the bit for ModeOpenGL3. getMode should really take the bits apart and return a Modes instead so that we could just or in a single bit, and then we'd have a clean solution.
from fltkhs.
Ooh great find! Can you confirm that you're able to are indeed able to render using newer versions of OpenGL? I'll change getMode
as you suggest.
from fltkhs.
I've got a square rendering with #version 330 in my shaders, so I believe that indicates I'm using newer OpenGL. I don't know how to get the actual version out, but I believe it should default to the full range of whatever I've got installed.
from fltkhs.
Taking out that one setMode line gives me back the old error:
Vertex Shader Error:0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES
That seems like proof.
from fltkhs.
getMode
now extracts the different Mode
s out of the bits.
from fltkhs.
Works great--thanks!
from fltkhs.
Related Issues (20)
- Return function pointer from `openCallback` so it can be freed. HOT 1
- Crash in FL.eventKey on special key HOT 8
- GL causes c2hs error on Mac due to missing type HOT 4
- after using setIcon on window it doesn't display application HOT 4
- Adding a Scrolled via FLUID generates wrong "scrollNew" call instead of "scrolledNew" HOT 1
- unable to run basic example under nix HOT 1
- Fltkhs as stack dependency linking error on Windows 10 HOT 1
- install gotchas
- Build error in Setup.hs HOT 2
- Error building bundled fltkhs in custom Setup.hs HOT 1
- fltkhs-fluidtohs generates incorrect module names for nested modules
- addAndGetMenuItem is suprisingly slow HOT 8
- How to call findClicked?
- GHC 8.10.3 linking issue HOT 1
- Syntax error while installing with bundled fltkhs HOT 1
- Build fails with autoconf 2.70 and up HOT 8
- New branch's build artifacts stored in /tmp get erased
- Updating for base-4.14 (ghc 8.10) HOT 2
- cabal-install 3.4.0.0 breaks installation HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fltkhs.