how to see the 3d image in an opengl output [closed] - opengl

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
i was reading opengl superbible, they were telling i can use the arrow keys to rotate the output and get a 3d view of the whole image
but i dont seem to get it........
Any new functions needed to be invoked?
Thanks in advance

First of all you have to understand the difference between the windowing library and the opengl context. In short, here is an overall summary.
OpenGL can be split in 2 parts:
The client
The driver
The client library is just a bunch of headers that you have to install. The driver is shipped with your graphic card.
The only thing that you can do is to manipulate an OpenGL context, that is, a set of buffers (frame buffers: color, depth, stencil, accumulation...) and states.
The context itself has no notion of "window" or "key". All it does is take some inputs, let it go through its pipeline, and save the output in frame buffers.
Next, there is the windowing system ( native ones: Win32, Cocoa, ..., or libraries built on top of it: Qt, GLFW, SDL, SFML, ... ) that provides windows, user input, drawings, etc... It is the windowing library that knows how to read OpenGL buffers and display them on screen.
So basically, all you have to do is to choose a windowing library, set up an OpenGL context, feed it with some inputs, and ask the window library to display the content on a canvas-like widget.
Give some more informations on what you're trying to do if you want more information.
Sides notes:
http://www.songho.ca/opengl/gl_pipeline.html for a description of the OpenGL rendering pipeline
http://www.opengl.org/sdk/docs/man/ for the OpenGL 2 reference manual
Look at these simple windowing libraries:
http://www.libsdl.org/ : SDL
http://www.sfml-dev.org/index.php : SFML
http://glfw.sourceforge.net/ : GLFW
http://www.opengl.org/resources/libraries/glut/ : GLUT

The OpenGL SuperBible doesn't bother including the entire program in the text of the book, just the pertenate code snippets that illuminate the topic at hand. Just download the complete source code at www.opengl.org/supperbible. Running these programs will give you the complete functionality described in the text of the book.
The OpenGL graphics library does not include user interaction functions such as moving the model with arrow keys. Another library or custom code is required to supply that functionality. The OpenGL SuperBible's sample programs use the GLUT library to supply user interaction functionality. The OpenGL SuperBible covers GLUT in addition to OpenGL, see chapter 2 for enough information on GLUT to understand the example programs.

Related

Software and Hardware rendering in SDL2/SFML2

First off, I'm relatively new to this. I'm looking forward to picking up both SDL2 as well as SFML2 libraries for game dev. (and other stuff).
Now I know for a fact that both SDL2 and SFML2 are capable of creating OpenGL enabled contexts, through which OpenGL graphics programming may be done.
But online, I've read discussions wherein people said something to the effect of "SDL 1.2 is software accelerated, SDL2 and SFML2 are hardware accelerated by default". I know that software rendering is graphics using CPU alone. While Hardware rendering uses graphics cards/pipeline.
So my question is, with regards to these game libraries:
Part 1: when someone says one is software/hardware acc.by default, what does he mean? Is it that (my guess) if say SFML2 is hardware acc. by default, even basic 2d graphics are done by it using hardware rendering as the backend pipeline to do it, even if I didn't explicitly do any hardware-rendering programming in the code?
Part 2: And if that is true, is there any option within these libraries to set that to software acceleration/rendering?
Part 3: Which of these 2 libraries (SDL2 vs SFML2) has better overall performance/speed?
Thanks in advance for any answer and apologies if you found the question dumb.
Cannot say anything about SFML (but almost sure things are very close), but for SDL it is as you say. In SDL1 2d drawing implemented as blitting directly on display surface, and then sending this surface to display - so mostly software (although minor hw acceleration is still possible). SDL2 have SDL_Renderer and textures (which are GPU-side images or render targets) and any basic drawing that uses renderer may be accelerated by one or another backend. Which backend will be chosen depends on system your program runs and user settings - e.g. it would default to opengl for linux, d3d for windows (but still can use opengl), opengles for android/ios, etc..
You can use software renderer either by explicitly calling SDL_CreateSoftwareRenderer, or hint SDL to use software driver, or even override it by setting SDL_RENDER_DRIVER environment variable.
If you intend to use opengl for 3d graphics - then you just ignore all that and create window with opengl context as usual, and never use SDL_Renderer.

Need some help to choose beetween Allegro 5, SDL 1.2, SDL 1.3 or SFML [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I won't start a debate about which library is better, it would be against the rule, but more ask a series of technical question. When i ask if there is special technique, just say the name of the technique, or a link.
Don't forget, im comparing also SDL 1.2 AND SDL 1.3, not just one of those
Which library have multiple window support?
I already know the answer for SDL: SDL 1.2, no, but 1.3 yes
Which of those library are multi-threading safe?
Most of the speed test were done when SDL and allegro were using software acceleration, but now that SDL 1.3, allegro 5, and sfml use hardware acceleration, in terms of speed, how do they compare?
Which of those library can detect more than one keyboard press at once? Is there any special technique to do so?
Is there a way to integrate the result in a GTK window? If yes, is there any special technique? (I remember last time i used SDL 1.2, i wasn't able to do this...)
Which library has support for 3d? (using openGL)
If i use X library with OpenGL for graphics, will there be limitation, or more/less features available? (I mean, is using opengl for graphics the same for all those libraries?)
Which of those libraries can I statically link to?
And finally, are some of those libraries more toward a particular game style? (Like X library is better used when making RPG, while Y library is more used while making strategy game, tile based game...)
Don't forget about SDL 1.2 AND SDL 1.3
EDIT:
I will try to share everything i found out, from my research, feel free to contribute to get more answer to my question.
Multiple window: SDL 1.3, SFML
No multiple window: SDL 1.2
Multi-threading safe: Allegro 5, SFML
Not Multi-threading safe:
Speed: Unknown
More than one key-press support: SFML, Allegro 5

2D Vector graphic renderer for OpenGL [duplicate]

This question already has answers here:
Rendering Vector Graphics in OpenGL? [duplicate]
(5 answers)
Closed 5 years ago.
I want to use Vector graphics in an OpenGL game. I want to use vector graphics because they can be scaled cheaply without loss of quality.
Of course, the drawing should be hardware accelerated, so I do not want to draw in software to a texture.
Now I am wondering if a library doing this already exists. Is there a library, that can load some vector graphic format and display it using OpenGL?
I would not bother with anything OpenVG, not even with MonkVG, which is probably the most modern, albeit incomplete implementation. The OpenVG committee has folded in 2011 and most if not all implementations are abandonware or at best legacy software.
Since 2011, the state of the art is Mark Kilgard's baby, NV_path_rendering, which is currently only a vendor (Nvidia) extension as you might have guessed already from its name. There are a lot of materials on that:
https://developer.nvidia.com/nv-path-rendering Nvidia hub, but some material on the landing page is not the most up-to-date
http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/opengl/gpupathrender.pdf Siggraph 2012 paper
http://on-demand.gputechconf.com/gtc/2014/presentations/S4810-accelerating-vector-graphics-mobile-web.pdf GTC 2014 presentation
http://www.opengl.org/registry/specs/NV/path_rendering.txt official extension doc
NV_path_rendering is now used by Google's Skia library behind the scenes, when available. (Nvidia contributed the code in late 2013 and 2014.)
And to answer a more specific point raised in the comments, you can mix path rendering with other OpenGL (3D) stuff, as demoed at:
https://www.youtube.com/watch?v=FVYl4o1rgIs
https://www.youtube.com/watch?v=yZBXGLlmg2U
You can of course load SVGs and such https://www.youtube.com/watch?v=bCrohG6PJQE. They also support the PostScript syntax for paths.
An upstart having even less (or downright no) vendor support or academic glitz is NanoVG, which is currently developed and maintained. (https://github.com/memononen/nanovg) Given the number of 2D libraries over OpenGL that have come and gone over time, you're taking a big bet using something not supported by a major vendor, in my humble opinion.
Take a look at OpenVG.
Lots of discussion in this Slashdot post about renderers for SVG. I don't know which of them using OpenGL, if any.
This SO question also has several suggestions, including sauvage which is done in Python. Cairo is also apparently a possibility.
There are several powerful libraries that render SVG without OpenGL. I wonder if it's not really that necessary: maybe drawing lines is already accelerated enough on most systems' graphics cards.

How to create a transparent glass cup in OpenGL ES/OpenGL? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
Is there a way to create a glass cup with OpenGL ES/OpenGl? And if it's possible, what can i read to start creating? Need to get the most realistic view of a glass, for example -
see glass cup image
For simplicity, without handles.
Maybe, anybody has example with sources?
Thanks.
Getting something that looks very close to the image you linked would be very complicated (the handle is not the hard part). If this is a learning project, I would suggest starting smaller. Rougher approximations would be a better starting place.
You can make a semi-transparent object easily in OpenGL ES. The OpenGL feature you want is Alpha Blending. This won't get you very close to your glass though. http://www.opengl.org/resources/faq/technical/transparency.htm
A basic level of replicating this object would be to use a hand-drawn grayish texture that looks sort of like the interior refractions and draw it on a camera-oriented sprite with partial transparency. Then render a regular cup-shaped model with high transparency with only a small amount of ambient and diffuse lighting and a lot of specular lighting to make it look shiny.
The multi-bounce refraction effect of a rounded glass object is much more difficult. Especially if you want it to look convincing when something other than a blank background is behind the cup. It's fairly straightforward to do in a raytracer, but not in a rasterizer like OpenGL. Look up Caustics. There are methods to approximate this effect but they are not beginner projects.
According to this there are some examples in GLUT if you're serious about it. http://www.opengl.org/resources/faq/technical/lights.htm
I know this post is over a year old , but i came across this post on the internet, which may help. (Its russian or whatever, use google translate to change it to english)
With programmable shaders it is possible to create nice glass effects, such as reflection combined with refraction. OpenGL ES 2.0 has programmable shaders, but OpenGL ES 1.X does not.
A good example of glass with OpenGL ES 2.0 comes with AMD RenderMonkey (free). Download here, and have a look at the glass examples.

OpenGL Windowing Library for 2009 [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 1 year ago.
Improve this question
Trying to decide on a library for creating a window and capturing user input for my OpenGL app, but there are just way too many choices:
GLUT (win32)
FreeGLUT
OpenGLUT
SFML
GLFW
SDL
FLTK
OGLWFW
Clutter
Qt
Others?
GLUT is simply outdated. I liked GLFW but it seems you can't set the window position before displaying it (I wanted it centered, is that so much to ask?) so you see it appear and then shift over, which bothers me. Plus development seems to have stopped on it too. SFML has some nice features, but it uses event polling rather than callbacks which I prefer for decoupling. I don't think I need all the GUI features of FLTK. SDL is slow (doesn't seem to take advantage of the GPU). And the other 3 I don't know much about (FreeGLUT, OpenGLUT, OGLWFW). So which is the lesser of the evils? Are there others I haven't heard about?
I'm just trying to make a simple 2D game. I'm familiar enough with OpenGL that I don't really need drawing routines, but I probably wouldn't complain about other functions that might be useful if they are implemented properly.
SDL allows you to create an OpenGL context that is accelerated (depending on drivers / hardware support).
I know you tagged as C++, however pygame (python) is a great library for creating 2D games, which also supports an OpenGL context. Pygame is built on SDL.
Clutter is a new OpenGL based GUI library with bindings for Perl, Python, C#, C++, Vala and Ruby. I haven't used it myself. From the website:
Clutter uses OpenGL (and optionally
OpenGL ES for use on Mobile and
embedded platforms) for rendering but
with an API which hides the underlying
GL complexity from the developer. The
Clutter API is intended to be easy to
use, efficient and flexible.
GLUT and the other GLUT alternatives should not be used in any sort of production application. They are good for putting together a quick demo application or to try something out, but not for much more than that.
If you're trying to make an OpenGL game, I'd recommend SDL. It focuses more on gaming needs. It most definitely can be used with OpenGL. A brief google for "SDL OpenGL" turned up this link on how to initialize OpenGL with SDL. Enabling OpenGL should also enable hardware rendering with the GPU.
Qt is a reasonable alternative, but it's better if you want to embed OpenGL within a larger, desktop application (think 3D modeling, CAD/CAM, medical visualization, etc) where you need access to standard OS widgets for the UI.
I'd go for Qt. Nice general purpose library + opengl support
IF "learning c++ part of what you're trying to achieve":
then
IF "you only want to learn OpenGL with a fullscreen mode":
USE GLUT //Because it's VERY VERY simple. You can get set up VERY quick
ELSE:
USE QT //Great library, has many many things that will help you. It is portable, it has a nice API
ENDIF
IF "you don't need C++":
then
USE Python //I recommend it, it is fast, no long link times, good api, omg I love this language
Background:
I also tried to make simple 2D games once, I started with C++ and NeHe. I knew nothing about OpenGL and C++ (had Java background). The language overrun me, so did OpenGL. So it was a very hard learning curve.
I don't recommend going that way, since you can get faster results by using a dynamic language (such as Python). So I started learning some years later with python. I could get the "rotating cubes" working much faster.
We have had rather good experiences with ClanLib 0.8 in 2008 and ClanLib 2.1 in 2009 on our C++ course. The productivity of the students (as measured by the quality of their project works) has greatly increased since switching over from SDL. However, it needs to be noted that 2.1 is still very incomplete and one will certainly run into features that are simply not implemented yet.
A couple of groups used Irrlicht (3D engine) with good results.
SFML looks promising, but I haven't had a chance to try it yet.
As others have stated, GLUT is not really suitable for anything serious. The rest of the libraries mentioned are something more of GUI toolkits than game development libraries.
Per recent corespondance with the author, development on OGLWFW has stopped.