February 28, 2020, 09:47:43 pm

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


DirectX Line drawing

Started by GWS, August 03, 2018, 03:11:58 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

Hi,

I mentioned in another post that having had a bit of computer trouble, I had to replace my graphics card.  With it came DirectX 11.

I allowed the card installation to load DirectX 11 - bad move.

I found that DX lines drawn from Creative, were not smooth - they were 'dashed' - ordinary GDI lines were fine.  Circles were a bit iffy as well.

So I tried the same code in EBasic - the DX lines with DX11 were perfectly smooth.

Daughter Kim brought her laptop with DirectX 10 on it.  The lines in Creative were drawn perfectly.

So sadly, it looks like Creative Basic no longer works correctly with DirectX version 11. :(

That's a shame, since it's worked for years with DirectX 7 onwards.
Trust Microsoft to wreck legacy software.

Best wishes, :)

Graham



Tomorrow may be too late ..

Egil

Thats funny...

On my old workhorse running Win7/64 and DX9 with a screen adapter listed as Intel HD Graphics 4600, the very same thing happens when running dxlines.cba. But when running another ecample program, lines.cba the lines are all drawn perfectly.

Anyway, I stopped trusting Microsoft a  couple of years ago. Seems like they want to get rid of hobby coders.
If it wasn't for the price I had changed to a Mac long time ago, especially if I had been able to use any of the IW languages on it.


Regards

Egil
Support Amateur Radio  -  Have a ham  for dinner!

GWS

Hi Egil,

Interesting test .. it could be that Creative's DX line drawing was always incorrect.
The test program dxlines drew so many overlapping lines, it was hard to see the gaps in some of the lines.

From memory, I think Creative used 'Retained mode' DX graphics (whatever that means), while EBasic did something different with it's graphics buffers.

The other program you tried lines.cba, uses ordinary GDI graphics, and that works fine.

It's not a serious error - unless you need smooth lines.

All the best, :)

Graham
Tomorrow may be too late ..

GWS

Hi folks,

After a bit more testing - and a new graphics card ..  ::) I think I've resolved the problem ..

It's down to the already known problems of incompatibility of Direct X screens with normal windows controls.  For instance Button controls cannot be relied upon to work in a DX environment. You would need to draw and handle your own buttons.

Similarly, lines drawn in a windowed DX screen, occasionally exhibit visible gaps.

If the DX screen is full screen (ie. the bits per pixel setting is specified), the lines are pretty well perfect.  Just slight anti-aliasing occurs.

I include my modified DXLines pogram which demonstrates the effects.

It sets the bits per pixel to 32 in the CreateScreen statement to create a fullsize DX screen - the lines are now pretty good, but of course the Windows menu control is lost.  Hence the need to press Q to exit.

If you then temporarily remove the 32 bpp from the CreateScreen statement, you get a Windowed DX screen - but the lines are not so good.

The conclusion is - keep DX screens separate from ordinary Windows.  They don't get on well together.

Here's my modified program ..

Code Select

' the DirectX lines sample program
' displays random lines

autodefine "off"

IF GETDXVERSION < 7
MESSAGEBOX 0,"This program requires" + chr$(13) + "DirectX 7.0 or greater","Error"
END
ENDIF

declare "kernel32",GetTickCount(),int

DEF win:window
DEF size,tstart,run:int
def wW,wH:int

wW = 1024
wH = 768

'open a window and add a menu
WINDOW win,0,0,wW,wH,@SIZE|@MINBOX|@MAXBOX|@CAPTION|@NOAUTODRAW,0,"Lines ala DirectX",mainwindow
MENU win,"T,Options,0,0","I,Clear,0,1","S,Line Size,0,0","I,1,0,2,","I,2,0,3","I,3,0,4","^I,Quit,0,5"

IF CREATESCREEN(win,wW,wH,32) < 0 :' Note: the 32 bbp creates a full size DX screen without the menu

' try temporarily removing the 32 bpp value to get a windowed screen
' Note the slight incompatibility of the DX screen with Windows -
' the lines are often incomplete, and the close window icon is erratic.

MESSAGEBOX win, "Could not create DirectX screen","Error"
CLOSEWINDOW win
END
ENDIF

setfont win, "arial", 14, 600
frontpen win,rgb(0,250,0)
drawmode win,@TRANSPARENT

size = 1
SETLINESTYLE win,@LSSOLID,size

run = 1

gosub Draw :' draw first group of lines

waituntil run = 0
closewindow win
end

'this is the handler subroutine for the window
sub mainwindow
SELECT @class
case @IDCREATE
centerwindow win
case @idclosewindow
run = 0
case @idchar
if (@CODE = ASC("Q")) | (@CODE = ASC("q")) then run = 0

case @iddxupdate
' draw new random lines every 4 sec update
if ((GetTickCount() - tstart) >= 4000) then Draw

case @IDMENUPICK
SELECT @MENUNUM
CASE 1
RECT win,0,0,wW,wH,RGB(55,55,55),RGB(55,55,55)
CASE 2
CASE 3
CASE 4
SETLINESTYLE win,@LSSOLID,@MENUNUM - 1
size = @MENUNUM - 1
CASE 5
run = 0
ENDSELECT
case @IDMENUINIT
CHECKMENUITEM win,2,size = 1
CHECKMENUITEM win,3,size = 2
CHECKMENUITEM win,4,size = 3
ENDSELECT
RETURN

sub Draw
' draw random lines
dxfill win,RGB(35,35,35) :' start with a new grey background
move win, 40, 20
print win, "Press Q to Quit"

for i = 1 to 20 :' draw 20 random lines
line win,rnd(wW),rnd(wH),rnd(wW),rnd(wH),RGB(rnd(255),rnd(255),rnd(255))
next i

dxflip win,1 :' specifying the 1 tells dxflip not to wait for vertical sync
tstart = GetTickCount() :' set new start time

return



Best wishes, :)

Graham




Tomorrow may be too late ..