SVGA Programming in Turbo C [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I want to do 1024*768 programming in Turbo C++
I am using Turbo C 3.0 where i am using the old VGA method to invoke graphics
initgraph( &GraphDriver, &GraphMode, "..\\bgi" );
I want a library which can easily handle the SVGA mode and true colors.

There are several chip manufacturers for SVGA cards, and programming them may require specific code for each of them (unless your graphic board supports VESA, see below). I did that ages ago (in the 90s'), and I used the sources of POVRAY (a raytracer) as a reference.
Fortunately, POVRAY still exists today: http://www.povray.org/
You need to grab here http://www.povray.org/ftp/pub/povray/Old-Versions/ the sources of an old 1990's version that still has the routines for SVGA (the authors probably removed them in the recent versions !). You will find in the sources a bunch of inline assembly functions to initialize graphic mode and set a pixel for various graphic boards/manufacturers (S3, ET4000, ...). First unzip POVSRC.ZIP, then MACHINE.ZIP, then IBMPC.ZIP (and it is in IBM.C).
The code is a bit esoteric: this is because initially the IBM PC was meant to have no more than 64Kb of video ram (at segment A000:0000). To allow having higher resolution, there is a technique that is called "bank switching", that allows changing a "window" in video RAM that is mapped to A000:0000.
If your SVGA board supports the VESA standard (which is the case for most of them), then things might be easier, there is a standard interrupt for changing the graphic mode and for doing the bank switching (so you probably just need to find in POVRAY the VESA implementation of "set graphic mode" and "set pixel").
Finally, I mention djgpp (g++ port to MSDOS) that has both a 32 bit DOS extender and a graphic library (grx) that uses the virtual memory in a nifty way to simulate a contiguous graphic memory (it creates virtual addresses for the video RAM and uses page faults interrupts to trigger bank switching automatically). I used it to do 3D graphic programming on a 33Mhz 486.
Edit:
After digging a bit, I found that the latest version that has the routines is the one here:
http://www.povray.org/ftp/pub/povray/Old-Versions/Official-3.1g/MS-Dos/
unzip povmsd_s.zip
The routines are in SOURCE/MSDOS/VESAVBE.{H,C} (usable if your cards supports the VESA norm). Other cards have their routines in SOURCE/MSDOS/MSDOSVID.C

Related

non-Apple C compiler for mac [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
Looking for small C/C++ compiler available for OS X Catalina
without the need of installing both xcode and command line tools.
CLT itself takes over a Gig, xcode even more.
Preferably around or below 100Mb if possible.
Please kindly advice.
P.S. writing scripts for fluid dynamics, not even in need for OOP,
just wonder why compilers nowadays weight over USB-sticks capacities from 2000s :(
P.P.S Also considering installing server linux distributive just for C sake.
Happy to listen to different opinions.
Preferably around or below 100Mb if possible.
Why does 1 or 5 GBs bother you? For complex math calculations you need a very strong computer. Storage is cheap (1TB SSD for ~$120). I rather think that you will need to invest in the decent NVIDIA GPU and calculate there. We have (small business running waves simulations) $100k server with plenty Teslas and it is not fast enough :).
Forget the program sizes - it is the least important, no one cares about it.
You need a modern computer, a lots of RAM and plenty fast storage. Start from it. Compiler size does not matter
Looking for small C/C++ compiler available for OS X Catalina
C and C++ are different languages. Read and compare both n1570 (the C11 standard) and n3337 (the C++11 standard).
P.S. writing scripts for fluid dynamics, not even in need for OOP, just wonder why compilers nowadays weight over USB-sticks capacities from 2000s :(
Because recent C or C++ compilers are capable of very tricky optimizations, which programs on fluid dynamics practically need (be aware of OpenACC and of OpenMP and of OpenCL; your probably need one of them). See this draft report explaining more them.
If you need an unoptimizing C compiler, consider using tinycc or nwcc (and port them perhaps to MacOSX). Both are capable of compiling C code on MacOSX or Linux. Both are open source and coded in C.
You could use vim or GNU emacs as your source code editor. Or whatever Apple is giving on your Macbook. Choose also a good build automation tool (e.g. GNU make or ninja) to drive your C or C++ compiler and of course compile on the command line ...
But you probably could take advantage in your field of the many optimizations that either recent GCC (i.e. g++ for C++, gcc for C) or recent Clang (i.e. clang++ for C++, clang for C) are capable of. And both compilers have dozen of millions of source code lines.
If you want a scripting language to drive fluid dynamics libraries, consider using an existing one: Lua, Python, Guile, Ocaml ... comes to mind and can embed other huge libraries.
See also LinuxFromScratch
If you have lots of time to spend (and a few gigabytes of disk space) consider the following route: download some old C compiler; use it to compile nwcc from source code. Download the source code of GCC 4.5 (it is coded in C). Compile it. You have now a C++ compiler g++-4.5. Download the source code of GCC 9. Compile it with g++-4.5. You have now an optimizing C++11 compiler g++-9. That could take a week of your time.
Also considering installing server linux distribution just for C sake.
That choice is large, and matter of opinion. I would recommend a recent Debian or Ubuntu.

whats easier to program in for newbies - directx 12 or vulkan [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I'm new to computer graphics and game development, and wanted to know whats easier to learn - Directx 12 or Vulkan?
By easier I'm referring to function names, class names, naming conventions, how to setup/initiate a vulkan project vs directx 12 etc etc.
Neither is an appropriate API for a newbie. Both APIs expose the application programmer to the intimate details of the GPU, making you fully responsible for synchronization in a 'lock-free' style, memory management including all edge-cases such as low-resource scenarios, fully described state, etc. These APIs are intended for expert graphics programmers who essentially want to talk directly to the video driver with some level of vendor-neutral abstraction.
Graphics programming is already a challenging discipline particularly when it comes to debugging. You can mess up a single number in a thousand lines of code and end up with a blank screen and have to work out what went wrong. It's particularly challenging to debug in context with GPU shader programming once you move beyond trivial shaders. With Direct3D 12/Vulkan, you can multiply the challenges even further with driver crashes that stop your application, timing-based synchronization issues that change based on even tiny differences in variables, or worse it works perfectly fine unless you use a different screen resolution or completely fails on a different PC.
Direct3D 11 is a good API for learning graphics programming and game development on the Windows platform. Direct3D 9 is only applicable to legacy systems or emerging markets which tend to have very specific and idiosyncratic hardware requirements. All modern Windows platforms support Direct3D 11 including Universal Windows Platform (UWP); Windows Win32 desktop apps on Windows 7, 8.1, or 10; and Xbox One. If you are interested, I suggest taking a look at the DirectX Tool Kit for DirectX 11.
UPDATE DirectXTK is also a good place to start because once you have learned it on DirectX 11, you can transition over to the DirectX 12 version and have a leg-up on the basics.
You can certainly learn the basics of graphics programming and game development on other platforms, but I can't speak to the best options there. One thing I can suggest is that you decide if your passion is really game development or graphics programming. You may not know enough right now to really judge fully, but these are distinct paths in the industry. If you have a game vision you want to make, then look at something like Unity or Unreal Engine so you can focus on game development aspects. If you are more interested in graphics or game-related technology (audio and media, engines, simulations, real-time interactive behvaior, etc.) in general, then learning Direct3D 11 is as good a place to start as any.

Graphics for C++ cross-platform music making software [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
EDITED, see below
I need an library to display graphics of music notation on a music making software. It will be Sibelius-like: Basically the user creates the sheet music and the app sends midi output.
I'm not looking for an library to display music notation, as for various reasons i must implement it myself. Also, the library i'm looking for must be cross-platform (should run at least on Windows and Linux).
The graphics will be vector-based or drawn with functions like "line(point1, point2);"
(Before continuing let me state that i'm new to C++ and most of my experience is with interpreted languages - PureData and Processing, mostly)
Now to the question:
I've found Cinder. You think Cinder is sutiable for the task? If no, you might skip 2 and 3.
I don't have experience with OpenGL. I couldn't actually figure out if Cinder uses OpenGL exclusively or if it uses it only on demand. My doubt here is, when using OpenGL libraries my application will only be able to run on computers with dedicated graphics cards?
Cinder doesn't have the hability to create GUIs like Qt or GTK+. Is it possible to integrade Cinder in another window, created by Qt/GTK+/SDL/etc ? I want something like Sibelius, where you have normal GUI (buttons, menus, etc) integrated in the notation graphics window.
If Cinder is not a good option, what might you recommend for that specific application needs? OpenCV? SDL? SFML?
EDIT:
I see this was marked as off-topic. Sorry, i'm new here. I've seen some posts asking for this kind of recomendation so i thought it was okay. Well, i will try to be objective and straight-forward
Question:
I need to draw music notation graphics, but i don't want to deal with low-level stuff (like Cinder, SDL, SFML, Ati-Grain). So, what are the other technologies available? That is, what are the other options?
What you are describing is a LOT of work and something impossible for someone with limited programming experience such as yourself. C++ is neither an easy language nor a language that forgives.. it's not just about learning the syntax (as is the case with processing or similar languages with automatic garbage collection) - it's also about managing memory and other resources, invariants, etc - leaving aside the complexities of linkage, compilation, etc: in turn this prerequisites that you have a thorough understanding of how computers work at a lower level.
Anyway, I'll try to answer your questions:
You could do this with cinder - this would probably mean having to re-invent the wheel - but you can do. I wouldn't say, however, that cinder is really suitable for such a task. This is meant for accelerated 2D/3D computer graphics. What you want is some more generic GUI library (maybe QT?). Regarding midi-support, you'll probably have to rely on some other library for this anyway.
Most computers these days do support openGL. Again you don't really need openGL for what you want to do.
Yes you can do this in theory - but it won't be easy and it's not really necessary for what you want to do.
OpenCV definitely NOT. This is for image processing - i.e. raster graphics - you need vector graphics. Let aside that OpenCV's Highgui is really slow on certain things so you'd have to use some other library for rendering anyway. I have no experience with the other libraries. My suggestion would be to either use some interpreted language such as python, luaAV or maybe SuperCollider (which does have built-in midi support by the way) which is far easier than C++, or to search for some open-source music-notation alternative (if there any) -> you can always build something of your own upon an existent code-base - reinventing the wheel is not necessary...

GPU programming in Standard C++ [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I know that you can program an OS by putting your code in the first 512 bytes of the RAM and things like that, but how do you program a GPU? Is it possible in standard C++?
I've heard of CUDA, but I would like to go by standards. Does Adobe Photoshop also use CUDA?
For all intents and purposes, there is no way to program a GPU without making use of some libraries, whether OpenCL, CUDA, or otherwise. While it is technically possible to drive the GPU directly (given that the GPU drivers are doing so!), documentation on how GPUs work is very difficult to come by, especially regarding advanced features such as those required for computation, and it's almost certainly not something you want to get involved with.
CUDA is a proprietary Nvidia language and software. It won't work on AMD graphics cards, or on recent Intel or AMD processors having an integrated GPU.
OpenCL is an industry standard, available on Nvidia and AMD graphics cards (and recent processors with integrated GPU).
However, pure standard C++ don't give you access to graphics cards or GPGPUs. You'll need an operating system and some libraries.
Notice that the small codes (called kernels) running on the GPU are not coded in fully standard C++, but in a small C-like dialect (also called OpenCL). There are some limitations (no recursive function, no function pointers, etc...) because of the weird nature of GPGPUs. The programming model is not as general as in C++.
There is also OpenACC, a set of pragmas for C++ compilers.
CUDA is the standard for NVidia cards. Alternatively OpenCL is also an option for a bit more cross platform.
http://en.wikipedia.org/wiki/OpenCL
Coding a GPU is fundamentally different to coding a CPU in that you have hundreds to well in the thousands of concurrent threads hence the different way of calling functions/kernels on the GPU.
NOTE: There is no way you can run your own code on the GPU without compiling it for the GPU therefore a standard C++ compiler will only be able to call functions in libraries.
It is surely possible up do everything in C++, but you will need to use some external libraries.
You might want to consider OpenCL instead of CUDA.
CUDA is a proprietary NVidia technology, while OpenCL works on more hardware and platforms.

Which C language and Graphic library should be use to write OS independent program? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am trying to write a program which I want to run just before booting up the system like the Setup program of Windows XP. The problem is that I cannot figure out which version of C/C++ programming language should be use. Because as far as I know about the many versions of C language they only works in DOS, Windows and Linux. Or is there any way to write the program in the Visual C++ or Turbo C that can run without any OS.
My next question is that which Graphics library can be use in that C language to create and display Images and Shapes on screen, Setting Background color etc.
I read an article on Windows in Wikipedia and I found that it is written on C++. So I thought that I can also write similar type of program in C++ without switching to Assembly language.
You want to write a program that runs directly off boot, with no OS loaded? Sorry, but if you need to ask which language to use, you have a learning curve ahead of you that's so steep that you ought to consider lowering your ambitions considerably for a first effort.
In the bad old days when space was at a premium, bootloaders were written in raw assembler. Today most of the functionality is written in C (or perhaps C++), but one still needs to go to assembler for the very earliest stages that take over from the BIOS, loads more code from disk than the single sector BIOS gives you, and puts the processor into protected mode so it can access more than 1 MB of RAM.
The choice between C and C++ is mostly up to preferences. C++ tends to require a somewhat more complex assembly intro in order to set up its run-time environment as the compiled code expects to find it. In either case, you won't have much in the way of standard libraries available. No malloc/free/new/delete unless you implement them yourself, for example.
No matter what the language, you will need to customize the linking phase much beyond what an off-the-shelf compiler toolchain will do for you with a simple command.
If you're using an x86 machine, you are going to have to learn how to work with either the default VGA buffer, or possibly VBE mode buffer if you want higher-resolution graphics. Most of this will have to be setup through calling BIOS interrupts or using MMIO ports dedicated to controlling the VGA buffer. In either case, this is going to have to be a mixture of assembly and C ... you can't really take advantage of C++ in this instance, since you will not have the use of a OS runtime that typically provides support for many C++-specific language features like exceptions, etc. If you want those types of features, you're going to have to setup the runtime yourself.
Here is a great site for information on the VGA registers that can be accessed through x86 MMIO: http://www.osdever.net/FreeVGA/home.htm
C/C++ does not matter as each system will compile it into the correct machine code for that machine. I can't remember the exact steps, but you're definitely going to have to mess around with copying your code into boot sector, etc.
You will inevitably have to write a little assembly language to be able to write something which boots before the OS. You'll have to write a boot-loader for one thing.
As to a graphics library, you will pretty much have to roll your own if you want graphics, because most libraries use at least some capabilities of an underlying operating system, no mater how cross-platform they are. You'll notice, for example, that the Windows setup program is all text until it boots into the Windows that's being set up for the first time.
As you mentioned yourself, you need to write a boot loader and that is, after compiling your boot loader you have to install it somehow (I'm not so sure about this part), but that usually involves copying it to a certain location of your hard disk, referenced by the master boot record.
As for graphics (or better say graphics card), as well as any other device that you want to interact with at boot time, you simply need to load their driver. So, in principle, your boot loader starts running, loads a bigger portion of itself into memory and once that is done, it start loading the drivers and starts working (similar to how an operation system boots, but much much simpler). The drivers are usually very limited but very generic drivers that you either have to write yourself or find on the internet.