graphics program by OpenGL without windows programming [closed] - c

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I want to do graphics program by OpenGL. But I don't have any experienced in windows programming. Any suggestion?

See these links
lazy foo tutorial for SDL to simplify some file and inputs handling
SDL and OpenGL
Kore engine uses Opengl and SDL and is open source
Kore Engine wiki Some more info on the Kore Engine
My own project using SDL and OPENGL host on Google code
Note that you'll need to code in C++ with those links
EDIT:
I tried GLUT and SFML, and both are easier to use than SDL and OpenGL alone.
GLUT is pretty straightforward but is limited in its scope.
SFML brings the good things of SDL and OpenGL, but with a nice C++ interface instead of the old C interface of SDL and raw OpenGL calls (which are still possible to do). Big performance gain out of the box for the same project, SFML is just better optimized than my own code with SDL.

But I don't have any experienced in windows programming. Any suggestion?
Well, you need to create a window somehow, so that the user can see the beautiful pictures you'll draw using OpenGL. But you're right: Opening a window and creating a OpenGL context is tedious, no matter which OS you're doing it on (the most simple one would be probably NSOpenGLView of MacOS X).
Luckily there are some libraries that abstract away the OS dependent parts of creating a window and creating and attaching a OpenGL context to it.
GLUT is probably the oldest one of those. I discourage using the original GLUT and recommend to use FreeGLUT or OpenGLUT instead, as those are actively maintained. They are easy to use. But GLUT don't give you control over the event loop which essentially means, it's ill suited for creating games.
SDL is actually a whole bunch of sub-libraries, the main library providing creating of windows. Also provides OpenGL support, but has not been tailored for it. Personally these days I'd use SDL for everything but creation of a OpenGL window. But it's fine for audio, loading graphics and such.
GLFW is IMHO one of the nicest OpenGL frameworks out there. It has a well designed API, gives you full control over the event loop and is actively maintained. Also it focuses on exactly one task: Create a OpenGL window and provide a message pump for user input.

Related

Math Functions graph in c [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 8 years ago.
Improve this question
I'm new here, I searched for any related post like my question and I found nothing
I have a project to create a math function graph in a console like f(x)=ax^2+bx+c the user give me a b c and I draw the function.
Someone told me that there are a library called graphic.h that help me with that
so if someone can help me, I'm not finding anything about graphic.h and my project
And if there are another library or anything that could help
Thanks
Sorry for incomplete answer but you have incomplete question so it is impossible to answer ...
What environment you have to use ? You wrote console but what compiler and OS ? because graphics is very different for each
DOS
many schools still use DOS console apps which is not the same as win or linux console. In DOS there is graphics.h which switch to gfx video mode and then you can use CGA/EGA/VGA and sometimes VESA graphics. Haven't done anything in it since Turbo Pascal 7.0 few decades ago.
for DOS I am using direct VGA/VESA access instead (works on win32 too) but anyway look here and here for info about graphics.h with examples.
graphics.h stands for BGI (Borland Graphics Interface) but you need CGA/EGA/VGA or VESA for proper functionality. Most gfx cards emulate them so that should be no problem just do not expect any arbitrary pixel or color resolution. It can handle 640x480x16 or 320x200x256 and the rest depends on your HW. This lib is native only to ancient Borland/Embarcadero compilers so you will find it somewhere in include path so use < > not " " !!! (you do not need to copy it to your project).
#include <graphics.h>
Windows
You have to create graphics window by WinApi or by IDE of your programing language and then you can use GDI which is part of WinAPI and most compilers have libs for it natively.
linux or different GUI OS
I do not code for such so I do not know exactly but should be similar to Windows
OpenGL (any GUI OS and also sometimes DOS with proper drivers)
if you use OpenGL then you can find tons of examples how to create gfx window + OpenGL and also OpenGL GLUT (OpenGL utilities) have functions that take care of windows stuff. You just code code for events like keystroke, mouse move, redraw ...
google NeHe OpenGL tutorials ... not my favorite but beginners like it
Look here for some more info
Now for the function plot
clear gfx screen
create for loop from xmin to xmax
compute y value for each x
do not forget to scale and offset x,y values to fit your gfx area !!!
draw line from previous to actual point
with different color than clear ...

Styled cross-platform native widgets and windows [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I'm looking for a reasonably cross-platform way to render windows and widgets and style them the way I want without losing the ability to interface with the OS-preferred ways of doing things like redrawing or text input. I am also keen on knowing how Photoshop did this on Windows, as a concrete example.
I'm writing a program primarily for myself but I want to leave open a possibility to share it with others afterwards if it would be useful for more people. I want to really customize its look-and-feel but would like to keep it using native GUI libraries, such as windows forms or something more specific than just rendering my inerface to X11 windows. As I have to use it both on Windows and X11 the solution would preferably be cross-platform but I'm ready to implement multiple UI front-ends if needed, too, if it would provide reasonably consistent looks on both systems. OSX support is a plus, but really far from mandatory. I don't see myself porting this to OSX quite yet. I have barely started.
The reason I want theming is simple: I like dark themes because they are very relaxing to my eyes. On Windows, Microsoft Visual Studio and Adobe Photoshop (Photoshop as the only one and VS by default) display a dark theme and I find it enjoyable to work with these pieces of software for the sole rest that my eyes get. However, both of these, as it seems, use Windows' native controls (I can get to individual widgets in these using Hawkeye and they seem to have descriptive class names, consistent with what they represent).
I see this done way more on Windows than on X11 systems (GNOME, KDE, XFCE on GNU/Linux), maybe because Windows' theming is as rigid as it can get and on X11 window managers and GUI toolkits (KDE with Qt comes to my mind) are really flexible at that so apps needn't implement their own styles when the user can choose them DE-wide quite freely.
I didn't really do GUI programming at all before so I feel a little lost. I would like to refrain from drawing all GUI in a window with an OpenGL context, because I like the idea of the OS drawing legible, subpixel-level text for me, according to the users' settings, and handling partial window redraws instead of full ones. I would also like to integrate with the operating system with, for example, text input. As I said, I would like to share the software some day, so it'd be nice if I don't have to make fundamental changes beforehand.
I'm using C for core code as I've grown tired of futile OOP (whose most benefits I fail to understand if I'm the only one working on the project) with C++ and just want to write code, but I see that GUI libraries for C are in deficit, so I'm ready to write the GUI front-end in another language and link it against my C object files.
Bottom line, to focus on a multiplatform example, how does Photoshop go about redrawing native Windows widgets? I see it looks very consistent on Windows and Mac. Supporting X11 would be less of a problem, as I wouldn't force my styling in the X11 version, just proxy all through a standard widget library (Gtk+? Qt?) and let the desktop environment/window managers/whatevs style it for me. Though I don't know enough on how window and widget management works on GNU/Linux desktop environments to make assumptions.
Thanks in advance.
NOTE: This is purely anecdotal and based upon my own assumptions.
Due to Photoshop's age, I would assume it uses its own custom, proprietary GUI toolkit. It may use the underlying OS's native toolkit but more than likely it just mimics the look and feel. I know Sublime Text uses a custom toolkit made by the developer.
I have made simple applications with .NET, GTK (PyGTK), and Qt (PySide). If you want to support multiple platforms I'd really recommend using a cross-platform toolkit instead of writing the GUI specific to each OS because of the amount of work involved.
I liked .NET but it's not really cross-platform (I'm not sure what all is supported by Mono).
GTK2 (via PyGTK) was fairly straight forward to us. It looked good on Linux (Ubuntu) but I could not get some custom styles working properly in Windows (unless Windows 95 looks good). I also found PyGTK's documentation lacking. GTK3 is the way forward, but last I knew it was still under heavy development and isn't stable on Windows (yet).
I will say I liked Qt (PySide) the best. I found its documentation and examples better than GTK's. It supports native OS themeing along with custom styles and themes (I don't have personal experience with this though). By default it looks native on both Windows (XP and 7), and Linux (Ubuntu).
I have no experience with wxWidgets so I have no say on it, but it is cross-platform.
I would recommend looking into using Qt, though you would have to use C++ (or a higher-level language with available bindings).

What simple C graphics library would you recommend? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed last year.
Improve this question
I'm learning C and I would like to start graphics programming, but start it simple, without spending hours just to understand what functions will I need.
I would like something to draw pixels, squares, maybe sprites, simple stuff, like in BASIC.
I tried SDL and got overwhelmed very quickly. Same with Allegro, it's hard to get it to work on Xcode 4 and documentation is lacking.
Maybe there is some custom one? Also would be nice if it works on Mac OS.
Any book recommendations are welcome, like simple C graphics programming or game programming, whatever.
If SDL is overwhelming, perhaps graphics programming is not the place to start in C. If you want to get familiar with the concepts involved in coding up graphics, try it in a higher level language like Python (with pygame or pyglet.) Most high-level languages have good bindings to graphics libraries. If you really want to learn C by writing games, maybe something more text-oriented (ncurses-based?) is appropriate.
Once you understand the fundamental idioms of graphics programming, applying them to different languages becomes much easier. You'll be able to go from pygame to SDL in C without too much extra pain beyond that inherent in going from Python to C.
I'd go for QuickCG. Here you can find sources and some tuts.
The best you can use at least which is both portable and now almost an industry standard, simple graphics can be done using OpenCV. This is not limited to just drawing lines or primitives, or should I say simple graphics, I have used it for industry standard image processing products and computer vision problem solving. This will be fun if you start learning it. OpenGL is also another place to start. It might well suit what you want. Mostly related to graphics, rather than computer vision or image processing
Another option would be to investigate the Postscript language to get a feel for the stencil/paint image model. And then you could more easily get started with Cairo which implements the same model. A big advantage to the stencil/paint model is device independence. With Cairo you can perform the same drawing commands to output to a window, an in-memory pixmap, or a pdf file writer.
"g2 graphics library" is the most simple. The programming language is C. But does not support "only" 64 bit systems (it supports 32 bit like Mac OS Mojave, and Ubuntu, have not checked up with Windows MSYS MinGw). To create User Interfaces i recommend FLTK (Fast Light Toolkit) with the UI-builder Fluid.
https://sourceforge.net/projects/g2gl/
https://www.fltk.org/software.php

Graphic programming over video playback [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to make some GUI mockup program for video player, so my idea is just to show some menu pictures over real video being playback. I have working program made with C and SDL just to load pictures and make a slideshow, but i don´t know how to put this over video with transparencies.
Do you have a hint?
ps. i usually program with python and C, so if there is any solution with this two i highly appreciate.
Thanks!
Suggestion: use Openframeworks
http://www.openframeworks.cc/documentation
It is in C++ though, and not C.
Check the documentation for class ofVideoPlayer
I think you can use this tutorial, to get a working video player in SDL: http://dranger.com/ffmpeg/tutorial01.html
The tutorial is using SDL and ffmpeg. In the "tutorial 01", the video frame is converted to 24-bit RGB, so you can just do some tricks and translate to a surface.
If you want the overlay, you can see this library: http://www.libsdl.org/projects/sdlyuvaddon/
There is a function (Get_YUV_From_Surface) to convert a surface to YUV. You will need to modify it to fit your needs, but you can see the function to get some ideas.
You could render the video with OpenGL using a textured quad, and then do all your 2D drawing on top (with an appropriate 2D projection matrix setup) using GL.
SDL OpenGL support
Python OpenGL bindings
Depending on your codec, you are quite likely to end up with YUV data (rather than RGB). Depending on the platform and your hardware, you may be able to use a native texture type, to avoid having to convert to RGB first.
By using alpha blending, you can easily come up with some very sophisticated looking UIs. You will probably want to look into something like FreeType to handle the font rendering, as this is one area of GL that is platform-specific and fiddly to get working.
There are loads of tools, scene graphs, widget libraries and so on for OpenGL you can use too.
You can use Gstreamer with both C/python.
all you have to do is to overlay a rendered video on a window.
Check out the doc of how to do it https://gstreamer.freedesktop.org/documentation/video/gstvideooverlay.html?gi-language=c#GstVideoOverlay

A Simple, 2d cross-platform graphics library for c or c++? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
As in title, i need a 2d graphics library that is cross-platform, and provides simple functions, like in Basic; essentially, i only need to paint a pixel a certain color-I do not need hardware acceleration, or any kind of 3d support. I've found a couple ones, but they're not cross-platform.
Anyone knows a solution for me?
What about SDL?
Perhaps it's a bit too complex for your needs, but it's certainly cross-platform.
Am I missing something to wonder why noone suggests OpenGL? To use it for 2d would be very simple. The OP only wants to color a pixel. It doesn't get simpler than glBegin/glColor/glVertex/glEnd.
Qt 5
GTK+
Cairo
and many many more ...
[In no particular order.] However, if you have any other requirements, let us know. BTW: I am not just posting results of a Google query here, I have used all of these (and SDL -- wrote my first few games in SDL :) and I'd say without a set of requirements, it's very difficult to choose among the ones listed.
Heavy-weight:
GTK
QT
WxWidgets
Lightweight:
FLTK
Fox
Tk
Lua IUP
Ultimate++
dlib
Drawing frameworks without GUI widgets:
SDL
Cairo
http://www.allegro.cc/
http://en.wikipedia.org/wiki/Allegro_library
One neat engine I came across is Angel-Engine. Info from the project site:
Cross-Platform functionality (Windows and Mac)
Actors (game objects with color, shape, responses, attributes,
etc.)
Texturing with Transparency
"Animations" (texture swapping at defined intervals)
Rigid-Body Physics
A clever programmer can do soft-body physics with it
Sound
Text Rendering with multiple fonts
Particle Systems
Some basic AI (state machine and pathfinding)
Config File Processing
Logging
Input from a mouse, keyboard, or Xbox 360 controller
Binding inputs from a config file
Python Scripting
In-Game Console
Some users (including me) have succesfully (without any major problems) compiled it under linux.
I would recommend DISLIN. It's cross platform, has support for many languages, and has very intuitive naming of routines.
Also, just noticed that nobody mentioned PLPLOT, also cross platform, multi lingual ...
Picasso graphic library you can used: cross platform
https://code.google.com/p/picasso-graphic/
A cross platform 2D graphics library for .Net is The Little Vector Library
You could use it in conjunction with Unity 3D (recommended) or Xamarin, for example, to create 2D graphics on a variety of platforms.

Resources