Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Help Loading DLL Resources...

Author
Message
Acolyte
18
Years of Service
User Offline
Joined: 3rd Feb 2006
Location:
Posted: 7th Sep 2008 08:52
Hello all.

I was wondering if anyone could help me with loading resources from a dll. I have a dll that was compiled with several jpeg images using visual basic.net. First, do I need to recompile this dll with c++ in order to use it within a GDK game? If it is possible to load my current dll using LoadLibrary, how do I access the saved jpegs from within the dll so that I can manipulate them with the GDK functions? All of the examples i've seen on the forums deal with loading a dll and then calling a function within the dll; however, i'm referring to loading a dll with a series of jpegs within.

Thanks in advance for any help you guys give me.

Windows XP Home Ed. SP/2 ---> GeForce FX 5500 - 256MB
160 GB HD ---> 1 Gig RAM
kBessa
17
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 7th Sep 2008 09:22
@Acolyte:

I'm not a C++ expert, so I can't really tell how to call a VB.NET dll from C++.

About loading them to DGDK, it is not possible to do it directly, as the GDK has no methods to load Images (or objects, sounds, etc) from memory streams. The workaround is to read the file from your dll, save it to disk and then load it to GDK.

Hope this info helps at least a little.

Regards,
Thiago
Acolyte
18
Years of Service
User Offline
Joined: 3rd Feb 2006
Location:
Posted: 7th Sep 2008 17:53
I can see what you mean; however, the whole point of having them in a dll to begin with is so that I don't have to load them from the hard drive as this wastes an unbelievable amount of time, it's much faster to just load the dll into memory and then access the resources from the library itself.

So it's not possible to do it in the GDK, then does anyone know how to do it using c or c++ commands? I need to know the following:

1. Loading the dll and getting it ready to be accessed.
2. Accessing the image files within the dll and getting them into a format which the GDK can handle the images with it's image routines.
3. A safe way to unload the information when done

I think this would be more than adequate knowledge for my needs. I've been successfully loading the DLL using the LoadLibrary method. If that helps anyone know the direction in which i'm headed. Thanks again!

Windows XP Home Ed. SP/2 ---> GeForce FX 5500 - 256MB
160 GB HD ---> 1 Gig RAM
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th Sep 2008 18:00
Acolyte
18
Years of Service
User Offline
Joined: 3rd Feb 2006
Location:
Posted: 7th Sep 2008 18:06 Edited at: 7th Sep 2008 18:14
i really donn't appreciate that. I'm a loyal member to these forums and i search them frequently, just because I miss one thing doesn't mean you should treat me like a noob.

apart from that, reading your post provides little relevant information to my situation at all. Yeah, you show how to deal with loading and converting a resource from a resource stream to a bitmap; however, i'm asking specifically how to do this from a dll and my images are jpegs not bitmaps which probably makes a difference also.

Windows XP Home Ed. SP/2 ---> GeForce FX 5500 - 256MB
160 GB HD ---> 1 Gig RAM
kBessa
17
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 7th Sep 2008 19:41
@IanM: I once tried converting you method to DarkGDK.NET but it did not work right.

I might try it again, but the problem is it just solves for Bitmaps, I don't know how difficult it would be to make it work for other kind of files: Models (.x for example, with animations), Images, Sounds, Animated Sprites, etc.

I still don't know why DGDK doesn't have methods to load directly from memory, because IIRC, DirectX does allow this to be done.
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 7th Sep 2008 20:07 Edited at: 7th Sep 2008 20:07
Quote: "however, i'm asking specifically how to do this from a dll"

Use LoadLibrary to load the DLL and pass its handle to the LoadBitmap function. To be honest I don't think you'll notice much of a speed difference loading files like this.

Acolyte
18
Years of Service
User Offline
Joined: 3rd Feb 2006
Location:
Posted: 7th Sep 2008 21:24
thanks

Windows XP Home Ed. SP/2 ---> GeForce FX 5500 - 256MB
160 GB HD ---> 1 Gig RAM
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th Sep 2008 21:28
Quote: "i really donn't appreciate that"

Uh, bad day?

Unless you have included your jpegs as a custom resource, the only other types that can hold images in a resource that I'm aware of are icons and bitmaps. As Benjamin pointed out, the LoadBitmap takes the handle of the executable that holds the resource as its first argument - that's a few lines extra to the code I posted back then.

If you are using a custom resource, then you'll need to write custom code and you're on your own.

@kBessa,
Unfortunately, all the other resource types need to be coded individually if you just dump data into the resources. If you pre-prepare the data in it's GDK memblock format, then I'd guess that you could simply copy the resource data into a memblock to reconstruct the original - wouldn't be great for objects though as memblocks lose most of the model information when used in this way.

You're right about the memory thing - TGC could make this stuff lots easier, simply by assuming that all GDK resources are built from memory. Adding file support once you've done that is trivial.

Login to post a reply

Server time is: 2024-09-30 05:41:45
Your offset time is: 2024-09-30 05:41:45