Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Is SFML good for making console graphics files editor (for Windows 7/c++)?  (Read 3337 times)

0 Members and 2 Guests are viewing this topic.

indubhushan

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Hello, my name is Ivan, I'm studying c++ now in computer academy Step (Kiev, Ukraine). We study patterns, and have a task to make a pictures editor. It is a part of course "patterns editor" (make template for AnyDocumentType editor), and task is to be done in several days.
So, main features I'm worried about is that we never done anything like "Drawing pixels" unto the Windows7Console. I was doing previous exam for C++OOP, and it was "sea battle-ships game", so I used some libraries for graphics and mouse, and it worked in Win7, but when teacher run that on Win10, it didn't work ... neither compiled, nor didn't run in Visual studio... so, anyway, I've got good mark, but this time I have this interesting task, and have no idea how to make this all done properly, so that it can run in Win10 also (and probably, in some future versions - out of my academy course - to make this cross-platform, thus only making for Windows is not best idea imho).
So, teacher adviced to use SFML. He just showed how some student(s) made some simple game in SFML, but he was unable to compile that, as some libraries should have been attached, and he didn't have that. so it is up to us, up to me to use any graphics library I want.
The first which came to my mind is to use pseudo-graphics input method, which I used for sea-war exam game. So I simply pressed on keyboard cursor up-down-left-right to set new coordinate, and press space/delete to set new ship or kill enemy ship-deck, or switch to mouse mode - and that's faster - to set coordinates on two fields using mouse (one middle button to change ship orientation, and secondary mouse button to go back to keyboard input mode) ... the main problem is that I can't draw pixel in this way. I can draw some ASCII blocks, colored in some (not many) colors (I think there are just 16 colors in this mode). And it is somewhat sad, in days of millions of colors in graphics cards. Sure, we will study in future Windows Graphical interface (and not "text"/pseudo graphics console anymore), so it's kind of I don't have much time to find out what to do and how.
Just for your information: when I had on first semester an exam to make "library", and it could have had also a graphics mode, - I didn't have enough time to do that. I tried to make use of mouse, and only managed to make it move up-down, highlighting current element in list of items, but it didn't work as expected, so it remained "experimental" (to-be-done in future feature). of course this experience helped to make similar program, I mean game later - when I chose to make sea-war game. So, what I expect can be later, in some future course, that we may have more advanced tasks, and knowing something like SFML may be a good experience. Even if I don't accomplish it well now (then I'll have to use my pseudo graphics mode, and saving to own invented graphics format - just array of color-blocks with their coordinates x/y and colors, just 16 colors available, sad).
The trick is that in task I have to make available a "pallete of tools" to process picture in different ways. I'm thinking just to make at least pallete of colors. At least, if I don't have a way to draw pixels, lines, but just pseudo graphics, then what can I do? maybe set ASCII character to be drawn, and set its forecolor, and back color, that's it. I want more than that. I have some experience in C#\Unity3d, so I know how to make simple 3d games, using animations for characters etc. But never had experience with c++. Actually only half year ago on courses I started to study c++ for the first time ever. So, for me, some gradual way to study "world of c++" graphics, is a best approach. I want to make it smooth, so that I don't want to give up...
I was thinking, I can search on internet for different ways to draw lines/pixels in MS Windows7 console. But what I suspect can happen - like happened recently - it may work on WIndows7, but will not work on teacher’s laptop with Win10 etc. etc. So I want to learn from good source. I thought, I don't know any other good library which may sit me well, with support like SFML. Unreal Engine is good, but is not what we are studying now (maybe in some more or less far future). I need basic 2d graphics editor. Ideally - to draw pixels, lines, some common shapes. If I can draw precisely like in Windows - with precision up to one pixel - it would be best. I don't know if that is possible to get this precision (for mouse, and probably not for keyboard almost sure) in Windows console mode... Also, ideally I'ld need some common, simple image-file format. Maybe something like .bmp or like that, uncompressed, which writes lots of bytes. Of course, task asks to read/write many graphics files formats, but it is not necessary for now. It's just a pattern which we have to make. But I'm sure we will use this later. Like previously we had task to draw button, window, just abstract, without even showing it. Just set position, title/text, boarder style (on/off/color etc), size of window (x/y) etc. And soon when I had this task to make "sea-ships war", I was happy to have these classes abstractions already done, and thus I had enough time to make exam in time.
Task asks to make it possible even to print the picture on printer. Hm, is that possible in SFML? Opening/saving picture files: is that possible to make easy, with just attaching some libraries? Does SFML require something to be installed on PC to run source code with SFML functions within Visual Studio/c++? I mean, if I'll install it on my PC, make libraries work, will that be enough to copy whole project (source) to teacher's computer so he will be able to open it and compile and run without problem? because I'm 100% he will not be interested in installing any software just to make this run (ok, may see on my pc only, but I want more cross-platform or at least, to be run on any nowadays-common Windows version...).

Is SFML a good choice for what I ask? Will C version of SFML libraries work equally well with c++? (I use free visual studio 2019).

Actually, I’d be happy to try make simply games using SFML. Even if not for exam, but generally. I was making some hobby games in Unity3d/C# for past maybe 5 years or so (from time to time), and was quite happy, and it came out C# is not that hard (I used just Visual basic before, can't believe ;) )... I thought C++ is such a hard language, but now I see it is more or less like C#, good language, I may not say it is that hard as I though it is ... ;-) Just make it even more enjoyable (I'm on 1st/2nd place in my group in academy ;-) ), I want to make games... Can I make a sprite editor in SFML? I liked how I used Microsoft Agent (Visual basic/c#), it had just 256 colors maximum, but had many animations for different states. Can I have at least 256 colors with SFML in Windows console? What are perspectives to use SFML cross-platform-way (I think about Android first of all)? Does it use some common libraries (is that OpenGL?) for cross-platform compilation? Say, can I set console to OpenGL mode, and write code cross-platform from now on? So that I can have such cool picture editor/viewer even on my Android phone (as apk)? is that possible (but mouse clicks are to be generated from touching screen)? I've got touchscreen on laptop, it is fun (also for drawing, I use special stylus, for more precision) - in programs like Corel Painter / Adobe Illustrator. I understand, that making own vector/raster graphics editor is not something which can be done in one week ;-) but at least something very basic for drawing pixels, setting their coordinates/colors, saving them to file/restoring is ok. How to set graphics mode? Say, if I will like to set graphics modes for Windows/Android, how that would be different? can i compile directly from Visual Studio to Android apk when I have SFML?

I just need a direction to go. Maybe there are good examples to download, which are out-of-box with methods of setting graphics mode in Win-console, loading graphics files (better if not my own), editing something, saving etc. etc.

And yes, I’d like in future to know how to use audio & network within SFML (tried in Unity3d and it was fun) ;-)

Any help on written is welcome.

P.S. I attach my "sea-war" game, so that you can see how I made it. It's only 16 colors maximum, mouse support is there, but I'm not so happy
due to limits of graphics in the game.
So looking towards SFML ;-)


P.S.2. Can you suggest some good tutorial/example project (maybe complete game\program) to start with?
« Last Edit: March 13, 2020, 06:51:09 am by indubhushan »

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
SFML does not have ASCII version, i made a win32 console library that has similar code structure and design as SFML while ago.
here the link: https://github.com/MORTAL2000/MSLIB

indubhushan

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
hi, Mortal. I tried your project, but it doesn't compile. 38 errors. do I need to include something additionally?
and what specifically this project is for? can I change picture of any character to own image (like in font, can I change every character (letter/number/puctuation/pseudographics char etc) to custom image)? I really don't understand, sorry

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
true, it failed with VS2019. it complains about missing “std::string” file in “Cosole.h” file, i added it it runs on my PC [windows 10 / VS-2019].

i updated the main repo at github, check it out.

Yes you change the image or upload the txt file to “Image::loadFromFile()”. This project was made when i was learning the drawing of Ascii arts from this site: https://www.randygaul.net/2012/07/03/windows-console-game-asciiengine/

indubhushan

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Hi, Mortal ;-) Thank you, I'm quite happy now, because in your example I've found how to get exact coordinates of mouse cursor even in console ;-) I attach a file so you can see the result.

When I''ll have more time, I'll take a look of more advanced features of SFML. Thank you, it was really helpful. If not you, I could have probably spent a lot of time looking for ways to get exact coordinates of mouse in console, and probably with a little chance to get an answer like this...

P.S. Millions of thanks and blessings ;-)

by the way, do you know what is CLR for C++? It seems to have additional libraries of .NET (?), which are not in C++, but they are easy, - graphics objects etc. But I was unable to make them work with very same source (if I make a project to support CLR). have no idea why.

Also, I want to know is the "console window" and any other window in Windows basically same or not from point of view of graphics - how it is rendered? I mean, maybe all these graphical modes are just nothing but same text-consoles, but with text-cursor hidden, and all (most) control is transferred to mouse-input...?




Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
I'm glad it helped what you were looking for.

by the way, do you know what is CLR for C++? It seems to have additional libraries of .NET (?), which are not in C++, but they are easy, - graphics objects etc. But I was unable to make them work with very same source (if I make a project to support CLR). have no idea why.
No i didn't work with CLP


Also, I want to know is the "console window" and any other window in Windows basically same or not from point of view of graphics - how it is rendered? I mean, maybe all these graphical modes are just nothing but same text-consoles, but with text-cursor hidden, and all (most) control is transferred to mouse-input...?
In general, the console screen “black box” window is not made for graphics, true it’s tiled grid, it can do some basic drawing shapes like square or rectangle,  but it can’t draw complex shapes like circle or capsule or even a polygon.

It’s better to use a windows base app to draw those shapes, in a window environment there are many graphics libraries, like Win32 GDI, Win32 GDI+ and many more. Or even more better, you may choose a multi-platformer graphic library like SFML of-course. This will allow your application to run in every platform window, mac, linux..etc
« Last Edit: March 14, 2020, 06:48:28 am by Mortal »

indubhushan

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Hi, thanks for fast reply ;-) Actually I was asking about CLR simply because I had experience with it since I used Visual Basic .NET. But anyway, of course, if I'll go further earlier to history, I remember times when I used Visual Basic for DOS (in end of 90-es) (just learning programming at school), and it was fun ;-) ... I am thinking if that is possible to have some control elements for SFML-crossplatfrom out of box? What I mean is that, say, look at

https://www.zdnet.com/article/microsoft-we-wont-evolve-visual-basic-programming-language-but-well-open-it-to-net-5/
I remember how easy it was to make Visual controls in VB, and I wonder why many graphics libraries or even game engines like Unity3d lack basic features like "control-elements". I remember how I tried to make SharpNLP (C# library to make part-of-speech tagging for any English text) work with Unity3d, and was unhappy when found out that no "TreeView" available out-of-box. I had to buy additional component "TreeView" (4$), and still it was too simple for my task of putting big text-tree (with POS-tags) into Unity3d.

Actually I want to make some cross-platform stuff to make "text-to-gamelevels" (generator of game-levels based on "parts-of-speech"-tagged text, like in SharpNLP or BookNLP) or "text-to-cartoon" ("text-to-comics") generator, and it becomes not that easy... Anyway.

I was asking several times out teachers is it possible to make cross-platform in C++, so usually they didn't respond anything which satisfied me enough. If C++ is so cool, why I have to go with Java on Android etc?

If I'll go cross-platform ever, second platform after Windows will be Android. I have phone Lenovo A6000, it has Android 5.0.2 (1 GB ram). I can successfully compile to Android using Unity3d, but it is not so good to make simple "text-editor" etc. I even was looking for simple programs to make "e-book" (of aphorisms) on Android, and found Android Book maker -
but that's not what satisfies me completely.

So all these troubles with cross-platform, and lack of good tools for Android made me sad one day, that when I was making Unity3d game for Android, I finally decided to make board-game instead (and making it now).

Is it possible to use SFML as graphics interface for any common tasks on Android like making text editor, file manager, some control-elements like those in visual-studio (compare with Visual basic DOS for simplicity, sure in that way it is quite easy, just make 'drag and drop') etc?

Actually, I tried to draw pixel-by-pixel a line in my this program which I attached in previous message - I wonder why it is so slow?
Is SFML really fast enough? I mean, it seems to be not SFML yet, the link to program which you advised, right?

Can you guide me to install what I need to install SFML for Win/Android cross-platform-development?
Can I code in C++ for SFML in Android? I ask, because it seems that Android is using natively Java, so using C++ maybe means converting from C++ to Java (it is similar to conversion among "just C++" and ".NET" Common Language Runtime / CLR).

I'ld be more happy to use some combination of technologies which will not force me to give up someday what I study. If study some programming language / technology (be that C++/SFML etc)- it should have perspectives for future decades of years (and growing in popularity and demand from end-user/consumers of such e-products)...

Actually yesterday I've also was reading some history of SFML, and found out that it made to kind of replace SDL / Simple DirectMedia Layer. But I've read about it - and that seems to be made by so famous and cool people like Sam Lantinga, from Blizzard/Valve etc... My favorite in list of games on which he worked is Heroes of Might and Magic 3 ;-) But I remember how I also enjoyed their Heretic / Railroad Tycoon ;-)
I wonder what is wrong with SDL?

 

anything