flat assembler
Message board for the users of flat assembler.
Index
> Windows > plotting pixels to the screen |
Author |
|
bitshifter 26 Jul 2009, 04:44
There are 3 popular ways to render in windows.
(You cant write directly to video memory) 1) GDI 2) DirectX 3) OpenGL What is this application for, a game? I have many demos, maybe one for you. |
|||
26 Jul 2009, 04:44 |
|
tthsqe 26 Jul 2009, 07:14
I would like to make a program that animates plots in real-time. Each plot is generated not by calculating a color for each pixel but by a random walk-like process on the screen. Thus, it is almost necessary that the screen be cleared between plots. Each step in the walk requires 40-50 cycles to generate the next screen coordinate, and I would like to do 10^5 - 10^6 or so iterations. If I did the math right, this works out to a max of 46fps on a 2.3GHz cpu for a million iterations. I can't afford a performance hit for plotting each point, so I though writing directly to the screen buffer in memory would be a solution. I have seen something like this in the mandelbrot and juilia set programs involving [ddsd.lpSurface], but have not been able to extract the essential parts of these codes. Is [ddsd.lpSurface] not a pointer to the screen buffer? Any help would be appreciated. I am not too familiar with direct draw code.
|
|||
26 Jul 2009, 07:14 |
|
bitshifter 26 Jul 2009, 16:32
The DX surface is a buffer which gets transfered to screen.
If you are using WinXP or less you can make .com files which can access video memory for VGA hardware. That would be the fastest way to plot pixels. Also i have made a simple OpenGL app which paints pixel. The relevant code is commented like ;xxxxxxxxxxxxxxxx If this turns out too slow for you i can help with the VGA coding. You sure are lucky i have such a passion for graphics coding
_________________ Coding a 3D game engine with fasm is like trying to eat an elephant, you just have to keep focused and take it one 'byte' at a time. Last edited by bitshifter on 21 Sep 2009, 12:51; edited 1 time in total |
|||||||||||
26 Jul 2009, 16:32 |
|
tthsqe 26 Jul 2009, 18:23
thanks. I'll write back as soon as I try it out
|
|||
26 Jul 2009, 18:23 |
|
tthsqe 27 Jul 2009, 04:33
Everything seems to be working up to the 1365th point. When glVertex2i is called for the 1365th time in render, something abnormal happens and all of the xmmx registers are cleared upon return. Are you able to reproduce this? Is there a limit to the number of points one can plot in one frame?
|
|||
27 Jul 2009, 04:33 |
|
bitshifter 31 Jul 2009, 20:26
I see no reason why you cant fill the entire resolution.
|
|||
31 Jul 2009, 20:26 |
|
Kuemmel 03 Aug 2009, 19:59
Hi tthsqe,
regarding your request about plotting something on the screen and waiting for key pressed, I stripped down my Mandelbrot bench (kind of fast rude strip down, some may be unusefull code, especially for threading left over). You'll find it attached, it just displays now my palette data. So you should find the plot routine easily now. Everything should be there, like screen address, etc etc. Just read also up about DirectDraw, you need 'ddsd.lpSurface' for the address and also 'ddsd.lPitch'...to have the right offsets in case there. You asked also about clearing the screen...so I don't do that in my code...but it would be just a memory fill to the screen or may be or for sure there might be some faster DirectDraw routine for that (sorry not a DirectDraw expert).
|
|||||||||||
03 Aug 2009, 19:59 |
|
windwakr 03 Aug 2009, 20:18
Kuemmel, have you tested that code? On my computer it went to fullscreen, drew the palette, and then COMPLETELY LOCKED UP MY SYSTEM. I had to hard boot my computer.
|
|||
03 Aug 2009, 20:18 |
|
vid 03 Aug 2009, 21:03
IMO the easiest to use is SDL.
|
|||
03 Aug 2009, 21:03 |
|
windwakr 03 Aug 2009, 21:07
Someone should code up an example of SDL in assembly, I can't find anything about using it in assembly. It would require a lot of include converting...Ok, nvm...
|
|||
03 Aug 2009, 21:07 |
|
Kuemmel 03 Aug 2009, 21:46
windwakr wrote: Kuemmel, have you tested that code? On my computer it went to fullscreen, drew the palette, and then COMPLETELY LOCKED UP MY SYSTEM. I had to hard boot my computer. Hm, works well here on Vista 64 (but is 32bit code)...use ESC to exit after drawing...as I said, was quite a fast hack, might have some problems...the SDL stuff sounds quite nice...anybody setting it up for FASM !? |
|||
03 Aug 2009, 21:46 |
|
windwakr 03 Aug 2009, 21:54
I have 32 bit win xp sp3, It completely locks it up. ESC does nothing.
SDL in FASM would be quite an undertaking, but that would be awesome if someone managed it. Anyone here wanna do it? Too bad its not as simple as just importing the dll.... |
|||
03 Aug 2009, 21:54 |
|
c rex 11 Sep 2009, 20:59
I used to code in visual basic, and someone showed me StretchDiBits which typically beats opengl and directx because they must convert video memory to normal ram, you do math, and memory is shot back to ram
Code: Type RGBQUAD Blue As Byte Green As Byte Red As Byte Alpha As Byte End Type Type BITMAPINFOHEADER biSize As Long 'vb 32 bits biWidth As Long biHeight As Long biPlanes As Integer 'vb 16 bits biBitCount As Integer biCompression As Long biSizeImage As Long biXPelsPerMeter As Long biYPelsPerMeter As Long biClrUsed As Long biClrImportant As Long End Type Type BITMAPINFO bmiHeader As BITMAPINFOHEADER bmiColors As RGBQUAD End Type Declare Function StretchDIBits Lib "gdi32" _ (ByVal hDC As Long, _ ByVal X As Long, _ ByVal Y As Long, _ ByVal dx As Long, _ ByVal dy As Long, _ ByVal SrcX As Long, _ ByVal SrcY As Long, _ ByVal wSrcWidth As Long, _ ByVal wSrcHeight As Long, _ lpBits As Any, _ lpBitsInfo As BITMAPINFOHEADER, _ ByVal wUsage As Long, _ ByVal dwRop As Long) As Long Public Const BI_RGB As Long = 0 Public Const DIB_RGB_COLORS As Long = 0 'Function call StretchDIBits DC, _ X, Y, Wid, Hgt, _ 0, 0, BIH.biWidth, BIH.biHeight, _ Array32bpp(0, 0), BIH, DIB_RGB_COLORS, vbSrcCopy I think vbSrcCopy = 0 |
|||
11 Sep 2009, 20:59 |
|
pabloreda 15 Oct 2009, 15:20
Hi, perhaps this help
I'm finish the core for compile and I use StretchDiBits, I don't finish the fullscreen mode. this example fill the buffer and copy to video.
|
|||||||||||
15 Oct 2009, 15:20 |
|
Rahsennor 09 Nov 2009, 02:42
Google TinyPTC and its successor pixeltoaster. They use C, but they do exactly (and only) what you want and shouldn't take much to port to fasm.
|
|||
09 Nov 2009, 02:42 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.