I believe that you will be required to use the pdcurses-wingui.dll and copy it to pdcurses.dll
Chuck Haatvedt
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
6 days ago
There are prerequisites to calling putpixel
Initialization: You must initialize the graphics system using initgraph(&gd, &gm, ""); before calling putpixel.
Where: gd = Graphics Driver ->
A pointer to an integer specifying the driver.
Using the macro DETECT (set to 0) allows the system to automatically pick the best driver for your hardware.
gm = Graphics Mode -> resolution
"" (Path to Driver):
Windows:
EasyX
SDL_BGI
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, of course, looking at https://www.geeksforgeeks.org/c/putpixel-function-c/
I can see that there are some calls that need to be made before using the function.
But the problem is something else.
These calls, however, seem to look for a library that I don't know what it is and where to find.
Replacing pdcurses-wingui.dll and copying it to pdcurses.dll is also impossible because I'm using the AIO compiler available in SuperBOL and VSCode.
This compiler doesn't use pdcurses, but libncursesw.dll.a and libncursesw6.dll.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But unfortunately this is just für MinGW-32 and so it does not work with the SuperBOL-distribution which is shipped with MinGW-64.
It should work with the distribution of Arnold because this is based on MinGW-32 but this comes without g++ (C++ compiler). But g++ ist needed because in the graphics.h the file sstream.h is referenced and this is related to C++.
A 64-bit version is available here: https://github.com/ahmedshakill/WinBGIm-64
But it has to be compiled by one self and there is no ready to use binary version - so far I see.
PS: Maybe there are binary 64-bit versions of this lib in the internet. But these files should always watched twice because of security issues. A good practise is to check them on virustotal.com ...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sincere thanks for this answer, which I think is exhaustive, even if it doesn't meet my goals.
Thank you.
At this point, I'd say I have to abandon this approach.
I remember that the older BASIC had some simple statements to draw, for example, a circle, a square or a line etc. in a graphical way.
If anyone has an alternative idea, I'd be very grateful.
The goal is to draw a pixel on the screen using GnuCOBOL and, for example, a CALL to a function in a C library.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The binary libbgi64.a looks ok while checked with virustotal (please recheck if you want to use it). We need to extract the graphics.h from the file "Source code (zip)" and put it into include folder of the SuperBOL-installation ... and we need to put ibbgi64.a into the libs folder...
Tomorrow (or within the next days) I will try to compile the example from https://www.geeksforgeeks.org/c/putpixel-function-c/ If this works we can go a step further with calling functions from GnuCOBOL. I think because GnuCOBOL uses gcc internally we need to write a wrapper in C which calls the g++ code from winbgim.
Seems to be a longer way with some challenges ahead :-)
Or SDL2/SDL3 directly. But we probably need wrapper routines to call it in a comfortable way from GnuCOBOL. The benefit would that this could work in Windows and Linux both.
But maybe there are some other good solutions, ideas and howtos out there in the community right now :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
PDCursesMOD does provide a Windows graphic version called WINGUI. With this you should be able to access individual pixels using the setpixel function. There are some serious considerations
How to Access Pixels in WinGUI
To draw or manipulate individual pixels, you must bypass the curses abstraction and use the underlying Windows API:
GettheDeviceContext(HDC):Youneedahandletothewindow's device context to perform graphical operations. In the WinGUI port, you can often obtain the relevant HWND (window handle) or HDC.Use SetPixel(): The standard Win32 API function SetPixel(hdc, x, y, color) allows you to change the color of a specific pixel at coordinates.Coordinate Systems: Remember that curses uses character-based coordinates (rows/cols), while GDI uses absolute pixel coordinates. You may need to calculate the pixel position based on the current font width and height.
Key Considerations
Redrawing:Cursesmanagesitsowninternalbuffer.IfyoudrawpixelsdirectlytothewindowusingGDI,theymaybeoverwrittenorerasedthenexttimecursescallsrefresh()orwrefresh(),asitredrawsthetextgridoverthewindow.
Portability:Usingpixel-levelGDIcallsbreakstheportabilityofyourcode.YourapplicationwillonlyworkwiththeWinGUIportofPDCursesModandwon't function on standard terminal-based curses or other ports like X11 without significant changes.Performance: Drawing pixel-by-pixel with SetPixel() is generally slow. For complex graphics, it is better to draw to an off-screen bitmap and then copy that bitmap to the screen in one operation using BitBlt().
In my opinion, if you want to do graphic's then you should consider not using curses as it is a text user interface.
could pixels be accessed using ncursesw ?
No,
ncursesw (the wide-character version of ncurses) cannot access individual hardware pixels. Unlike the WinGUI port of PDCursesMod, which can interact with the Windows GDI, ncursesw is designed strictly for character-cell terminals where the smallest addressable unit is a single character cell.
Chuck Haatvedt
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
However, the main problem, as mentioned above, is that these libraries (not just Raylib, but the others as well) do not work together with PDCurses or other curses libraries.
Regards,
László
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'd like to use the putpixel() C function from a GnuCOBOL program.
To draw geometric shapes on the screen: a circle, a rosette, etc. See:
https://www.geeksforgeeks.org/c/putpixel-function-c/
Possibly without using a C wrapper but using something like this in the GnuCOBOL program:
Compiling this program gives "undefined reference to `putpixel' "
Can someone explain to me in detail if it is possible and how / what I should do ?
As far as I see:
BINARY-LONG--include graphics.hI believe that you will be required to use the pdcurses-wingui.dll and copy it to pdcurses.dll
There are prerequisites to calling putpixel
Initialization: You must initialize the graphics system using initgraph(&gd, &gm, ""); before calling putpixel.
Where:
gd = Graphics Driver ->
A pointer to an integer specifying the driver.
Using the macro DETECT (set to 0) allows the system to automatically pick the best driver for your hardware.
gm = Graphics Mode -> resolution
"" (Path to Driver):
Windows:
EasyX
SDL_BGI
Yes, of course, looking at
https://www.geeksforgeeks.org/c/putpixel-function-c/
I can see that there are some calls that need to be made before using the function.
But the problem is something else.
These calls, however, seem to look for a library that I don't know what it is and where to find.
Replacing pdcurses-wingui.dll and copying it to pdcurses.dll is also impossible because I'm using the AIO compiler available in SuperBOL and VSCode.
This compiler doesn't use pdcurses, but libncursesw.dll.a and libncursesw6.dll.
Some hints I found to this topic:
putpixel() is part of the Borland BGI Graphics emulation (based on https://en.wikipedia.org/wiki/Borland_Graphics_Interface ):
https://winbgim.codecutter.org/
But unfortunately this is just für MinGW-32 and so it does not work with the SuperBOL-distribution which is shipped with MinGW-64.
It should work with the distribution of Arnold because this is based on MinGW-32 but this comes without g++ (C++ compiler). But g++ ist needed because in the graphics.h the file sstream.h is referenced and this is related to C++.
A 64-bit version is available here:
https://github.com/ahmedshakill/WinBGIm-64
But it has to be compiled by one self and there is no ready to use binary version - so far I see.
PS: Maybe there are binary 64-bit versions of this lib in the internet. But these files should always watched twice because of security issues. A good practise is to check them on virustotal.com ...
Sincere thanks for this answer, which I think is exhaustive, even if it doesn't meet my goals.
Thank you.
At this point, I'd say I have to abandon this approach.
I remember that the older BASIC had some simple statements to draw, for example, a circle, a square or a line etc. in a graphical way.
If anyone has an alternative idea, I'd be very grateful.
The goal is to draw a pixel on the screen using GnuCOBOL and, for example, a CALL to a function in a C library.
Thank you very much.
I searched now for a 64-bit version and found this one for MinGW:
https://github.com/dbautsch/winbgim/releases/tag/6.0a
The binary libbgi64.a looks ok while checked with virustotal (please recheck if you want to use it). We need to extract the graphics.h from the file "Source code (zip)" and put it into include folder of the SuperBOL-installation ... and we need to put ibbgi64.a into the libs folder...
Tomorrow (or within the next days) I will try to compile the example from https://www.geeksforgeeks.org/c/putpixel-function-c/ If this works we can go a step further with calling functions from GnuCOBOL. I think because GnuCOBOL uses gcc internally we need to write a wrapper in C which calls the g++ code from winbgim.
Seems to be a longer way with some challenges ahead :-)
Another approach we could give a view is:
https://sourceforge.net/projects/sdl-bgi/ which is already mentioned by Anonymous above.
Or SDL2/SDL3 directly. But we probably need wrapper routines to call it in a comfortable way from GnuCOBOL. The benefit would that this could work in Windows and Linux both.
But maybe there are some other good solutions, ideas and howtos out there in the community right now :-)
Ok, I think we are on the good way with winbgm/putpixel() on SuperBOL-AIO-distribution :-)
1) Library (always check it with virustotal.com) and graphics.h from:
https://github.com/dbautsch/winbgim/releases/tag/6.0a
2) Rename libbgi64.a to libbgi.a and put it into:
C:\Users\YOURUSER\AppData\Local\GnuCOBOL\mingw64\lib\gcc\x86_64-w64-mingw32\13.2.0
3) Put graphics.h (from the Source Code ZIP file) into:
C:\Users\YOURUSER\AppData\Local\GnuCOBOL\mingw64\lib\gcc\x86_64-w64-mingw32\13.2.0\include
4) Compile wrapper.cpp and circle.cob from Windows Terminal (CMD):
5) Call the demo:
circle.exe
wrapper.cpp:
circle.cob (from the BASIC example above):
PS: Colors and other constants are from graphics.h:
Last edit: Michael Del Solio 2 days ago
Now, we have some more functions available:
gfxdemo.bat:
New gfxwrapper.cpp attached ...
PDCursesMOD does provide a Windows graphic version called WINGUI. With this you should be able to access individual pixels using the setpixel function. There are some serious considerations
How to Access Pixels in WinGUI
To draw or manipulate individual pixels, you must bypass the curses abstraction and use the underlying Windows API:
Key Considerations
In my opinion, if you want to do graphic's then you should consider not using curses as it is a text user interface.
could pixels be accessed using ncursesw ?
No,
ncursesw (the wide-character version of ncurses) cannot access individual hardware pixels. Unlike the WinGUI port of PDCursesMod, which can interact with the Windows GDI, ncursesw is designed strictly for character-cell terminals where the smallest addressable unit is a single character cell.
Chuck Haatvedt
Hello,
The Raylib C library is also based on BGI.
https://en.wikipedia.org/wiki/Raylib
https://github.com/raysan5/raylib
There are Raylib bindings and wrappers for many programming languages:
https://github.com/raysan5/raylib/blob/master/BINDINGS.md
Also for COBOL:
https://codeberg.org/glowiak/raylib-cobol
Our GNU Cobol Contributions also include an example using Raylib (author: Giancarlo Canini):
https://sourceforge.net/p/gnucobol/contrib/HEAD/tree/trunk/samples/raylib_painter
However, the main problem, as mentioned above, is that these libraries (not just Raylib, but the others as well) do not work together with PDCurses or other curses libraries.
Regards,
László