GLUT problem with the support of hidpi retina on macOS (c++) - c++

I making a port of my 3d program to macOS.
I'm using c++ and FreeGlut at windows. So at macOS, I've started to use it with GLUT. I don't use cocoa and create an OpenGL window context via GLUT.
There is a problem with the support of hidpi retina.
Glut reshapefunc is detecting two times the smaller resolution (I mean it detects logical points, not actual retina pixels) That's why the image looks pixelated.
How to turn on retina support in GLUT (or freeglut)?
I've tried the solution from this article http://iihm.imag.fr/blanch/software/glut-macosx/ (add line "hidpi" to glutInitDisplayString
and GLUT_3_2_CORE_PROFILE to glutInitDisplayMode). But it doesn't help.
Is it possible to make it without big changes in the program? Because it's quite a big program (3d software).
Thank you

You should only use one of glutInitDisplayString and glutInitDisplayMode.
glutInitDisplayMode overides glutInitDisplayString if it comes after.
try:
glutInitDisplayString("hidpi core rgba double")

Related

OpenVR. Rendering in OpenGL without SDL

Is this possible in nature? What role of SDL library in OpenVR API? Does it needed for OpenGL context or only for mirroring the stereo image to SDL window?
It is possible. If you don't use SDL, you'll have to create your rendering context and window by yourself. The whole code would be too long for this answer, but on Windows you could use functions like CreateWindowEx and wglCreateContext. OpenVR doesn't require anything different from a normal context setup, but you need to use a somewhat modern version of OpenGL (4.1 at least works for me).

A video player based on QtAV with Direct2D / OpenGL rendering

I'm developing a video player in Qt C++ using QtAV. QtAV uses ffmpeg internally. I need to show semi transparent overlays both my watermark logo and subtitles. I'm writing the application for windows. I use OpenAL library. OpenGL and Direct2D are the choice for renderers.
If I use OpenGL renderer, it works fine in some systems. The overlay works fine. But in some other systems the whole application will be just a black window. Nothing else I can see.
If I use Direct2D, the overlay wont work. And the renderer is a bit slow. But it works on all systems, without this overlays.
I have no code to show here because its not the coding issue. Even the examples in QtAV are not working. I need to find a way to show the overlays using Direct2D renderer OR find a solid way to use OpenGL rendering on all systems without fail.
Direct2D is not well supported in QtAV. So you may need to implement your own functions to add filters in your video render. That includes text draw functions, setting transparency etc.

On Linux how can I capture the desktop to an OpenGL texture?

I'm writing a cross platform open source Oculus Rift desktop viewer. I decided to start with Linux because I prefer developing on it. I've already got the texture warping working but now I need to capture the desktop to an OpenGL texture. There are other issues I'm not entirely sure how to resolve like rendering the warped desktop to my window while capturing every window except mine. Any clue how I would go about this?
I think your best course of action would be actually to write a fully fledged compositor.
There is the GLX_texture_from_pixmap extension, that allows you to source any pixmap compatible X11 drawable into a OpenGL texture. For a start it might be enough to simply pull the root window (pixmap) as it is into a OpenGL texture. Later you might want to use the Composite extension to redirect windows to off-screen rendering and composite them in 3D space as a stereoscopic picture in the Occulus Rift.

C++ & Allegro 4.2 - I need graphics to stretch in windowed mode

I am using C++ with Allegro 4.2 to build a windows game.
I want stretchable graphics in windowed mode.
I'm am one who likes giving users of my programs lots of options; I always hate when I'm playing a game in windowed mode and I'm either not allowed to stretch the window or the content inside the window doesn't stretch with it (this sucks a lot for 640x480 size games played on high resolution screens that don't even allow for fullscreen; requiring a magnify tool to play it properly). I'm wondering if there is some way in Allegro or perhaps if there is another programming library that allows the graphics to stretch with the shape of the window itself. I already know how to have my Allegro applications switch to fullscreen mode; I'm trying to improve the windowed mode.
A big reason for this is because my artstyle is low-resolution art (I call it "Bitmap Brothers" style); it's very good for games since it's organized and easy to edit. I don't want to have to go higher than 640x480 to increase the size because it's far to high for low-resolution art, but my window remains too small during windowed mode.
I noticed that Allegro 5.0.8 has this line of code:
al_set_new_display_flags(ALLEGRO_WINDOWED | ALLEGRO_RESIZABLE);
At the end it says "ALLEGRO_RESIZABLE", could that be the feature I'm looking for? If so, just how much does Allegro change from 4.2 to 5+?
Allegro 4 doesn't support user-resizable windows.
Allegro 5 does (as you've noted), but it is completely rewritten and is not backward compatible at all. Still, I would highly recommend that you switch to it as development on Allegro 4 is all but dead.

Alternative to GLUT

GLUT is a very old framework for OpenGL, and there seems to be a lot of negative attitude towards it. I hear SDL is an alternative, though to my understanding it does not handle the 3d component of OpenGL. What is a good option (which preferably has good documentation so it is easily learnable) that can do what GLUT does and provide more functionality, eg. to make a complete 3d game? I prefer not to use pre-made game engines, I'd much rather build my own code from scratch.
orginal GLUT is very old and I would not recommend it. But the new version of it: http://freeglut.sourceforge.net/ is quite interesting framework. Is is as simple as GLUT but adds more features: mouse scroll, new geometry objects, etc, etc.
last version of this library is from January 2012
here is a useful link with several frameworks for opengl: http://www.opengl.org/resources/libraries/windowtoolkits/
If you want to make w "whole" project I suggest combining more libraries:
http://www.opengl.org/wiki/Related_toolkits_and_APIs#Context.2FWindow_Toolkits
http://glsdk.sourceforge.net/docs/html/index.html
SOIL for texture loading
If you are to use modern OpenGL GLFW is the best option out there to manage context, window creation, user input. The lib is very active with constant new releases.
Just wanted to add that my consideration to move from GLUT and from FREEGLUT was the lack of ability to define color, stencil, depth bits and MSAA samples for created context. GLFW allows you doing this.
SDL can create windows with OpenGL context (see the SDL_WINDOW_OPENGL window flag), so you can use the OpenGL functions. So can SFML, and probably Allegro too.
I personally recommend SFML, especially version 2 (which is in development), as I find it very easy to set-up and start using, both generally and for OpenGL.