I have continued to play around with loading embeded resource data files and have come up with a alternative way to create a D3DTexture from an embeded resource image. This new method seems more apropreate. (To me at least :p )

If you are wondering why I am loading embeded resource images rather than simply loading and creating a D3D texture from a file, it is because external files can be lost and can result in you app not being able to run. Not that I will be doing this for every app I write!

    Protected Friend Function LoadResource(ByVal ResourceName As String) As IO.MemoryStream
        Dim ResourceStream As IO.Stream

        ResourceStream = Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(ResourceName)

        If ResourceStream Is Nothing Then Return Nothing
        Dim byts(CInt(ResourceStream.Length - 1)) As Byte
        Dim Len As Integer = ResourceStream.Read(byts, 0, CInt(ResourceStream.Length))

        Dim MemStream As New IO.MemoryStream(byts, 0, Len)
        Return MemStream
    End Function

    Protected Friend Function LoadResourceImage(ByVal ResourceImageName As String) As Direct3D.Texture
        Dim Mem As IO.MemoryStream
        Mem = LoadResource(ResourceImageName)       

        ' attempt to load/create image we saved to memory stream
        Dim Tex As Direct3D.Texture
        Tex = Direct3D.TextureLoader.FromStream(mobjGraphics.Device, Mem)
 
        ' done with varibles
        Mem.Close()
        Mem = Nothing  

        ' return reference to texture
        Return Tex
    End Function

I have added a cool little code snip that demonstrates a way of loading a image that was added to a project and declared "Embeded Resource" at design time, and returns a newly created D3D texture.
The code is written in vb.net and DX9.

Private Function LoadResourceImage(ByVal ResourceImageName As String) As Direct3D.Texture
        Dim Mem As New IO.MemoryStream()
        Dim Img As Bitmap

        ' attempt to create bitmap from embeded resource
        Img = New Bitmap(Me.GetType, ResourceImageName)

        ' save image to memory stream
        Img.Save(Mem, Drawing.Imaging.ImageFormat.Png)

        ' seek to start of stream
        Mem.Seek(0, IO.SeekOrigin.Begin)

        ' attempt to load/create image we saved to memory stream
        Dim Tex As Direct3D.Texture
        Tex = Direct3D.TextureLoader.FromStream(mobjGraphics.Device, Mem)

        ' done with varibles
        Mem.Close()
        Mem = Nothing
        Img.Dispose()
        Img = Nothing

        ' return reference to texture
        Return Tex
End Function

DX9Tools overkill?

Published 5/14/2004 by createdbyx in News

I am just finishing off merging the GameToolsR2, DXEliminatorR2, and EasyRenderSystemR1 libraries into the DX9Tools library. And then I got to counting ...

The DX9Tools solution references about 40 different projects! That's alot of projects. =)

So in addition to merging the libraries I am also going to merge all of the DX9Tools Example projects into one. This should help to simplify things as well as help speed up both the compile process and vb.net's background compile feature.


DX9Tools update...

Published 5/14/2004 by createdbyx in News

I have uploaded the 5.53mb snapshot of the full DX9Tools R5 solution. Including ...

GameToolsR2 <- this is also a pre-release
MAXExport and the maxscript for exporting scene data compatible with 3DS MAX v3 and above
MSAni maxscript parser exporter <- possibly discontinued because MAXExport replaces it
DXEliminatorR2 <- this is also a pre-release
Easy Rendering System project. <- work in progress

NOTE: That this is not to be considered an actual release just a third pre-release snapshot.

I am thinking that I am going to merge the DX9Tools, GameTools, and DXEliminator libraries into the DX9Tools library. This would help to unify all three libraries as well as redudce the complexity of having to manage 3 seprate libraries, and should make it easier for all of you who are using the libraries.

I am also thinking I am not going to bother uploading "pre-release snapshots" for DX9Tools but instead, just make a release even if that release contains code that is not complete or simply does not work yet.

You can find link to download the DX9Tools R5 snapshot3 here ...
DX9Tools at gotdotnet


Pardon the interruption

Published 5/12/2004 by createdbyx in News

Excuse the discontinuity on my site I am in the process of adding comment features to my blog hopfully should get it working by tomorrow. But for now it's nap time...


You can post your comments!

Published 5/12/2004 by createdbyx in News

I have finished tweaking my blog with a slightly new look as well as the ability to add comments to my blog posts! I have been wanting a user comments feedback functionality for some time now.


I have took my May 12, 2004 block post titled "IDEA: Textured Index Buffers for D3D" and have posted under a number of fourms located at...

xtremevbtalk
vbgamer
intheoryforum


I have written a new article regarding an idea I have about "Textured Index Buffers for D3D"

Textured Index Buffers for D3D


I saw a news post at VBGamer stating you could get a free copy of VB.NET 2003 standard edition and all you have to do is watch 5 movies relating to vb.net and app development.

I watched a number of movies, the site send me a activation email, I got the email right away and filled in my shipping address and pressto in 4=6 weeks I should have a free copy of VB.NET 2003 standard edition CD in the mailbox! Whoot! GO check it out at VB.NET at the movies!


Progress Report

Published 5/6/2004 by createdbyx in News

DX9Tools R5 progress report...

I have a 99% complete new library called MAXExport that I expose out to COM. I have also written a MAXScript script for 3DS MAX that uses the classes from the MAXExport library to export Meshes+Animations and Cameras+Animations.

But I am having trouble on the MAXScript side not working properly.

The reason I am making this MAXExport library and MAXScript script is because I am in the process of adding custom animation classes to DX9Tools so that you can use 3DS MAX to create your meshes and scenes and export them. As well as providing the classes to load and play the animations in your apps/games. I have some Animation classes already built and working, but I want to add more features before I posting the official Release 5 for DX9Tools.

I am also doing some more work on DXEliminator and will make a post for that soon.


Created by: X

Just another personal website in this crazy online world

Name of author Dean Lunz (aka Created by: X)
Computer programming nerd, and tech geek.
About Me -- Resume