Rectangle output on the screen? - c++

The user will input two co ordinates. We have to change them to opposite co ordinates and we should output a rectangle on the screen. Can we do it in C++ ??

Sure we can, it's just not quite as simple. You will need an external library to achieve this result - personally I recommend looking into these two tutorials:
I suggest you learn this if you want 2D graphics
Or this if you want to go all the way
With both SDL and OpenGL, once you learn to understand them of course, your issue will be easy to resolve by writing very simple code - writing a rectangle or a similar object is usually the first thing being taught. The difference is that SDL encompasses fairly complex framework that allows you an efficient use of 2D graphics, while OpenGL (which SDL is based upon) is much more difficult to deal with - the reward, on the other hand, is far more freedom in what you can do.

Related

The simpliest way to visualize - easy-use graphics. Which languages and lib?

I'm going to develop math model of trafics simulation and will need to somehow vizualise it. The model will be in C++
I'd like someone to recommend me how can I visualise the result data file - e.g. paint cars, road etc. Language choose is not important but should be easy enough to go into.
os: Win32
UPD:
It'd better be the 2D not 3D
but actually - doesn't matter
Best quality and most general software I've seen is Graphviz.
http://www.graphviz.org/
I've heard lots of good things about VTK (not yet had the occasion to use it myself).
The Wiki contains lots of C++ examples.
Although I do not know how (or even if) it interfaces with C++ you may be interested in processing to quickly build visualizations.
If you want more 2D than 3D and if you know C++, then using Qt and notably its Qt Graphics View framework could be ok.

3-d animation in C++

I am doing a scientific project in C++ and I need to draw simple animated 3-d images of moving atomic groups. What is a good and convenient graphics library to do that? Some general remarks are also appreciated. I work in Linux.
Thank you in advance, Roman
OpenGL of course,
one library you could use is glut for that.
have a look on http://nehe.gamedev.net/
If you want to show 3D in linux, you should use OpenGL. But since it is a C library, you can use a wrapper, like for example glt or sfml
The easiest library to use is Vtk. A more difficult and slower, but potentially better rasterization can be achieved using POVRAY.
I suggest looking at game oriented graphics engines. They provide OO wrappers around openGL and have lots of utility functions for loading 3d model formats etc.
If you don't want to get bogged down in writing the graphics, a game oriented renderer is likely the fastest way for you to get stuff on screen.
Ogre may be a good choice - it has a fairly large and helpful community.
Irrlicht is another possibility.
There are several possibilities, some perhaps more suitable than others, obviously!
I think any one of the options mentioned above would serve to do so.
I personally recommend OSG.
http://www.openscenegraph.org/projects/osg

Finding the right tools for programming a futuristic-styled UI project

I've always been inspired by dynamic, futuristic-like user interfaces. The best I can describe is a graphic interface such as in the latest Iron Man movies.
Although I wouldn't build a full blown application, I would like to make little snipplets of animations that I plan to make interactive. And maybe put them together someday to make something bigger. Admittedly, I will use for audio manipulation in the future but anyway, that's not the point since it's the animations/graphics I'm unsure of.
I know it's possible to make those kind of animations in Adobe After Effects. I'm just having a hard time thinking of the processes (artistically and programmability) to proceed.
While researching on this on my own I have acquired basic experience with OGRE 3D and Blender. I've imported and compiled meshes on OGRE, have been able to do basic things like move the meshes around which is about it.
I'm beginning to think I may be approaching this the wrong way and there are better tools or if 3D is overkill for those kind of animations when 2D would suffice and maybe provide a smoother experience.
I'm having trouble understanding the process and am wondering two things:
1.)The main thing I'm having trouble understanding is how to get still graphics to make animations? Do the meshes keep the timeline from a program like Blender then a graphics engine like OGRE reads the timeline and plays them?
Most importantly:
2.)Do I even need graphics (meshes)? Most of the interface are thin-border boxes, text and shapes of transparent LED-like colors that can move around dynamically to make that futuristic effect.
Please share your opinions, suggestions and anything you think might help me accomplish to develop those kinds of sexy eye candy! Thanks.
When you look at awesome futuristic UIs in movies, they are usually made of
basic primitives
desaturated colors, and/or one color tone
transparency
a cool font or two
high-tech text, graphs or similar
simple animations to make things look "alive", blinking lights/text and similar
a touch interface, of course
Maybe you can't do a lot about the touch interface, but the rest is really not hard graphics wise, it's a matter of carefully crafted artwork and combining simple elements in a cool way.
Also I would look into Adobe Photoshop and fancy texturing rather than Blender and fancy modelling, as you are looking for a fancy 2D UI, and detailed 3D models will not be that important. Playing around in photoshop (well, or GIMP if you want a free alternative) can help you develop your art skills, and help you get that high-tech, sci-fi look on a 2D surface.
You know, I would go as far as to suggest making some sci-fi wallpapers in the style you are after before trying to solve this problem in code. I think you will find that photo manipulation skills and an eye for art will help you here. And for gods sake, look at those movies (Iron Man, Minority Report etc.) that have those UIs you are aiming at, and analyze what exactly they are. Decompose them like I did in the list above.
As for the "which tools should I use?", I say the answer to that is fairly simple:
OpenGL
Photoshop (or GIMP if you are a starving student etc.)
A compiler & toolchain
A code editor/IDE
A cup
I see this is tagged C++, which is an excellent choice of programming language if I may say so.
Ogre is a full blown 3D engine, which is fine, but not exactly targeted at what you want to use it for. You might find that you struggle to get what you want done (disclaimer: I have not tried this in Ogre, and it might work well for this. Then again, when did you last see Ogre used in an audio manipulation program?). My advice is to learn good, simple OpenGL. That would give you complete power over your UI, not get in your way or limit you in any way. It is also cross platform, well documented, and used by tons of developers all over the world (also for audio manipulation applications). I can't see how you could possibly go wrong with it. The fun part is that it probably won't take you long to get advanced enough in it to start developing some pretty nice UIs. As I mentioned, it's more of an art problem than a coding problem.
The cup is for the coffee, by the way. :)
The easiest and most efficient way is to keep track of all your graphics data (meshes, animations, effects) in "media files" and load & play them in runtime. Though you'll be able to easily change your game without changing the code.
For example, you have a Diablo-like game and you wanna turn it to the future-style. You just need to rewrite some player and AI scripts and modify meshes/effects/sounds/animations. But if you've done those via code - it will be a new game from scratch.
I would suggest Ogre, but you already used that, so by my opinion, you are on the right track.
Look up 'billboards' in Ogre documentation, re: LED and 2D stuff.

Animation with C++

is there anyway to build rich animation with C++?
I have been using OpenCV for object detection, and I want to show the detected object with rich animation, Is there any easy way to realize this?
I know flash can be used to easily build rich animation. But can flash be reliably integrated with C++ and How?
Also, Can OpenGL help me with this? To my knowledge, OpenGL is good for 3D rendering. But I am more interested in showing 2D animations in an image. So I am not sure whether this is a right way to go.
Another question, how are those animations in augmented reality realized? What kind of library are they using?
Thank you in advance.
Its difficult to tell if this answer will be relevant, but depending on what sort of application you are creating you may be able to use Simple DirectMedia Layer.
This is a cross-platform 2D and 3D (via OpenGL) media library for C, C++ and many other compatible languages.
It appears to me that you wish to produce an animated demo of your processing results. If I am wrong, let me know.
The simplest way to produce a demo of a vision algorithm is to dump the results to a distinct image file after each processed frame. After the processing session, these individual image files are employed to prepare the video using e.g. mencoder. I employed such procedure to prepare this.
Of course, your program can also produce OpenGL. Many people dealing with 3D reconstruction do that. However, in my opinion that would be an overkill for simple 2D detection. Producing flash would be an even greater overkill.

Mac dev - Help getting started with 2d games

I want to make some simple 2d games/clones (for Mac), but I have a few questions:
Should I use Quartz 2d or OpenGL (I don't plan to try 3d anytime soon)
There seems to be a lot of typedef'd things like CGFloat/GLfloat, which should I use?
Should I use Objective-C for the game too (classes) or just C? (I assume I'll use Objective-C and Cocoa for window and views.)
Is it fine to redraw the entire view each time? I don't really understand how the NSView's -drawRect dirtyRect parameter works, how does it know what I want to update?
Are there any good tutorials for this?
Thanks.
Quartz or Core Animation vs. OpenGL really depends what you're trying to do. If you want simple drawing and animation, use Quartz or CA. If you want fast/powerful games, use OpenGL. Eventually I'd suggest learning both.
For the typedef'd things, use whichever is meant for the specific system you're using. For Quartz/CA/CG, use CGFloat. For OpenGL, use GLfloat.
Objective-C vs. C also depends on the speed you want. Objective-C adds a little bit of overhead but will (obviously) let you create much more object-oriented games. I'd suggest using Objective-C if you use Quartz and Core Animation, and either Obj-C or C if using OpenGL. However, if you're doing this on a Mac (e.g. not for iPhone), you probably won't see much difference unless you're doing complex fast drawing.
I'm not entirely sure about drawRect, but this question has some information which may answer that question for you.
For an intro to Quartz, I'd recommend this tutorial, and I've always heard the NeHe tutorials recommended for OpenGL.
If you use SDL with either Cairo or OpenGL, you get virtually the same programming model, but you get cross platform compatibility virtually for free. You should even be able to continue using objective C for the bulk of the game, if you want.
How graphically intensive do you want to get? Cairo will probably be easier to just get going with for 2D.