Thread: graphics.h alternative

  1. #1
    Registered User
    Join Date
    Jan 2023
    Posts
    5

    graphics.h alternative

    Hi,

    I'm using graphics.h because it have all the features I need. But it's a bit old (2004) and for now I'm running the program in a virtual Windows 7. The database is running fast and currently have about 2000 transactions. It started out being coded in C++, but the more OOP i learned, the more attractive C is for me. The search, sorting, showings pictures is almost in C.

    It's relational database for my wife's shop and I know it's working well or else my wife will let me know in a heartbeat.

    The picture shows test data with a picture related to the costumer.

    I had tried Raylib, but the font is a bit blurry and it is can only run in double buffering mode, as far as I know.

    graphics.h can use double buffer or not as you please.

    So if anyone knows of any easy graphics library, because my level is about medium, I think?

    Evan
    Attached Images Attached Images graphics.h alternative-capture2-jpg 

  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    1,664
    cairo is a possibility.
    What all are you doing with graphics.h?
    It looks like you are just displaying an image.
    You could do that with the Windows API if you don't care about portability.
    All truths are half-truths. - A.N. Whitehead

  3. #3
    Registered User
    Join Date
    Jan 2023
    Posts
    5
    Thanks - I will try to explain, despite my dyslexia: )

    Everything you can see is done with graphics.h

    For me it's also a learning process, so all the text handling like editing is done by functions I have written - even the drawing the cursor including insert/overwrite ec.

    The top windows is showing a customer - the first 6 lines. The rest of the lines in the top windows is showing a currently job, from a list just below. If there are more jobs, you can shift between the jobs.

    The right window is for searching and the results will be shown in the bottom window.

    The bottom window is the active window with a green title background. The content been shown in the bottom windows is a query for finished jobs. If the number of finished jobs, can't be in the the window, the jobs can be scrolled. The top red line in the bottom window is showing, what that job was about and related picture(s) if any. The red text indicate, what job the is looking at.

    I try to stay away from MS so much I can and I am using CodeBlocks IDE.


    I had a look at Cairo earlier and was not to keen of the use commands. As I understand you'll have to write cairo in front of all the commands:


    An example from the Cairo's help:

    cairo_move_to (cr, 10, 10);
    cairo_line_to (cr, 20, 10);
    cairo_set_line_width (cr, 1);
    cairo_stroke (cr);

    I would prefer:

    move_to (cr, 10, 10);
    line_to (cr, 20, 10);
    set_line_width (cr, 1);
    stroke (cr);


    Are you using Cairo and if you are I will appreciate any info.

  4. #4
    Registered User
    Join Date
    Feb 2019
    Posts
    1,077

  5. #5
    Registered User
    Join Date
    Jan 2023
    Posts
    5
    I have tried graphics.h, SFML, Raylibs and SDL.
    graphics.h is the easiest library and have a very fine monospace character set and even scandinavian letters built in.
    SFML is best suited to C++, because of it's OOP way of working.
    Raylib is easy to use and have released a new version I will try.
    I was not able to have SDL working and it seems that many are strugling with SDL.

  6. #6
    Registered User
    Join Date
    Apr 2021
    Posts
    148
    Quote Originally Posted by Hobby Coder View Post
    An example from the Cairo's help:

    cairo_move_to (cr, 10, 10);
    cairo_line_to (cr, 20, 10);
    cairo_set_line_width (cr, 1);
    cairo_stroke (cr);

    I would prefer:

    move_to (cr, 10, 10);
    line_to (cr, 20, 10);
    set_line_width (cr, 1);
    stroke (cr);
    First: I am NOT using cairo, nor any other windows thing. I know nothing about it directly.

    With that said, I'll argue that you are going to eventually come to love that cairo_ prefix, because it clearly identifies what subsystem/library the function comes from. As you write more and more code, and incorporate more and more libraries/modules from other people & places, you will find that you start to forget just exactly where did this particular function come from? What header file provides the prototype? What are the dependencies of using this?

    As that happens, simple conventions like putting a prefix on things will help you, a lot! Almost every "public" C library will have something like this.

    Now, just because they have that prefix doesn't mean you have to use them. One of the most powerful features of C is the macro preprocessor, and this is a perfect use case for it. Just code something like:

    Code:
    #pragma once
    // cairo-shortnames.h -- wrap short names around cairo functions
    #include "cairo.h"
    
    #define  move_to(cr, x, y)     cairo_move_to ((cr), (x), (y))
    #define line_to(cr, x, y)        cairo_line_to ((cr), (x), (y))
    #define set_line_width(cr, w)     cairo_set_line_width ((cr), (w))
    #define stroke(cr)                  cairo_stroke((cr))

    With that done, you can just #include "cairo-shortnames.h" and be happy.

  7. #7
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    958
    Quote Originally Posted by aghast View Post
    With that said, I'll argue that you are going to eventually come to love that cairo_ prefix, because it clearly identifies what subsystem/library the function comes from.
    Not only that, but it avoids name collisions. Imagine there were a function called "move_to" in some other library (perhaps in some game engine library or text editor or something). If Cairo didn't use the cairo_ prefix on its function names, you would have more than one function with the same name, which is not allowed and should cause an error during either compile time or link time.

    You can think of prefixes as C's version of "namespaces".

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alternative to goto?
    By .:Lyle:. in forum C Programming
    Replies: 21
    Last Post: 08-29-2012, 10:39 AM
  2. alternative content
    By MisterSako in forum Tech Board
    Replies: 2
    Last Post: 04-10-2006, 06:40 AM
  3. Any alternative?
    By sCandal2 in forum Windows Programming
    Replies: 4
    Last Post: 01-11-2006, 04:30 PM
  4. gets() alternative
    By Mastadex in forum C Programming
    Replies: 5
    Last Post: 12-12-2004, 12:28 AM
  5. alternative to cin
    By Unregistered in forum C++ Programming
    Replies: 18
    Last Post: 06-25-2002, 05:14 PM

Tags for this Thread