LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Graphics in c++ in fedora (https://www.linuxquestions.org/questions/programming-9/graphics-in-c-in-fedora-868257/)

Samael 03-17-2011 12:37 PM

This may help:
http://stackoverflow.com/questions/2...latform-manner

SigTerm 03-17-2011 01:19 PM

Is this("Linux console color and other tricks") or this("Prompt Magic") what you were looking for?

theNbomr 03-17-2011 02:32 PM

Quote:

Originally Posted by Samael (Post 4294143)

But, if you do that, you will end up back here asking essentially the same question next time your code needs to run on a different terminal type. That's one of the problems that ncurses solves.

--- rod.

shivi91 03-19-2011 01:03 PM

thanks but i still don't get the code in lang c++...

MTK358 03-19-2011 01:11 PM

Quote:

Originally Posted by shivi91 (Post 4296252)
thanks but i still don't get the code in lang c++...

Do you really expect us to write your code for you?

And you never really said what you want. Do you want to:

Be able to draw stuff (not limited to text) in a graphical window

--- OR ---

Be able to change the color of text printed to a terminal?


Those are very different, unrelated things and require completely different answers.

dugan 03-19-2011 01:23 PM

Quote:

Originally Posted by shivi91 (Post 4294044)
i have no clue abt the high tech terms that every1 is using...

So look up the words you don't understand.

theNbomr 03-19-2011 01:44 PM

Lots of people have tried to help you. We need more information, and we have asked you specific questions that you can answer to give us that information. You gave us
Quote:

i still don't get the code in lang c++
When you help us help you, maybe that code will start to happen.
--- rod.

dugan 03-19-2011 01:48 PM

You've already been given enough resources that you can write the code yourself. You use ncurses or s-lang for the cursor position and stuff, and ANSI escape sequences for the colors. Yes this requires you to read the links that were previously posted. And no, we're not going to write it for you.

John VV 03-19-2011 09:36 PM

When i here graphics in "c" i think of
Cimg.h

a very nice lib ( built at compile)

shivi91 03-20-2011 01:47 AM

Quote:

Originally Posted by John VV (Post 4296586)
When i here graphics in "c" i think of
Cimg.h

a very nice lib ( built at compile)


whenver i try to complie on of the tutorial program they have given in that site..
error occurs that is

p2.cpp:3:19: fatal error: CImg.h: No such file or directory
compilation terminated.





the code is
#include <Cimg>
using namespace cimg_library;

int main() {
CImg<unsigned char> image("lena.jpg"), visu(500,400,1,3,0);
const unsigned char red[] = { 255,0,0 }, green[] = { 0,255,0 }, blue[] = { 0,0,255 };
image.blur(2.5);
CImgDisplay main_disp(image,"Click a point"), draw_disp(visu,"Intensity profile");
while (!main_disp.is_closed() && !draw_disp.is_closed()) {
main_disp.wait();
if (main_disp.button() && main_disp.mouse_y()>=0)
{
const int y = main_disp.mouse_y();
visu.fill(0).draw_graph(image.get_crop(0,y,0,0,image.width()-1,y,0,0),red,1,1,0,255,0);
visu.draw_graph(image.get_crop(0,y,0,1,image.width()-1,y,0,1),green,1,1,0,255,0);
visu.draw_graph(image.get_crop(0,y,0,2,image.width()-1,y,0,2),blue,1,1,0,255,0).display(draw_disp);
}
}
return 0;
}



i tried the same code with c complier .it didn't work

shivi91 03-20-2011 02:02 AM

#include <graphics.h>

#include <stdlib.h>

#include <stdio.h>

#include <conio.h>

#include<iostream.h>



int main(void)

{

/* request auto detection */

int gdriver = DETECT, gmode, errorcode;

int left, top, right, bottom;



/* initialize graphics and local variables */

initgraph(&gdriver, &gmode, "");



/* read result of initialization */

errorcode = graphresult();

if (errorcode != grOk) /* an error occurred */

{

printf("Graphics error: %s\n", grapherrormsg(errorcode));

printf("Press any key to halt:");

getch();

exit(1); /* terminate with an error code */

}

cout<<endl<<endl<<endl<<" zxc HOSPITAL" <<endl<<endl<<" name-abc age-56 "<<endl<<endl<<" reg no-907 Dr name-mno"<<endl;

left = getmaxx() / 2 - 200;

top = getmaxy() / 2 - 200;

right = getmaxx() / 2 + 200;

bottom = getmaxy() / 2 + 200;



/* draw a rectangle */

rectangle(left,top,right,bottom);



/* clean up */



getch();

closegraph();



return 0;

}


i am tring to convert this code for fedora
but i quite get stuck at few things
conio should be replaced with what.
graphics.h doesn't work what should be done for that?

shivi91 03-20-2011 02:12 AM

slang..tried to use that... but same kind of error...
fatal error

what should b done?

Aquarius_Girl 03-20-2011 02:24 AM

List out here the errors you get when you remove conio.h and then compile.

John VV 03-20-2011 02:55 AM

Quote:

whenver i try to complie on of the tutorial program they have given in that site..
error occurs that is

p2.cpp:3:19: fatal error: CImg.h: No such file or directory
i take it you did NOT copy cimg.h to /usr/include
-- or ---
and give the full or relative PATH to it in the source folder
every example in the "examples" ( for the examples the relative path would be " ../ " ) folder uses that "Makefile" to build all of them
Code:

make MLinux

shivi91 03-20-2011 04:35 AM

Quote:

Originally Posted by John VV (Post 4296754)
i take it you did NOT copy cimg.h to /usr/include
-- or ---
and give the full or relative PATH to it in the source folder
every example in the "examples" ( for the examples the relative path would be " ../ " ) folder uses that "Makefile" to build all of them
Code:

make MLinux

hey i downloaded cimg.h from net
pasted that in /usr/include.but still the program shows the same error


All times are GMT -5. The time now is 05:12 PM.