ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Well what I have to do is to implement simple graphics algo.The algo which are used to draw basic figures (like line,circle,polygon) etc.
we have basic algo for drawing them ie bresharhams algo,dda algo.
In windows we simply include <graphics.h> file and do our work. but in linux how should do that?? I m unable to use commands like setpixel etc
If you don't like the answers you get, refine the question. Repeating the exact same mistakes as before only tells us you are unwilling to learn or accept advise. Therefore, why should anyone try to help?
Install a graphics library. SDL sounds like it might be the best choice for you, it will allow you to access the raw graphics data so you can draw using whatever algorithm you want.
I think OP was put off the idea of having to write code to open a window to draw the graphics in. If so, then the ideal solution would be something that does this automagically - a-la OPs experiences with turbo-c++.
Can someone be reassuring on this point?
There are lots of libs - it must be bewildering.
try using opengui : http://www.tutok.sk/fastgl/. Download the tarball and look in the examples directory for opening a window and drawing basic graphics. Its relatively simple.
well I am ver much sorry that i repeated my question.actually I founded the programming related topics in this forum which i never saw b4 so i thought i may get better answers here...
Simon Bridge: getting a window in SDL is simple enough, without checking for errors its only a few lines:
Code:
#include <SDL/SDL.h>
int
main (argc, argv)
int argc;
char** argv;
{
SDL_Surface* window;
SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMMER);
// 400x320 sized window, color depth of 32
window = SDL_SetVideoMode (400, 320, 32, SDL_SWSURFACE);
// place draw code here (window->pixels stores the pixel data you can alter)
SDL_Flip (window); // call to update the window after drawing to it
SDL_Delay (10000); // admire the window for 10 seconds
return 0;
}
You could try using a graphics package like svgalib (http://svgalib.org)
It uses a cool library vgagl which has most of the pixel rendering function. svgalib will work in console mode (i.e. without starting X server).
If you want a still more simplified svgalib helper graphics package, you can mail me at josedsilva@yahoo.com
If you are looking for a graphics package under X, try SDL or Open GL, GLUT, etc.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.