I want to make a minimal visual display in console with openGL, but as far as my knowledge goes there has to be a window system involved(glut, glfw, sdl, etc..).
I've seen omxplayer build a graphic environment(I just assume it is openGL or something similar, so please correct me if I'm wrong) from console, in order to save some processing power, and make movies watchable in the PI.
I'm just wondering how do they do it? Is there some literature in the topic? I'm mostly interested in solutions in C/C++, but any language with these capabilities would be great to know about!
I scavenged through the source code, but couldn't really find a clue about this particular task. Any help or pointer would be appreciated!
Note: the Raspberry Pi does OpenGL ES, not OpenGL.
You can find examples of making console based OpenGL ES applications in the VideoCore SDK:
/opt/vc/src/hello_pi
I'm not sure what you mean by "window system", especially as you mention SDL. You can absolutely use SDL + OpenGL ES in the console. That's what the Quake3 port (and the Quake2 port I made) uses.
It uses the EGL native platform interface.
Here's some code from the SubtitleRenderer class:
void SubtitleRenderer::initialize_vg() {
// get an EGL display connection
display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY);
ENFORCE(display_);
// initialize the EGL display connection
ENFORCE(eglInitialize(display_, NULL, NULL));
// get an appropriate EGL frame buffer configuration
static const EGLint attribute_list[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_ALPHA_SIZE, 8,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_NONE
};
EGLConfig config{};
EGLint num_config{};
ENFORCE(eglChooseConfig(display_, attribute_list, &config, 1, &num_config));
Related
Now I need to develop a plug-in that can take screenshots on Ubuntu, CentOS and fedora. I try to write it in Xlib. It can run on Ubuntu and CentOS, but Fedora uses Wayland, and the plug-in that I developed can't work.
Gnome screenshot can work on these platforms, but after reading his source code, I found that it can achieve screenshots by calling other processes, which is hard for me to learn from.
So is there any way I can take a screenshot on Wayland engine?
I get it in using dbus, here is the light code:
method_name = "Screenshot";
method_params = g_variant_new ("(bbs)",
TRUE,
FALSE, /* flash */
filename);
connection = g_application_get_dbus_connection (g_application_get_default ());
g_dbus_connection_call_sync (connection,
"org.gnome.Shell.Screenshot",
"/org/gnome/Shell/Screenshot",
"org.gnome.Shell.Screenshot",
method_name,
method_params,
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
I accidentally updated my Mac, and OpenGL is now deprecated in the latest MacOS Mojave. I'm using OpenGL + GLUT (I know this is old, but I just need a simple program) and run on terminal (not using Xcode). With the same program that has been working perfectly in Sierra, I got so many OpenGL deprecated warnings in Mojave and managed to suppress all the warning using -Wno-deprecated-declarations , but now I only get black screen.
I read a lot of same issues with black screen on OpenGL after Mojave update, like Black screen on OpenGL , and Mac Mojave + opengl
Ask Question. But as of now, none of them have accepted answer and the provided answers don't work on me.
This is my main loop :
Code :
static void mainLoop(void)
{ glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_FRAMEBUFFER_SRGB);
argDrawMode2D(vp); //draw to the screen
char string[256];
glColor3f(1,1,1);
sprintf(string, "Some strings", string1 );
argDrawStringsByIdealPos( string, 10.0, 25.0 );
argSwapBuffers(); //clear the buffer
glFlush();
}
I have 2 questions :
Do you have any suggestion how to solve the black screen problem ? What I have tried but still got black screen :
Change glFlush() into glutSwapBuffers() to flush without a call
Change glClear(GL_COLOR_BUFFER_BIT) into glClear(GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT) (this one causing even more warning). Also I tried to set the color into glClearColor(255,255,255,0) (white), but after clear color buffer, only black screen. So the glClear isn't working.
Try to resize the window using reshape.
Update Xcode compiler for terminal to the latest version (Beta)
I'm using Gamma Correction from OpenGL with with glEnable(GL_FRAMEBUFFER_SRGB), and after Mojave I'm facing this
"Assertion failed: (value >= 0.0f && value <= 1.0f), function
LinearToSRGB"
Does the openGL gamma correction doesn't work anymore ?
Any Suggestion ?
[UPDATE 1]
Step 3 above : Try to resize the window using reshape.
This one seems to work a little bit after I changed into full screen, following this Mojave 'hack' from The University of Bath, to resize your window to other dimension than the initial size. It failed when I set to another size (smaller/bigger), but when I set into fullscreen using glutFullScreen(); , my screen is rendered, as of now the frame transition is not smooth and I'm still working on it.
Also, I set my fps into 60fps and print them out. And after this hack I got random fps from 100-200 fps here, despite my Mac refresh rate only 90Hz. It is because the resize command, when I commented out the resize command I got black screen but the printed fps in terminal is correct (around 60fps). I realize this hack is also not reliable in the future. So, still need suggestion here, or other solution rather than resize.
[UPDATE 2]
I tried to changed my whole project using GLFW. Still the same black screen issue even with GLFW. Therefore this is not API issue.
[UPDATE 3]
Tried to clean uninstall XCode 10 (which comes with Mojave update). Then install XCode 9.41 (Sierra) and Command Tools 9.41 as well. As of now, the GLFW works, and the GLUT still doesn't work.
I need to open the default audio capture device and start recording. libsox seems to be a nice cross-platform solution. Using the binary frontend, I can just rec test.wav and the default microphone is activated.
However, when browsing the documentation, no similar functionality exists. This thread discusses precisely the same topic as my question, but doesn't seem to have reached a solution.
Where could an example of using libsox for recording from the default audio device be located?
You can record using libsox. Just set the input file to "default" and set the filetype to the audio driver (e.g. coreaudio on mac, alsa or oss on linux)
const char* audio_driver = "alsa";
sox_format_t* input = sox_open_read("default", NULL, NULL, audio_driver);
Look at some examples for more info on how to structure the rest of the code.
You need to record with alsa first and use libsox for the right format. libsox is not for recording. see example: https://gist.github.com/albanpeignier/104902
How do I command Arducopter to enter guided_nogps mode? I am planning to operate in a gps denied environment, and although other posts indicate this is possible with guided-nogps, I cannot see how to set that mode. Using Dronekit (python) vehicle.mode = VehicleMode("Guided_NoGPS") returns an error indicating there is no such mode.
Mavlink also refuses to acknowledge the mode.
My setup is a Pixhawk running Arducopter with a Raspberry Pi companion. Firmware is v3.5 dev, and v3.4 on the DroneKit-SITL (I compiled my own v3.4 binary for this).
Everything else is working great (e.g. controlling via set_attitude_target thanks to this post How to set copters Attitude via DroneKit -- SET_ATTITUDE_TARGET not working ) - I just need to be able to go indoors!
Also - I did notice in this post prior to the release of Arducopter v3.4 Controlling movement without GPS that an optical flow sensor might be required. Did that requirement come to pass?
Thanks again!
All advice welcome.
Thanks Squilter for your help. I created a function to change the flightmode (20):
def set_mode(flightmode):
# create the MAV_CMD_DO_SET_MODE command
msg = vehicle.message_factory.command_long_encode(
0, 0, # target system, target component
mavutil.mavlink.MAV_CMD_DO_SET_MODE, #command
0, #confirmation
flightmode,
0, 0, 0, 0, 0, 0 )
# send command to vehicle
vehicle.send_mavlink(msg)
The message is correctly received but was not successful (result 3 returned). One thing I wasn't sure about was parameter 2, which the spec indicates is platform specific. I put 0 as I wasn't sure what to do with it for Arducopter.
Again, any suggestions welcome and many thanks!
Try setting the mode to 20. This is the internal representation of the mode. It looks like dronekit-python does not know this yet.
Optical flow is required for normal guided mode, not guided_nogps. However, guided_nogps does not allow sending velocity or position requests, only angles.
I know that this question is a little old but I have found the answer. Update your installs of MAVProxy and PyMAVLink.
pip install -U pymavlink mavproxy
DroneKit will automatically install older versions of them without the new modes available. You want PyMAVLink >= 2.2.4 and MAVProxy >= 1.6.1.
How do I create a core profile using GLFW and OpenGL? I'm currently running Mesa 10.0.2 which should support OpenGL 3.3 in a core profile and 3.0 in a non-core profile.
Currently this is what I'm trying to do.
glfwOpenWindowHint(GLFW_FSAA_SAMPLES, 4);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 3);
glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// Create context
if( !glfwOpenWindow( 1024, 768, 0,0,0,0, 32,0, GLFW_WINDOW ) )
{
fprintf( stderr, "Failed to create context\n" );
glfwTerminate();
return -1;
}
I found this to be largely a GLFW version issue as genpfault and Brett Hale pointed out. Once I ported the offending code to GLFW 3 the issue disappeared. I also updated to a newer version of the GLM library. For those who are playing with opengl-tutorial.org, I suggest taking it as an exercise to rewrite the code using updated libraries as the ones supplied are very old at this point.