Wrox Programmer Forums
|
BOOK: Visual Basic 2005 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2005 Programmer's Reference by Rod Stephens; ISBN: 9780764571985
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2005 Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 13th, 2006, 02:48 AM
Authorized User
 
Join Date: Mar 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Textures and Direct3d

Hi Rod

I have been working with DirectX to be able to render a 3D object (one created for Microsoft Flight Sim). I have run into a problem with textures and I can't seem to get round it.

I am using the function TextureLoader.FromFile(Device, TextureFile)

To get a texture where textureFile is a string containing the full path to the texture file. I can load straight format bmp files fine but the ones I need to load are DXT1 bitmaps and these fail with a very unhelpful error - something like 'application error'. I have looked in the SDK and it seems that DX should be able to handle a whole range of formats. In fact FS textures can be in different formats so I need to be able to load them (preferably without knowing the format first). Any pointers much appreciated



Jon Masterson
__________________
Jon Masterson
 
Old June 13th, 2006, 07:32 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Sorry but I haven't done any DirectX for a long time. I have no clue on this one.

Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html
 
Old June 13th, 2006, 07:58 AM
Authorized User
 
Join Date: Mar 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK Thanks Rod


Jon Masterson
 
Old September 30th, 2006, 10:36 PM
Registered User
 
Join Date: Sep 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Jon and Rod:
I have also been working on FS textures, and although I have edited these textures for years using the tools in the Microsoft SDK and photoshop, I am very new to handling them in VB.

The texture files use the .bmp extension, but are not typical "Windows Bitmaps".
They are described as DXT1, DXT3 or DXT5 each with slightly different characteristic, but they all have an alpha channel for either transparency or reflectance, and MIP maps.

They can be viewed and converted from one format to another using the SDK utility "Imagetool".

There is an excellent discussion on the web page from Martin Wright located at: http://fly.to/mwgfx/

[u]Some of the formats described are:</u>
DXT1 RGB image, MIPs, the Alpha channel ignored
DXT1a RGB image, MIPs, the current Alpha channel reduced to 1 Bit
DXT3 RGB image, MIPs, the current Alpha channel reduced to 4 bit 16 level)
DXT5 RGB image, MIPs, the current Alpha channel.
(256x256 images use 7 mip maps, 512x512 use 8 mip maps)

Martin's site offers many great tools for viewing, converting and editing these files, designed specifically for MS flight simulator.

He also can provide a developers package with support for his .dll with routines to load almost any format image, create MIP maps, and alpha channel and save to any of the FS formats.

ROD: I have obtained the develper files, but none of the books I have purchased, including yours, show a Newbie step by step how to incorporate a 3rd party .dll into my project.

I have documention for the called routines and parameters, but where do I put the files, and how do I declare them?

The files in the folder provided are of the types:
.dll, .bas, .frm, .frx, .scc, .vbp, and .vbw

Note: the dll was written in C++, but the above files were written for VB6. Can we use them in .net?

thanx,
.....joisey





Author of NuRoads 2.0
 
Old October 2nd, 2006, 06:36 AM
Authorized User
 
Join Date: Mar 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have stopped using VB.Net - I found that working with DirectX is much easier from C# (as most of the examples and the SDK are in C#).

I am using Martins libraries to transform textures. I found that changing the modified bmp texture into DDS and using the DDS worked - changing it to a straight BMP loses the transparency information. I had to check if the bmp was regular or DXT before trying the conversion as it did not seem to work if the BMP was a regular 256 BMP.

I am using Martin's dlls successfully from C# using PInvoke. in VB API calls should work fine


Jon Masterson
 
Old October 2nd, 2006, 10:13 AM
Registered User
 
Join Date: Sep 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx Jon: Very interesting.
I purchased VB.net 2002 over a year ago at retail for almost $200, and recently aquired "VB2005.net express" as a free download. As I am in the middle of my new project, with such steep learning curves and so little time (still working a full-time day job) I don't think I can afford the time or money to acquire yet a new language.
I will have to just find a way using VB.net

The files I am working with are road textures found in Scenery/world/texture. Although they are not windows bitmaps, they do use the extension .BMP, and "Imagetool" identifies them as DXT5, alpha, 8 MIPs. Unless they are ultimately saved with the .bmp extension ,they will not be recognized by the sim.

I am trying to write a utility so that the user can load the image file, manipulate some of the pixels with my routines, and save them back to their Flight Sim Folder.

I have worked with images in VB.net, but never with a dll library from a 3rd party.

Can Rod or someone direct me to the instructions for including a .dll from an outside library into the code? Martin's library came with examples, but they are for vb6.
thanx,
......joisey
Author of NuRoads 2.0
 
Old October 2nd, 2006, 10:46 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

First: C# 2005 is released as an "Express" application as well:

http://msdn.microsoft.com/vstudio/ex...harp/download/

Second: To import .DLLs into VB you do something like this:

Declare Function [function exposed by dll] Lib "name.dll" () As [Type]


hth.

--Stole this from a moderator

I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
 
Old October 2nd, 2006, 11:58 PM
Registered User
 
Join Date: Sep 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dparsons, hi:
Thank you for the info.
I have installed the Express C#.net
I'll continue attempting to use vb.net for a while, but it looks like I'll have to learn C#.net in order to properly use the D3D SDK and the available libraries.
The question is whether to attempt to re-write (translate?) my work to date, or to start from scratch using c#.
I really doubt that I could afford to hire someone to do part of my project, but who knows? Write me: joisey@mindspring.com
.....joisey



Author of NuRoads 2.0
 
Old October 3rd, 2006, 07:28 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Sorry, Jon. I can't be any help with that one, either. You could try loading it with a Bitmap object and see if that works. If so (I wouldn't hold by breath) then you can write it into a bmp file and load it as a texture them.

Sorry I can't be more help.

Rod

Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html
 
Old October 3rd, 2006, 11:37 PM
Registered User
 
Join Date: Sep 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by joisey
 "I am using Martin's dlls successfully from C# using PInvoke in VB API calls should work fine"....jon

Jon:
Thanx for the advice. Can you possibly send me a code snippet for either vb.net or c#.net illustrating the declarations and a call to one of Martin's routines. I just downloaded C#.net and need to purchase a textbook.
(Does Rod have a C# book or can he recomend one comparable to his
vb2005 book.)
Please contact me: Joisey@mindspring.com

thanx....joisey

Author of NuRoads 2.0
Author of NuRoads 2.0





Similar Threads
Thread Thread Starter Forum Replies Last Post
Textures Euqil C# 0 February 19th, 2006 10:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.