flat assembler
Message board for the users of flat assembler.

Index > Windows > Graphics under Windows

Author
Thread Post new topic Reply to topic
P3t3_Asm



Joined: 09 Nov 2010
Posts: 2
P3t3_Asm 09 Nov 2010, 13:22
Hi,
Firstly 'hi', my first post.

I would like to develop an application under Windows to do computer graphics type primarily.

I'd prefer not to use DirectX or OpenGL, else I would be coding this in C/C++. I love assembly language, which is why I'd like to code from the ground up, and access the graphics card memory directly.

I'm not sure if this is possible under Windows. I'm assuming you have to access Ring 0 to be able to read/write to the graphics card. I could be wrong here.

If this is possible, could someone point me to information and/or examples on how to start this.

Else do I have to do down the path of going outside Windows, i.e. bootloader, and being able to access whatever I want easily? If so, any pointers on where to start? I noticed the OS forum has heaps of bootloader related information. That is covered well. But I would need graphics programming information.

I know assembly fairly well. Coded for fun over the years on PCs (in the early days) and PIC microcontrollers lately, but nothing too serious.

I know this will be a large learning curve, but I love assembly language programming alot, and would enjoy it immensely.

Some of you from the Commodore 64 days may remember the demoscene. I sure do, I pine for those days Smile

Many thanks
Pete
Post 09 Nov 2010, 13:22
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 09 Nov 2010, 13:28
Windows does not allow user programs to access the hardware directly so you are correct in your assumption. You have to run a real mode OS, or at least something other than Windows, that allows direct writes to the video chip and the video memory.
Post 09 Nov 2010, 13:28
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 09 Nov 2010, 17:37
If you're going to run under Windows, you need to play by the rules. There's not much sense in trying to "directly write to the hardware" anyway, unless your goal is to write a toy operating system.

If you just want some low-level graphics, use GDI, DirectX or OpenGL for setup, just enough code to get access to the framebuffer - then you can write to that from your glorious assembly code.
Post 09 Nov 2010, 17:37
View user's profile Send private message Visit poster's website Reply with quote
P3t3_Asm



Joined: 09 Nov 2010
Posts: 2
P3t3_Asm 09 Nov 2010, 23:04
Thanks heaps guys!

It looks like I'm forced to write a tiny simple OS-like host to do low-level graphics hardware programming.

I'll take a look in the 'OS Construction' forum on how to proceed with this.

And in the mean-time, (being a n00b) if I go down the other path of using DirectX under Windows, can someone please point me to assembly language + DirectX information/examples?

Thanks.
Post 09 Nov 2010, 23:04
View user's profile Send private message Reply with quote
pabloreda



Joined: 24 Jan 2007
Posts: 116
Location: Argentina
pabloreda 09 Nov 2010, 23:05
I have a "framework" for use the graphics windows like the old school.
I teach asm with this framework too.

http://code.google.com/p/reda4/source/browse/trunk/r4asm/r4fasm.asm

write me if you like and need help about this
Post 09 Nov 2010, 23:05
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 10 Nov 2010, 00:01
P3t3_Asm wrote:
can someone please point me to assembly language + DirectX information/examples?
There is a directdraw example in the "EXAMPLES" folder in the Windows download.
Post 10 Nov 2010, 00:01
View user's profile Send private message Visit poster's website Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 11 Nov 2010, 20:25
If you have XP or less, you can access BIOS to set vga modes.
Then read or write directly to video memory.
Otherwise DX or GL is the common choices.
I prefer GL since its easier to use.

vga demo: http://board.flatassembler.net/topic.php?p=108398#108398

opengl demo: http://board.flatassembler.net/topic.php?t=9262&postdays=0&postorder=asc&start=0
Post 11 Nov 2010, 20:25
View user's profile Send private message Reply with quote
rocketsoft



Joined: 26 Jan 2010
Posts: 189
rocketsoft 12 Nov 2010, 21:56
I think it should be possible to write directly to the hardware screen buffer from within a windows application bur i have not figured out yet how
It would greatly speed up my graphics
Maybe i would have to write my whole application as a driver, so i work at
ring 0?
Post 12 Nov 2010, 21:56
View user's profile Send private message Visit poster's website Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 13 Nov 2010, 08:20
It is possible to write pmode vga driver pretty easily.
You just need to use port io and set the mode manually.
I also think it will have to be a win32 console application
or at least a gui application without wndclass/window/etc...
Post 13 Nov 2010, 08:20
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 13 Nov 2010, 10:06
rocketsoft wrote:
I think it should be possible to write directly to the hardware screen buffer from within a windows application bur i have not figured out yet how
DirectX allows you to do that.
rocketsoft wrote:
It would greatly speed up my graphics
It would (probably) greatly speed up your app if you used hardware acceleration instead of manually drawing pixels Smile

rocketsoft wrote:
Maybe i would have to write my whole application as a driver, so i work at ring 0?
Don't even think about it. You don't hammer in nails with nuclear bombs, do you?

_________________
Image - carpe noctem
Post 13 Nov 2010, 10:06
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 14 Nov 2010, 03:56
People (SciTech) have written VESA Windows drivers like 10+ years ago, but in modern terms the video hardware often is as fast or faster than the CPU(s). The object should be to minimize data on the bus and let the video processor do it's thing.

I'm not saying the video card manufacturer is perfect - just that they have more information about the video card than anyone else and they don't feel like sharing.

I have templates for DX8 thru DX11 which just display stuff on a surface. Also, there are plenty of good examples on the board using the hardware for more. Using GDI/D2D in Win7 is hardware accelerated!
Post 14 Nov 2010, 03:56
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 14 Nov 2010, 15:02
use opengl
Post 14 Nov 2010, 15:02
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 14 Nov 2010, 16:24
edfed wrote:
use opengl
Any reasons for suggesting OpenGL in particular?

I would think DirectX (in particular, some older DirectDraw) is the smarter move, since there's a greater likelihood of it being available across all Windows versions - and have less overhead (isn't the default Vista-and-later GL implementation implemented on-top of DirectX?).

_________________
Image - carpe noctem
Post 14 Nov 2010, 16:24
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 14 Nov 2010, 16:27
bitRAKE wrote:
Using GDI/D2D in Win7 is hardware accelerated!
At least when you have a WDDM1.1 driver. Also, don't pretty much all pre-Vista Windows versions have GDI hardware acceleration? Afaik it was disabled in Vista to support double-buffering (without the display stack upgrade Win7/WDDM1.1 brought), and for most systems and applications, nobody noticed a difference anyway Smile (in speed, anyway - the reduced tearing because of double-buffering is pretty noticeable).

_________________
Image - carpe noctem
Post 14 Nov 2010, 16:27
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4073
Location: vpcmpistri
bitRAKE 14 Nov 2010, 17:06
Supporting hardware acceleration and having the hardware driver support that model are two different things. How much each video card manufacturer decided to support is all a blur to me, but I do remember it wasn't uniform. Direct2D is Win7+ specific. My point was that there are many ways to get to GPU acceleration presently - which don't require RE'ing the hardware. (Unless you find that kind of thing fun.)

I skipped Vista like last years flu and I like to pretend it doesn't exist. Wink
Post 14 Nov 2010, 17:06
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 14 Nov 2010, 18:21
bitRAKE wrote:
How much each video card manufacturer decided to support is all a blur to me
Same here - all I know is that, for normal applications, whether GDI is accelerated or not makes pretty much no difference on normal hardware - and some software even suffers from hardware acceleration (locking a on-gpu bitmap for pixel access = bad).

bitRAKE wrote:
My point was that there are many ways to get to GPU acceleration presently - which don't require RE'ing the hardware. (Unless you find that kind of thing fun.)
Mmh. Use hardware acceleration if you want things to go smooth - if you want to learn, use a supported API to get framebuffer access. If you want to waste time, write a toy OS kernel and video drivers Razz

bitRAKE wrote:
I skipped Vista like last years flu and I like to pretend it doesn't exist. Wink
Hehe. Vista Vanilla didn't survive long on my box; SP1 isn't that bad, once you tweak services a bit - I ended up keeping it on my laptop until Win7 came out. Given the choice between XP and Vista (on proper hardware), I'd choose Vista.
Post 14 Nov 2010, 18:21
View user's profile Send private message Visit poster's website Reply with quote
seppe



Joined: 12 Apr 2015
Posts: 15
Location: Belgian in Tenerife
seppe 20 May 2018, 10:58
I believe that WDDM is the low-level graphics driver to support all graphic cards.
Does anyone have some experience using WDDM from assembly? Question
Post 20 May 2018, 10:58
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.