0

How do I interact with the VGA in order to display arbitrary image directly, without drawing pixel by pixel as the evident and elementary ways do?

What I want to accomplish is faster image rendering without involving 3rd party libraries from external sources.

Imobilis
  • 1,379
  • 6
  • 23
  • What platform? MS-DOS? I'm just guessing based on the last time raw VGA was relevant. If this is the case, set the video mode to 13h for 320x200 256-color mode and write to 8-bit palette pixels starting at segment A000h. – Multimedia Mike Apr 09 '15 at 23:28
  • @MultimediaMike Sorry, I totally forgot to mention the OS. Added new tag. Anyway, now that I see you have knowledge on this.. sadly I don't. I may be able to partially submit what you said in practice but it will be nor extremely hard or not complete.. unless there are a bit more detailed instructions. Thanks. – Imobilis Apr 09 '15 at 23:32
  • If you don't want to use provided API, the obvious and the most painful way to do that could be using BIOS interrupts. Standart BIOS video interrupt vector is 0x10, video mode: 0x00, setting palette registers: 0x10, writing graphics pixel mode: 0x0C, saving states: 0x1C and so on... Maybe you can take a look at BIOS interrupt table, get some ideas and do some experiments in kernel mode. – Unavailable Apr 10 '15 at 02:49
  • @BoraBozkurt Can I set the video mode without using only stdio ? – Imobilis Apr 10 '15 at 02:52
  • This is very common, just search `windows display bitmap` on this forum. There are many ways to do it, you don't need 3rd party tools. – Barmak Shemirani Apr 10 '15 at 03:01
  • @BarmakShemirani I can't find any source of implementation of the REGS structure. I need to find a way to set the video mode first. – Imobilis Apr 10 '15 at 03:04
  • @Malina You have to do this in a very primitive and close-to-hardware manner. I'm talking about x86 assembly here. If you're coding in C, you may use inline assembly routines. So, you are going to do this with registers. It has absolutely nothing to do with stdio. – Unavailable Apr 10 '15 at 03:05
  • If I succeed in this direct drawing only with the help of stdio, stdlib, math and string libraries.. this will be my new year resolution. – Imobilis Apr 10 '15 at 03:10
  • you can forget about direct access inside Windows because: 1. for that you need Kernel mode or 3th party tool to get Kernel mode privileges like JUNGO or DLPortIO. 2. BIOS routines limits you to CGA/EGA/VGA (which is mostly emulated these days) and sometimes VESA only 3. for true speed and direct access you need to access HW directly which bounds you to specific HW and that is backward ... What speed you realy need? `[Byte/sec] ` usually drawing to bitmap in memory and GDI draw the whole thing to target window is fast enough (up to 70 fps if coded right no problem) – Spektre Apr 10 '15 at 07:04
  • look here http://stackoverflow.com/a/21699076/2521214 – Spektre Apr 10 '15 at 07:09
  • @Spektre what I use now is VERY slow. I am using basic `putpixel(x, y)` and rendering images pixel by pixel takes seconds. Everything that is faster.. I will do everything needed to make it work. But once again.. I can't use any other 3rd party library whether it is dynamic or standard header file.. That's why succeeding is a dream. – Imobilis Apr 10 '15 at 08:22
  • the putpixel is slow because it calls huge amount of tests ... the putpixel it self is single mov instruction ...try to get scan lines from your image instead ... it is a pointer to single line that you can handle as 1D array with direct access without delays ... single scan line call is the same speed as single putpixel ... but you can call it just once per image resize ...no need to call it twice ... – Spektre Apr 10 '15 at 15:48
  • @Spektre In the platform I am coding, putpixel is even slower. I am trying to learn what can I do about that with pointers, stdlib, stdio, math and string. If I can do something please tell me. – Imobilis Apr 10 '15 at 18:14
  • for Windows `stdlib` and `stdio` are outdated 2 decades old stuff used for MS-DOS commandline output left for compatibility reasons. For GUI Windows applications use WinAPI or your IDE native libs. What language/compiler/architecture you write apps for? in Borland use VCL's bitmap and GDI as in my answer in the last link from the comment of mine above, in MS-VCPP compilers you need to use what ever is ther like HBitmap ...the GDI is there but I do not code for that compiler VB C# must have something like Canvas too (all of it is a GDI Windows thing) – Spektre Apr 11 '15 at 06:39
  • the free C/C++ compilers/IDEs usually do not have native Windows gfx output capability and only 3th party libs are used like OpenGL,DirectX,or ports/emulations of Borlands even older BGI (Graphic.h) called WinBGI ...Anyway if you include Windows.h (and link the libs for it if needed) header then you should be able to use WinAPI anyway ... – Spektre Apr 11 '15 at 06:44
  • I can't include anything. It is a cross-platform scripting tool that is old, considering the fact it uses c89 as a standard. – Imobilis Apr 11 '15 at 12:20

0 Answers0