Graphics for DOS under Dev-C++

This is a discussion on Graphics for DOS under Dev-C++ within the C Programming forums, part of the General Programming Boards category; Hi, i'm a C leaner... Ppl help me! I want to generate graphics in DOS with Dev-C++. It can be ...

  1. #1
    Registered User bubux's Avatar
    Join Date
    Jul 2002
    Posts
    14

    Unhappy Graphics for DOS under Dev-C++

    Hi, i'm a C leaner...

    Ppl help me! I want to generate graphics in DOS with Dev-C++.

    It can be simple graphics. No rendering or hardware stuff.
    Like drawing cirlces, squares, triangles...

    How could it be done? Plz just give me an tiny example and I would be glad!
    Last edited by bubux; 07-06-2002 at 02:12 AM.
    <VBCODE>
    While Bubux.State = "alive"
    Bubux.LoveGod = True
    Wend
    </VBCODE>

  2. #2
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    I'm not sure about devc++, but check out graphics.h

    what you have to do, is initialise the graphics mode,
    then do your stuff.

    There are many functions for drawing simple stuff like you want in graphics.h

  3. #3
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    try and get to grips with the following code:
    Code:
    #include <graphics.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <conio.h>
    
    int main(void)
    {
       /* request auto detection */
       int gdriver = DETECT, gmode, errorcode;
       int midx, midy;
       int radius = 100;
    
       /* 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 */
       }
    
       midx = getmaxx() / 2;
       midy = getmaxy() / 2;
       setcolor(getmaxcolor());
    
       /* draw the circle */
       circle(midx, midy, radius);
    
       /* clean up */
       getch();
       closegraph();
       return 0;
    }
    This should help you!

  4. #4
    Registered User bubux's Avatar
    Join Date
    Jul 2002
    Posts
    14

    Graphics.h

    Thanks!

    But there isn't such header file on Dev-C++4.

    I have it on TurboC2. But how could I pass it to Dev-C++?

    And I think there´s a GRAPHICS.LIB file you should consider passing together with GRAPHICS.H.
    <VBCODE>
    While Bubux.State = "alive"
    Bubux.LoveGod = True
    Wend
    </VBCODE>

  5. #5
    Registered User bubux's Avatar
    Join Date
    Jul 2002
    Posts
    14

    Ok i decide to act

    K, after al i decided to act to see what happens...

    Here we go:
    My TurboC2 is at C:\TC
    My Dev-C++4 is at C:\Dev-C++

    I copied the following files:
    C:\TC\INCLUDE\GRAPHICS.H -> C:\Dev-C++\Include\GRAPHICS.H
    C:\TC\LIB\GRAPHICS.LIB -> C:\Dev-C++\Lib\GRAPHICS.LIB

    Then I started Dev-C++4 and pasted your code.

    Then I ran the file and DevC++ found errors at GRAPHICS.H file.


    Snif, Snif, Snif... Help me plz...
    <VBCODE>
    While Bubux.State = "alive"
    Bubux.LoveGod = True
    Wend
    </VBCODE>

  6. #6
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    Well, firstly, simply taking a header file from one compiler and using it with another won't work, unfortunately.

    You'll have to learn/read up about allegro.

    I can't help 'cos i don't know it myself.

  7. #7
    Registered User bubux's Avatar
    Join Date
    Jul 2002
    Posts
    14

    Ok... But i'll never give-up

    Hey The Dog I ran your example under TurboC2 and it worked!
    Thank you so much!

    But my main objective is to run Graphics.h under DevC++.

    Ppl, I beg, if anyone have a graphics.h header that runs under DevC++ plz let me know!
    <VBCODE>
    While Bubux.State = "alive"
    Bubux.LoveGod = True
    Wend
    </VBCODE>

  8. #8
    Unregistered
    Guest
    try to include it like this
    [code]#include "graphics.h" /* in same directory */{/code]

  9. #9
    Registered User dune911's Avatar
    Join Date
    Sep 2001
    Posts
    140
    ooops, this was me
    ok, again the right code :

    try to include it like this
    Code:
    #include "graphics.h" /* in same directory */

  10. #10
    Registered User whistlenm1's Avatar
    Join Date
    Jan 2002
    Posts
    124
    The graphics library that comes with dev-C++ is <gl/gl.h> which is based on OpenGL
    Man's mind once streched by a new idea, never regains its original dimensions
    - Oliver Wendell Holmes

    In other words, if you teach your cat to bark (output) and eat dog food (input) that doesn't make him a dog. It would have to chase cars, chew bones, and have puppies before I'd call it Rover ;-)
    - WaltP

  11. #11
    Registered User bubux's Avatar
    Join Date
    Jul 2002
    Posts
    14

    OpenGL... good but...

    K... Thanks guys.
    I'm sure ill use youre help in future!

    But currently, what I look for is portabiblity.

    That is, I'm coding a program to compile under Win and UNIX plataforms. I'm not sure if UNIX plataforms suport OpenGL. I've heard Linux does, that means BSD have good chances to support also. But i'm not sure. If you know about it tell me please.

    Another question: does UNIX plataforms suport the Turbo C2 BGI graphics libary?
    If yes, I may continue coding with Turbo C2. The main reason is that I'm still learning C. So I don't need great, complex "COMPILER" like DevC++. Just a C "compiler" is ok. And also ppl say C++ is code waste.
    <VBCODE>
    While Bubux.State = "alive"
    Bubux.LoveGod = True
    Wend
    </VBCODE>

  12. #12
    Registered User bubux's Avatar
    Join Date
    Jul 2002
    Posts
    14

    Hmm dune911...

    Hey dune911 it seems what you told me worked!
    But it generates many conflicts of variables already declared at another header files.

    Maybe I can change this in the future, who knows.
    With a bit of header editing work we could fix it. But it's not good to go editing standard headers, hehe.

    Anyway, thanks but for now i've decided to code on my cute Turbo C2.
    <VBCODE>
    While Bubux.State = "alive"
    Bubux.LoveGod = True
    Wend
    </VBCODE>

  13. #13
    Registered User dune911's Avatar
    Join Date
    Sep 2001
    Posts
    140
    hehe cool !
    can you tell me when it works ?
    i need something like this for dev-c++, too...

  14. #14
    Registered User bubux's Avatar
    Join Date
    Jul 2002
    Posts
    14

    Hmm dune...

    Originally posted by dune911
    hehe cool !
    can you tell me when it works ?
    i need something like this for dev-c++, too...

    If I get it to work ill tell ya for sure! But I'm just a C newbie and I don't think on working over it now. Anyway, who knows, in the future... You can get Turbo C 2 that comes with that BGI Graphics libary for free at http://community.borland.com/article...0841/tc201.zip


    Good luck!
    <VBCODE>
    While Bubux.State = "alive"
    Bubux.LoveGod = True
    Wend
    </VBCODE>

  15. #15
    Registered User dune911's Avatar
    Join Date
    Sep 2001
    Posts
    140
    i am a newbie, too
    thanks for your link...

    maybe the allegro library will work with my
    ms vc++ 6 (i get this in about two weeks).

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginning Game Programming Type Books
    By bumfluff in forum Game Programming
    Replies: 36
    Last Post: 09-13-2006, 05:15 PM
  2. free 2d graphics engine for Dev C++?
    By two31d in forum C++ Programming
    Replies: 3
    Last Post: 11-29-2005, 06:48 AM
  3. Graphics Programming :: Approach and Books
    By kuphryn in forum Windows Programming
    Replies: 4
    Last Post: 05-11-2004, 09:33 PM
  4. Graphics with Dev 6.0 C++
    By gabaji123 in forum C++ Programming
    Replies: 1
    Last Post: 05-19-2002, 03:33 AM
  5. Graphics Devices and Cprintf clash
    By etnies in forum C Programming
    Replies: 6
    Last Post: 05-09-2002, 12:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21