flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > [solved]learning directdraw |
Author |
|
vivik 03 Apr 2018, 17:36
Got it working. Just added the same clipper to the backbuffer as well. BltFast doesn't work, but Blt works.
|
|||
03 Apr 2018, 17:36 |
|
vivik 10 May 2018, 16:34
Not a question, just wanted to say. DirectDraw reacted very weirdly to trying to draw beyond the borders of the window. I tried to draw image of width 60 to rect [-60...0] or [-60...-1], that is just to the left of window border, and it lagged, and after a while screen went black for a few seconds. And after that, explorer didn't run, could only see mouse. Alt-tab and windows key didn't work, but ctrl-shift-escape and ctrl-alt-delete did. Also, ctrl-alt-del, closing session and reopening it actually caused bsod
Probably just a buggy driver. Also, don't try to draw without Sleep(1); at the end, it draws too fast to notice, only 1/7 of frames actually get visible. I know there are other ways to do delay, Sleep works fine for me for now. Need to measure fps somehow though. I need examples of games/programs that use directdraw. Or games for windows in general. |
|||
10 May 2018, 16:34 |
|
vivik 29 Jun 2018, 20:07
A bit about fps and tearing.
I'm lucky to own a computer with a fried videocard, gdi and directdraw based games still work fine on it, as long as you play in windowed mode or in a small enough screen resolution. I guess I'll just keep it for visual novels and emulators. Bejeweled 2 Deluxe still works fine, even shows 90 fps most of the time. I saw hidden depths in this game, I learned that they use both directdraw and direct3d8 (or 7?) for this game depending on what computer it's run on. Graphics are even slightly different for both versions, title screen and level transition effects. I actually downloaded and compiled (!!!) popcap framework, there is some good info in the documents. Can't avoid tearing though, all methods fail, directdraw->GetMonitorFrequency, directdraw->WaitForVerticalBlank, directdraw->GetScanLine. They work on a working computer, but not on that one. Maybe I can assume that frequency is 75 hertz, and just use timers, manually... http://www.sega-16.com/forum/showthread.php?29176-DirectDraw-Tearing https://www.codeproject.com/Articles/4436/Tearing-free-drawing-with-GDI http://www.virtualdub.org/blog/pivot/entry.php?id=74 |
|||
29 Jun 2018, 20:07 |
|
vivik 29 Jun 2018, 20:43
I'm not sure if directdraw is any better than gdi in this scenario, the "no hardware acceleration" case. I guess it's slightly better, since you can actually lock a surface and access the raw data in it. With gdi, you need to construct .bmp file in memory first, obliviously not efficient. I even made a thread about this before somewhere.
You still need gdi for rendering text though. You may use bitmap fonts in some cases, but chinese has to use the os provided fonts, simply due to it's size. TrueType font rendering is a surprisingly complicated matter. One thing I noticed, some games display very rough, pixelarted text when you scroll through it fast (AIR for example), but show properly smoothed text with shadow under it when it stays. I'm curious how they keep resources, because game lags for a few seconds when a new image loads. They are also clever with transitions. They try to not update the whole screen at the same time, they fade left part of the screen to black, middle part, right part. They probably use dirty rects here too. I'm not sure if you can use dirty rects in directdraw, I know it has clipper lists, but it's probably different. Also, how can I see if half of a window is closed by some other window, and I need to render only half of what I usually render. The latter is most likely impossible. I hope to make a few games for Kolibri os, doubt they have drivers for videocards and such. Doubt I'll ever do that though. About directdraw text editor, I guess I'll have 1 frontbuffer and 2 or 3 backbuffers. I'll render the entire screen in one backbuffer, and prerender the screen above and the screen below. In cases where I scroll too fast, I'll render only 1 backbuffer. |
|||
29 Jun 2018, 20:43 |
|
vivik 30 Aug 2018, 19:33
I need to find out if i can make scrolling faster. Directdraw is fast enough when run in a small window, but for larger windows the delay is noticeable. For cases when only part of the window needs redrawing, i probably can just redraw that part of the screen and that's it.
directdraw + dirty rects, how? |
|||
30 Aug 2018, 19:33 |
|
MacroZ 13 Oct 2018, 23:17
I don't know why anyone would use DirectDraw when Direct3D is just as easy to set up, in addition you get 3d acceleration, which is good even for 2d games (Isometric simulation)
I recommend using Direct3D, I have created a library using Direct3D, it has 208 methods in it. I have all the basic methods available for graphics, sound and input. Well I use Direct3D for drawing, DirectSound for sound and RawInput for input. It's a "collection" library that I've created with all the basic functionality ready to go, and it's fast, probably faster than DirectDraw, when you're dealing with old things like directdraw, you can expect it to be a wrapper for newer technologies, which makes it even slower. Well, when I'm thinking back, it wasn't EASY to create it, there is a LOT of stuff to get into just to get the basics up, there are tons of stuff that takes time to learn. It's actually quite complex to initialize a Direct3D app correctly. Just when you thought you had it... 1 month later Just when you thought you had it... 1 month later Just when you thought you had it... 1 month later Just when you thought you had it... 1 year later (Still, just when you thought you had it) The problem is not getting it up and working nicely, the problem is getting unseen/unexpected things not happening. Here is an example method: Code: ;############################################################################################################## ; Copy any number of vertices from a system memory vertex buffer to ; the memory of a video vertex buffer and add an offset to each vertex ;############################################################################################################## ; Entry: ; rcx = The number of vertices to send ; rdx = Address of the locked region to write to ; r8 = Address of the first source vertex coordinate pair ; r9 = Address of the first source vertex diffuse value ; xmm0 = The Real4 value to add to each x coordinate (See notes) ; xmm1 = The Real4 value to add to each y coordinate (See notes) ; Return: ; rax = Address of the locked region after the one written to here proc _VidVbSendVerticesAnyTrns,Count,ppbData,pFirstCoord,pFirstDiffuse Z = dword 0.0 RHW = dword 1.0 punpckldq xmm0,xmm1 mov r11,rcx pshufd xmm0,xmm0,01000100b mov r10,(RHW shl 32) or Z shr rcx,1 jz .SendLast align 4 .Loop: movaps xmm2,[r8] addps xmm2,xmm0 pextrq [rdx],xmm2,0 pextrq [rdx+20],xmm2,1 mov eax,[r9] mov [rdx+16],eax mov eax,[r9+4] mov [rdx+(20+16)],eax mov [rdx+8],r10 add r8,16 add r9,8 lea rdx,[rdx+40] sub rcx,1 jnz .Loop .SendLast: test r11,1 jz .return movq xmm2,[r8] pextrq [rdx],xmm2,0 mov eax,[r9] mov [rdx+16],eax mov [rdx+8],r10 .ret: ret endp ;############################################################################################################## |
|||
13 Oct 2018, 23:17 |
|
vivik 13 Nov 2018, 05:50
About directdraw and dirty rects. You can hope to get dirty scanlines with directdraw (probably), but dirty rect is more of a gui thing, this is what windows does all the time when it draws windows on screen. So, you better leave this to gdi.
Though there is some support for them. >I don't know why anyone would use DirectDraw when Direct3D is just as easy to set up, in addition you get 3d acceleration, which is good even for 2d games (Isometric simulation) I own one computer with a fried videocard, it's only usable in safe mode or if I disable videocard in device manager. Video player and some games still work on it, interestingly enough. |
|||
13 Nov 2018, 05:50 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.