My own graphics library

Started by
3 comments, last by discman1028 17 years, 10 months ago
Hey everyone. Im not to sure if this is the right place to be posting this but I couldnt think of a better place. Ive been up all night(its 3:08am) trying to find a solution to my problem so if you cannot understand my post i will rephrase again tommorow when I am not falling asleep. Right then i took the time and dedication today of learning ASM and i have been doing really well. I have created a demo which changes video mode to number 18 (640x480 16 colours) and I have plotted a blue pixel in the center. The program runs until a key is pressed. Heres my code:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Pixel Plot
; Matthew Henley
; 29/05/2007
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
start:
;Set Display Mode (18)
MOV ah,00;
MOV al,18;
INT 10h;

;Draw A Pixel At The Center (320,240)
MOV ah,12;
MOV al,1;
MOV cx,320;
MOV dx,240;
INT 10h;

;Wait For A Key To Be Pressed
MOV ah,00;
INT 16h;

;Switch Back To Text Mode
MOV ah,00;
MOV al,3;
INT 10h;

;Exit Properly
MOV al,4Ch;
MOV ah,00;
INT 21h;

Now that i have managed to do that in ASM I was woundering how would i do the same in Cpp. Without another graphics API like D3D, OpenGL, GDI. Is there a way i can get a pointer to the video memory and change the mode. Then plot the pixel. This is all just for a learning purpose as if i manage to do it in Cpp i will then be able to make a very simple primitive graphics library (pixels, lines, rectangles, ellipse). Thank you for your time and i hope you can understand. *snores and falls asleep*
Advertisement
Why do you want to stay away from Direct3D/OpenGL? If you don't use them, you'll be relying on the software to do all of the graphics processing. If you use OpenGL/Direct3D, it will allow you to take advantage of video hardware, making your graphics render extremely fast.
Rob Loach [Website] [Projects] [Contact]
You can, but you need a DOS compiler. You can't do that with a Windows executable (a console app is NOT a DOS program).

There was a quite simple graphics library out there (PGE?) that provided you with a 32bit image buffer for quite a lot of OSs. This might be easier in the end and you can do low level pixel access.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Quote:Original post by Rob Loach
Why do you want to stay away from Direct3D/OpenGL? If you don't use them, you'll be relying on the software to do all of the graphics processing. If you use OpenGL/Direct3D, it will allow you to take advantage of video hardware, making your graphics render extremely fast.


Im not staying away from them. I have used GDI and started with Direct3D about a year ago. Im just woundering whether it is possible for someone to create a very simple graphics API.

Quote:Original post by Endurion
You can, but you need a DOS compiler. You can't do that with a Windows executable (a console app is NOT a DOS program).

There was a quite simple graphics library out there (PGE?) that provided you with a 32bit image buffer for quite a lot of OSs. This might be easier in the end and you can do low level pixel access.


Thanks for the advice ill be sure to check it out.
I'd be interested to know what sort of low-level libraries exist as well. (I have not looked into it).

Could you not just inline his asm code within c++ code? (Even if it must run from DOS only).
--== discman1028 ==--

This topic is closed to new replies.

Advertisement