-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot seem to create a High DPI window in MacOSX #140
Comments
@biglambda is this still in issue for you? For what it's worth, on MacOS 10.12.5 I have high DPI working even without the plist key. I can check, but I believe that while the window size doesn't change when I set |
Hmmm... it is an issue, what version of the libraries etc are you using? |
SDL 2.0.5. The latest version on homebrew. Using the haskell sdl2 library from this repo. |
Can I see your initialization code? |
Just using windowConfig :: WindowConfig
windowConfig = WindowConfig
{ windowBorder = True
, windowHighDPI = True
, windowInputGrabbed = False
, windowMode = Windowed
, windowOpenGL = Nothing
, windowPosition = Wherever
, windowResizable = True
, windowInitialSize = V2 800 600
} If I print out the dimensions returned by |
Note that if I set |
@biglambda can you show a screenshot of your window? Perhaps you were in high DPI the whole time but like #172 didn't know what to look for to see it's working. |
This is my startup code:
|
Right, so your window title bar is in high DPI so I think the whole window is. Your |
I finally have some time to work on this.
I write pixel values directly to that buffer and then I update the display using this code:
And I still get a low DPI output. Most frustrating thing ever :) |
Sorry if I missed something or this is distracting, but I have what I think to be high DPI working in one of my programs, which I set up with the following: let ogl = defaultOpenGL{ glProfile = Core Debug 3 3 }
cfg = defaultWindow{ windowOpenGL = Just ogl
, windowResizable = True
, windowHighDPI = True
, windowInitialSize = V2 640 480
} Then in my main loop I can query the window with |
@biglambda, you will get lower resolution, if you created window with |
Right, @biglambda you need to make your bitmap at least twice the size. Otherwise whatever you give it that is smaller will get stretched to fill the canvas. |
@schell, how do you get access to the 1280x960 framebuffer itself, if you want to write to it directly? |
@biglambda, if you use If you use pure OpenGL api, you need to create and fill OpenGL texture with foreign import ccall unsafe "glTexImage2D" glTexImage2D ::
GLenum -> GLint -> GLenum -> GLuint -> GLuint -> GLint -> GLenum -> GLenum -> CString -> IO ()
...
V2 w h <- glGetDrawableSize window
glTexImage2D GL_TEXTURE_2D 0 format (fromIntegral w) (fromIntegral h) 0 format GL_UNSIGNED_BYTE ptr where format = |
Ok, thanks for that insight. I finally have it working. I think the secret so far has been to forget about using the surface from the window.
I'm afraid though that there is an additional unnecessary copy operation versus using SDL.updateWindowSurface. What do you think? |
@biglambda, if you create
If your renderer is not software, function On the other hand,
I think, that you should always use For example, to create and use atlas you can
Also you can get some information on your question here. |
Ok interesting, the last step of my "drawOn" function is actually an OpenCL kernel that fills a buffer for every pixel in the window. So it's too bad but it seems like I currently copy the buffer back to the host memory and then back to video memory again. Is there a way to allocate a texture and then refer to that as an OpenCL buffer? |
@biglambda, you should try to do the following
SDL.setHintWithPriority SDL.OverridePriority SDL.HintRenderDriver SDL.OpenGLES2
type GLint = Int32
type GLenum = Word32
pattern GL_TEXTURE_BINDING_2D :: forall a. (Num a, Eq a) => a
pattern GL_TEXTURE_BINDING_2D = 0x8069
pattern GL_TEXTURE_2D :: forall a. (Num a, Eq a) => a
pattern GL_TEXTURE_2D = 0x0DE1
foreign import ccall unsafe "glGetIntegerv" glGetIntegerv :: GLenum -> Ptr GLint -> IO ()
...
SDL.glBindTexture texture
glName <- alloca (\p -> glGetIntegerv GL_TEXTURE_BINDING_2D p >> peek p)
SDL.glUnbindTexture texture
...
|
Thanks a lot, I'm working on trying to implement this, I'll let you know how it goes. |
Ok I think I'm close to having this working currently I'm getting an error from the OpenCL when I try to run clCreateFromGLTexture2D.
Not sure about the right approach to debug this. |
In this old discussion someone wrote about the same behavior in SDK examples due to the driver. Do you have a possibility to run some small existing OpenGL-OpenCL interop example? |
Ok, thanks for pointing me in the right direction. I think page 10 of this document http://sa10.idav.ucdavis.edu/docs/sa10-dg-opencl-gl-interop.pdf gets into how to do this OpenGL-OpenCL interop on a mac. It looks like there are a few functions that are needed that, I think, don't have bindings in the current OpenCL package that I'm using namely: CGLGetCurrentContext, CGLGetShareGroup. https://gist.github.com/acowley/cdac93e3b580b65bd7d2#file-clglinterop-hs I'm going to see if I can get some of this working in my code. |
Indeed I do OpenGL-OpenCL interop on macOS all the time. Let me know if you run into any trouble, but the code you linked should get you going. |
Hi so what I decided to do was modify @acowley's CLUtil package to include TextureObject parameters and I included an example program that uses SDL to display his QuasiCrystal kernel using the CLGLinterop. You can find that forked repository here: https://github.com/biglambda/CLUtil |
@biglambda, in your example, why do you create texture in every frame? You can create it once at the beginning. |
@biglambda, more precisely, you should create it in the beginning and recreate on window resize event. |
Cool, I just pushed a version that does that. |
Something I noticed is that this only runs on the CPU so far. For my first device, an Intel Iris Pro, I get.
For my second device an AMD Radeon R9 M370X Compute Engine (which comes up as having the display in my system report) I get a black output. If I switch back to CPU it works fine. |
I'm trying to create a high DPI window on MacOS but I seem to always get the larger resolution.
My window setup code looks like this:
I'm opening the code in with the 'open' command in terminal from a bundle. My info plist includes:
The text was updated successfully, but these errors were encountered: