Jump to content
  • Advertisement
Sign in to follow this  
cNoob

My own graphics library

This topic is 4500 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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*

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!