Thursday, September 21, 2006

Living in a refurbished slaughter house

Back to poking at my .Net code this morning. Seeing as I'm on a new computer I'm also going to see if blogger will allow me to upload photos, in the past it's always been quite fussy. I think that it's because I had firefox force any pop-up to load in a background tab. Well looks like it's working now!

Anyway I thought I'd talk a little about DirectX devices and forms. This relates to creating directx fullscreen apps as well.

When you create your device you create a PresentParameters object and this takes in two important variables; the height and width of your display area. If you have a form you might think - oh this is just form1.Width and form1.Height but you'd be wrong! That's the entire height of the form, including the blue bar with the maximize, minimize and close buttons, and the little grey border. If you use these values it will most likely throw some of your calculations off.

One way round this is to put a panel in the form and then use panel1.Height, panel1.Width and this will work fine because the panel has no border stuff. Unfortunately it will fail horribly if you try to do fullscreen. To do fullscreen the component you use must be a form.

So what's the best way to get the width and height? Well it's not to hard-code them, like I seem to have done on my project :D Rather it's to get them from form1.DisplayRectangle. This gives the area you can draw in and doesn't include any of the form fluff, like grey outlines and drop menu strips!

So there you go.

Also looks as if blogger's actually going to show one of my images. This test image just shows how I use firefox and rss. If in firefox you add a bookmark and put it in the "Bookmarks Toolbar Folder", it will appear as a button on a strip just above the window your currently browsing. Then you can press it and it'll take you to the relevant page. Great. If you add a bookmark to an RSS feed in the folder, a button will once again appear on the strip. But this time when you press it, it will form a drop down menu listing all the newest items in that feed (you can do that with this webapge by the way :D You'd get a list of all my latest posts with their rather cryptic titles :) . Even greater. Of course, if you keep doing this, that strip's going to get quite full! So you might want to add a folder within the "Bookmarks Toolbar Folder", this folder will also be represented as a button on the strip.

Click the folder and it will create a drop down of all the links you've put in there. I like to have folder just of RSS feeds. Then I can run my mouse down them and see if there's anything new on the webpages I'm interested in.

If you've read this and you're thinking, "I don't know what RSS feeds are :(", well, well done for reading it all :D RSS feeds are some XML files hosted on the webpage you're interested in and each time the page is updated, the xml's updated too. Then your computer periodically (every few minutes or so) queries this xml file and updates it's local listing of that particular pages updates. So rather than you manually checking for updates the updates are brought to you.

(Well the image seems to work quite nicely. The webpage shown is an online stockmarket electronic broker thing, because recently I've become a little interested in the stockmarket, after reading the, to be honest, rather crappy book, Rich Dad Poor Dad. Expect more images from now on!)

EDIT: I think I've the found artifact problem, it seems to be due to the ratio between directx space and pixel size of the display area and textures.

EDIT: I can't believe I was back again today battling with artifacts when rendering tiles GAH!! Anyway for what's it's worth it's fixed now. I made a new library with fixed spelling called Einfall.RenderPrimitives. Where I made one small change. But I think one of the main sources of artifacts occurs if your form.DisplayRectangle doesn't equal your othographic projection width and length. Currently I'm scrolling smoothly with batched unartifact tiles. So that's nice. I guess the worse thing was this worked fine before on my laptop :O I'm somewhat confident now it will work nicely on all systems. So now all I need do is rewrite my tight map project (which is basically a small tiled engine that uses batching, animation and layers.) and the artifacts should dissapear.

Then once that's working nicely I'll have to merge it into Einfall which I guess will be a never ending serious of headaches. And then, then, I'll have einfall create buildings that actually have walls! Currently the buildings are merely flat outlines.

Final Edit: Quick bit of tinkering and tight map is now compiling as expected.
Post a Comment