dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Thread: C or C++ equivalent to Java 2D graphics functionality

  1. #1
    Join Date
    May 2019
    Posts
    2

    C or C++ equivalent to Java 2D graphics functionality

    Hello everyone,,
    Inside the standard java packages there is a large library of graphics drawing functions encapsulated in java.awt.Graphics and the newer java.awt.Graphics2D.

    Along with these, there is the java.awt.image.BufferedImage class which can provide the Graphics2D object to be able to use all of those primitives and can be used to load and save images of different formats using the javax.imageio.ImageIO utility class.

    I've reviewed SDL and SFML and they provide some good 2D capability, but nothing as extensive as the Java 2D graphics objects. When you combine other support classes like the java.awt.Shape based classes, you can do some really great 2D graphics.

    What C or C++ library would be the closest in functionality to what is provided in that Java 2D graphics classes????

  2. #2
    Join Date
    Feb 2017
    Posts
    432

    Re: C or C++ equivalent to Java 2D graphics functionality

    Quote Originally Posted by Lincon1 View Post
    What C or C++ library would be the closest in functionality to what is provided in that Java 2D graphics classes????
    C++ itself doesn't supply a 2D graphics library although some think there should be one,

    http://open-std.org/JTC1/SC22/WG21/d...17/p0669r0.pdf

    Instead C++ programmers must look elsewhere and there are many different places where 2D support shows up. Here are a few examples,

    1. All major operating systems offer 2D graphics subsystems at different levels of sophistication, See for example Windows,

    https://docs.microsoft.com/en-us/win...-windows-vista

    2. There are dedicated libraries such as SFML and SDL,

    https://www.sfml-dev.org/
    http://www.libsdl.org/

    3. All packages that help build graphical user interfaces (GUIs) have support for 2D. One example of many is wxWidgets,

    https://www.wxwidgets.org/

    4. Standardized low-level graphics APIs such as OpenGL, DirectX and Vulkan can be used directly, for example,

    https://www.khronos.org/vulkan/

    5. and so on ...

    Which is best very much depends on what kind of program you're planning to write.
    Last edited by wolle; May 8th, 2019 at 03:07 AM.

  3. #3
    Join Date
    May 2019
    Posts
    2

    Re: C or C++ equivalent to Java 2D graphics functionality

    Quote Originally Posted by Lincon1 View Post
    Hello everyone,,
    Inside the standard java packages there is a large library of graphics drawing functions encapsulated in java.awt.Graphics and the newer java.awt.Graphics2D.

    Along with these, there is the java.awt.image.BufferedImage class which can provide the Graphics2D object to be able to use all of those primitives and can be used to load and youporn.wiki/ xhamster.vip/ redtube.onl/ save images of different formats using the javax.imageio.ImageIO utility class.

    I've reviewed SDL and SFML and they provide some good 2D capability, but nothing as extensive as the Java 2D graphics objects. When you combine other support classes like the java.awt.Shape based classes, you can do some really great 2D graphics.

    What C or C++ library would be the closest in functionality to what is provided in that Java 2D graphics classes????
    ____________________________________________________________________________________________________________________________
    Thank you my issue has been solved,...

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,689

    Re: C or C++ equivalent to Java 2D graphics functionality

    ... so what did you eventually choose?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.1.3)

  5. #5
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,207

    Re: C or C++ equivalent to Java 2D graphics functionality

    If the target OS is Windows, the best choice is Direct2D libray.
    You can directly use Direct2D COM interfaces or, much easier, the MFC Support for Direct2D.

    See
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: http://codexpert.ro/blog/author/ovidiu-cucu/

  6. #6
    Join Date
    May 2019
    Posts
    1

    Re: C or C++ equivalent to Java 2D graphics functionality

    I got valuable information here...Thanks for such an excellent piece of information....Keep Up!

  7. #7
    Join Date
    Feb 2017
    Posts
    432

    Re: C or C++ equivalent to Java 2D graphics functionality

    Quote Originally Posted by ovidiucucu View Post
    If the target OS is Windows, the best choice is Direct2D libray.
    Just because the target is Windows doen't necessarily mean the best choise is to use Direct2D. It may still be better to use a portable 2D package. Chances are this package will use Direct2D anyway when running on Windows. I wouldn't be at all surprised if even java.awt.Graphics2D uses Direct2D under the hood on Windows.

    Particularly when someone comes from Java I suggest having a serious look at Qt. It's a complete applications framework, not just a GUI toolkit. It supplies a sandboxed environment just like Java, maybe not quite as extensive but it definately has a solid 2D package,

    https://www.qt.io/

    There is a free open source version (even though the company obviously prefers you buy the commersial version).

    https://www.qt.io/download

    I think Qt is well worth considering even if your C++ application will always run on Windows. It's the same as with Java. It's portable too but that doesn't mean you cannot use it to write applications for Windows only. Whether Qt is a good choise ulitimately depends on what kind of application you're writing and in what setting.
    Last edited by wolle; May 17th, 2019 at 12:07 AM.

  8. #8
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,207

    Re: C or C++ equivalent to Java 2D graphics functionality

    Quote Originally Posted by wolle View Post
    Just because the target is Windows doen't necessarily mean the best choise is to use Direct2D. It may still be better to use a portable 2D package. Chances are this package will use Direct2D anyway when running on Windows. I wouldn't be at all surprised if even java.awt.Graphics2D uses Direct2D under the hood on Windows.
    [...]
    I know many projects developed for years using cross-platform libraries, but never targeted other OS than Windows.
    IMO, the most optimal approach is to write as much as possible cross-platform code (e.g. using standard C++) but for system specific stuff (like GUI) use native libraries for each target system. I know, Qt does this itself but introduces additional layers which can lead in performance penalties.
    Anyway, if someone may choose, is free to choose what he/she wants. I’ve no intention to start another one “religious war”.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: http://codexpert.ro/blog/author/ovidiu-cucu/

  9. #9
    Join Date
    Feb 2017
    Posts
    432

    Re: C or C++ equivalent to Java 2D graphics functionality

    Quote Originally Posted by ovidiucucu View Post
    I’ve no intention to start another one “religious war”.
    Neither do I . I've been in too many of those during my Java days.

    I just wanted to balance your imperative statement that "If the target OS is Windows, the best choice is Direct2D libray". It may be a good idea but it's not a given thing. It depends on the nature of the application and the setting.

    But I hear you. In fact the reason I abandoned Java for C++ was that they never got the GUI right. Java would run anywhere but it lacked the native look & feel I desired. Java may have improved since then but there's no turning back for me despite all difficult choices you have to make as C++ developer. After all, an attractive program is more important than easy programming.
    Last edited by wolle; May 19th, 2019 at 02:39 AM.

  10. #10
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,148

    Re: C or C++ equivalent to Java 2D graphics functionality

    Another nice and powerful library is AGG ( http://antigrain.com/ ), unfortunately, not actively maintained anymore, but what's there works nicely.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)