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 / Load png image from imbedded resource

Author
Message
WickedX
9
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 29th Jun 2014 07:18 Edited at: 29th Jun 2014 07:24
This question has been asked on the forum. How do I load a png image imbedded in the executables resource? Hay, Rocky. Watch me pull a rabbit out of my hat. The function declares 3 local variables and calls 1 Dark GDK function and only three DirectX functions. It uses the function D3DXLoadSurfaceFromResource() to load directly to the images texture surface, no memblock hacks here.

Press spacekey to exit.

Attachments

Login to view attachments
s_i
9
Years of Service
User Offline
Joined: 23rd May 2009
Location: Russia
Posted: 29th Jun 2014 13:27
Cool! How do you do it? To work with the imbedded resources will be enough Express version of VisualStudio? (I know how to use only imbedded icon for game file.)
WickedX
9
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 29th Jun 2014 18:27 Edited at: 29th Jun 2014 19:12
Works just fine with Visual C++ Express. Project attached.

Edit: Whoops, forgot to release the surface. Download updated.

Attachments

Login to view attachments
WickedX
9
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 29th Jun 2014 21:51 Edited at: 29th Jun 2014 21:53
This function loads the image into a bitmap. Do not release the surface, as a bitmap consists of a surface only.

s_i
9
Years of Service
User Offline
Joined: 23rd May 2009
Location: Russia
Posted: 29th Jun 2014 22:07
Thanks, very interesting.
But I do not understand, why are you doing this:


it is necessary to use internal resources?..
WickedX
9
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 29th Jun 2014 22:11
That handles the DirectX Lost Device issue. Lock your system or alt-tab - the application will recover.
s_i
9
Years of Service
User Offline
Joined: 23rd May 2009
Location: Russia
Posted: 29th Jun 2014 22:20 Edited at: 29th Jun 2014 22:39
Strange, because my full-screen game perfectly fulfills combination "alt-tab" without "handles the DirectX Lost Device issue".
What means "Lock your system"?..
P.S. I set resolution and use #include "DarkGDKWindow.h" instead of #include "DarkSDK.h" only in main.cpp, in other included .cpp files I use #include "DarkSDK.h".
WickedX
9
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 29th Jun 2014 22:37
Hold the windowkey and hit L - or see image.

Attachments

Login to view attachments
s_i
9
Years of Service
User Offline
Joined: 23rd May 2009
Location: Russia
Posted: 29th Jun 2014 22:47 Edited at: 29th Jun 2014 22:48
Yes, Win+L crashes my game if I use shaders, and makes nonfunctioning when I do not use shaders.
WickedX
9
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 29th Jun 2014 22:56 Edited at: 29th Jun 2014 23:01
In my function initVolitile(); - I reload and reinitialize everything lost. Such as the backdrop, images, objects, camera's (if using more than the default), shaders and display setting if not running in a window. With shaders you may only need to re-apply them.
WickedX
9
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 30th Jun 2014 08:49 Edited at: 30th Jun 2014 08:55
Looking through the dsutil.h and dsutil.cpp files, I just realized DarkGDK is already setup to load sounds from an imbedded resource. Cool, saves me the work.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2018-07-16 06:00:31
Your offset time is: 2018-07-16 06:00:31