Author Topic: PLUGIN: Direct3D v1.0 (Sprite and Theora video rendering) [2012-02-08]  (Read 7664 times)

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
Thanks! :)
I'll see about getting it downloaded and test it.

Yes, I know about not working on other platforms, and atm am not that worried about it.
So unless you can make the AGS play.movie (or what it's called) command play a movie in the BG (non-blocking), which I would rather use than a plugin... I have litte choice.
The only other choice is importing a huge amount of sprites and explode the sprite and game size. :( 

EDIT: Just finished installing the D3DX9_43 (dxwebsetup.exe I downloaded by following the CW's link), and that fixed it! :D I'm on win10, just for future reference. ;)

Thanks bunch, now I can test this pluging and see if it fixes the flipped frames bug from scotch's plugin. :D

EDIT 2: This is weird... I got this error even though my game is 32bits colour with true alpha. ??? ???
Quote
---------------------------
Adventure Game Studio
---------------------------
An internal error has occurred. Please note down the following information.
If the problem persists, post the details on the AGS Technical Forum.
(ACI version 3.4.0.13)

Error: 32bit colour mode required.

---------------------------
OK   
---------------------------
« Last Edit: 10 Jan 2017, 16:34 by Cassiebsg »
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
EDIT 2: This is weird... I got this error even though my game is 32bits colour with true alpha. ??? ???
Quote
---------------------------
Adventure Game Studio
---------------------------
An internal error has occurred. Please note down the following information.
If the problem persists, post the details on the AGS Technical Forum.
(ACI version 3.4.0.13)

Error: 32bit colour mode required.

---------------------------
OK   
---------------------------

This is because the plugin checks which graphics mode is set preliminary, in AGS_EngineInitGfx plugin callback, and therefore gets "incorrect" values.
Something changed in between AGS 3.2.1 and 3.4.0, probably in earlier versions AGS set up these values in advance (before actually trying to set screen mode).



EDIT:

I have checked the Plugin API description, and this is what is said there:
Quote
DLLEXPORT void AGS_EngineInitGfx(const char* driverID, void *data);
Called by AGS just before the graphics driver is initialized. This allows you to make changes to how the driver starts up.
driverID is the ID of the graphics driver in use. This can either be "D3D9" if the player is using the Direct3D driver, or "DX5" if they are using the standard DirectDraw driver.
If driverID is "D3D9", then the data parameter is a pointer to the D3DPRESENT_PARAMETERS structure that AGS is about to pass into CreateDevice. If you need to enable extra features such as the Auto Depth Stencil, then you can do so by changing the member variables at this point.
If driverID is "DX5", then the data parameter will currently be passed as NULL.
   
This event is called just as the graphics subsystem is starting, so functions that like GetScreenDimensions that rely on the screen being initialized will not work if called from this event.

Note what I marked with red color. This is actually what the plugin is doing: it calls GetScreenDimensions at that point, which is not guaranteed to work. The reason that it worked with 3.2.1 was pure luck, it's just that engine was coded in such way back then.


EDIT2:
I can with all honesty say, that I would not want to "fix" engine to work with this plugin; although we make such backwards-compatible fixes for old scripts, but how plugin is coded is not responsibility of AGS developers.
AJA seem to visit forums recently, I suggest to contact him and ask if he still has this plugin sources and whether he may fix it. Plugin needs to use callback argument (D3DPRESENT_PARAMETERS) instead of GetScreenDimensions to check screen mode.
« Last Edit: 13 Jan 2017, 15:37 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
Thanks bunch for checking CW! (nod)
I'll wait a bit and see if AJA sees and replies here in the thread, before PMing him.
There are those who believe that life here began out there...

To my great surprise, I found the sources for this ancient turd, whee!

Should run in AGS 3.4.x now: http://www.serpentpictures.net/ags_d3d/ags_d3d.zip

Thanks, CW, for figuring out the fix beforehand. Saved me a lot of time, cheers! :cheesy:

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
Cool, thanks bunch you two! :)

Downloaded, activated and tested (as in yes, I can open my game now with no error! :-D ).
Looking forward to test it with the code and video now! (nod)

EDIT: eeeeewwwwwwwww..... :~( Finally had some time to test this, and now I get a game crash when trying to load the video.

Quote
---------------------------
Illegal exception
---------------------------
An exception 0xE06D7363 occurred in ACWIN.EXE at EIP = 0x76BDB727 ; program pointer is +1004, ACI version 3.4.0.13, gtags (32,400)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.

in "room1.asc", line 29


Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.

An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)
---------------------------
OK   
---------------------------

The line in question is: video = D3D.OpenVideo( "Galactica_Intro.ogv" );

Now, this video works fine if I use scotch's Theora plugin.
I basically just copy/pasted this code:
Code: Adventure Game Studio
  1. D3D_Video* video;
  2.  
  3. function room_Load()
  4. {
  5.     // Required for autoplay
  6.     D3D.SetLoopsPerSecond( GetGameSpeed() );
  7.    
  8.     // Open video file
  9.     video = D3D.OpenVideo( "TheoraVideo.ogv" );
  10.    
  11.     if ( video )
  12.     {
  13.         // Use room coordinates
  14.         video.relativeTo = eD3D_RelativeToRoom;
  15.        
  16.         // Anchor point to top left corner
  17.         video.SetAnchor( -0.5, -0.5 );
  18.        
  19.         // Play!
  20.         video.Autoplay();
  21.     }
  22.     else
  23.     {
  24.         Display( "Couldn't open video." );
  25.         return;
  26.     }
  27. }
  28.  
  29. function room_Leave()
  30. {
  31.     // Free memory when leaving the room
  32.     video = null;
  33. }
  34.  

And replaced the name of the file with my video.
Is it me that is doing something wrong?
I can provide the dump, if needed.
« Last Edit: 14 Jan 2017, 21:28 by Cassiebsg »
There are those who believe that life here began out there...

Apparently if you run it from the editor it's looking for the video file in the Compiled folder but if you run the windows executable it looks for it in the Compiled\Windows folder. Maybe that's the issue you're running into? The error handling in this plugin appears to be quite lacking, sigh.

CW, can you confirm that GetPathToFileInCompiledFolder(const char*fileName, char *buffer) is no longer working as expected with the new platform specific folders or is there some other method I should be using to get the final compilation folder?

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
Okay, thanks for the info! :-D

Yes, that seems to be the problem. I copied the video to the compiled folder and now it loads! (nod)

Guess I just assumed that since the Theora plugin worked with the video from the game project, that so would this one. (roll)
Sorry about it. :)

Now I can launch myself into making my cutscene entirely in Blender and save on the sprite size ;)... or maybe I should do a few tests before counting victory... again.

EDIT: Just one more question, and probably why I didn't thought of copying the file into the compiled folder...
but shouldn't the code with the else Display("Couldn't open the video."); had been shown instead of crashing the game?
« Last Edit: 17 Jan 2017, 19:24 by Cassiebsg »
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
CW, can you confirm that GetPathToFileInCompiledFolder(const char*fileName, char *buffer) is no longer working as expected with the new platform specific folders or is there some other method I should be using to get the final compilation folder?
With changes to build folders structure I was going to remove any dependency on hard-coded folder names in the engine in the future, and subsitute them with some parameter passed by the Editor.

But as of 3.4.0 we still have a rule that all game data should be placed into Compiled folder, from where they are copied to every version (Windows etc).
This actually brings me to a thought that running game under debugger may not work correctly if you have Windows-only data for you game.
« Last Edit: 17 Jan 2017, 19:31 by Crimson Wizard »

Ah, so it gets copied there on compile, gotcha!

Cassiebsg, I uploaded a new version which should fix the file not found issue but also, and more importantly, implements screen scaling so it should look the same regardless of at what resolution you're running the game. Might not work perfectly but at least it's a start in case you decide to keep using the plugin.

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
Thanks, the scaling was a nice fix, I noticed on my previous run that the video was small and on the lower corner. But now it's filling the screen. (laugh)

However... the game no longer almost not crashes if it doesn't find the file. :-\
Putting a display into room_load crashes the game.
But then again, does the video need to be in room_load? what happens if it's in AfterFadeIn? I'm guessing, and hoping that it'll work just as fine. Because I'm planing to use the same room to run all 3 movies/cutscenes.

Also, file doesn't get copied on compile. But I suspect that is expected, and I have no problem moving the file into the compiled version, or even into the final game version. No problem here that needs urgent fix. Maybe just a note on the html file though. ;)

EDIT: Just tested with a second video in the room, and works fine. Well, again, almost, the return; after the Display puts the game on a loop, of constantly repeating the "Couldn't open video.". So I just deleted the line,now displays the message and continues running the code and thus the game. ;)
« Last Edit: 17 Jan 2017, 21:39 by Cassiebsg »
There are those who believe that life here began out there...

At least in AGS 3.4.0.13 if I had the video file in the compiled folder and built the game, it got copied to the folder that has the exe.

But then again, does the video need to be in room_load?
You can of course load the videos whenever you need them, shouldn't make any difference.

Anyway, glad to hear you're mananing to wrestle this thing into submission! ;D

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
Hey :)

All is working just fine!  (nod)

Just one "quirk", I have the movie inside a skipable cutscene, and I've noticed that I need to press ESC twice to actually skip the scene. First ESC stops the movie and all text and then just "hangs" there, untill I press it again, and then it opens the menu GUI.

Here's the code I'm using:
Code: Adventure Game Studio
  1. void Cutscene_Intro()
  2. {
  3. StartCutscene(eSkipESCOnly);
  4. // some speech and music code
  5. while (video.NextFrame() && !IsKeyPressed(eKeyEscape))
  6. {
  7.     Wait(1);
  8. }
  9. EndCutscene();
  10. //other code including turning the menu visible
  11. }
  12.  

I can post the entire room code, if you think it makes a difference.
There are those who believe that life here began out there...

I ran the same code quickly in my test project (AGS 3.4.0.13) and didn't notice any issues enabling any menus after the video is skipped. Only thing I noticed was that if you have a line of dialogue (probably anything skippable with a key press), it would be skipped without an extra wait after the cutscene.

Code: Adventure Game Studio
  1.     StartCutscene(eSkipESCOnly);
  2.    
  3.     while (video.NextFrame() && !IsKeyPressed(eKeyEscape))
  4.     {
  5.       Wait(1);
  6.     }
  7.    
  8.     EndCutscene();
  9.    
  10.     Wait(1); // Need to wait here so the key press doesn't skip the dialogue
  11.     cEgo.Say("This is not shown without the extra wait");

Could your issue be something related to that or caused by some other part of your code?

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
Okay, seems to be working even more weirdly than I expected. I removed CW's typewriter module out and the problem went away... So seems to be the other module that is interfering. But after I put the typewriter back is started working right (as in just one key press), but not if I do it right at the start...

So ignore this, problem seems to the be with the typewriter module.
Sorry to bother you and thanks for the quick reply.  (nod)
There are those who believe that life here began out there...

No problem. Let's hope it doesn't mysteriously unfix itself. :P

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
Okay, stumble into a new problem, not sure if this is caused by the plugin or the AGS code, though.

So, I have this working perfectly now, and decided to address the problem of "what happens if the player is in a system that can't run the plugin?" And to avoid having the game just crashing and refusing to play I added the following code:

Code: Adventure Game Studio
  1. if (Game.IsPluginLoaded("Direct3D Plugin"))
  2.   // load the video code
  3. else
  4.   Display("Couldn't load the plugin");
  5.  

The good news is that the game no longer crashes if the plugin fails to load  :-D... the bad news is that I can't get the video to load  :~(...I've tried putting on the string's plugin name "Direct3D" , "Direct3D Plugin" , "Direct3D Plugin (ags_d3d.dll)" and "ags_d3d.dll" .

And just to be sure this:

Code: Adventure Game Studio
  1. if (!Game.IsPluginLoaded("Direct3D Plugin"))
  2.   // load the video code
  3. else
  4.   Display("Couldn't load the plugin");
  5.  

Results in video loads just fine, and crashes if I remove the dll from the compile folder. So it's definitely the check that is failing...

Any ideas?  ???
There are those who believe that life here began out there...

It should be "Direct3D Plugin", at least that's what the plugin returns as its name, so either the method is broken or it's checking against some other string.

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
Oh, I realized the manual entry is not elaborate enough.

IsPluginLoaded checks against plugin's FILENAME WITHOUT EXTENSION. Because the OS may not be Windows, but e.g. Linux, which have different extensions for plugins.

Like "ags_d3d".

I decided to make it check against filename, because game references plugin same way in its data when decides what to load.
« Last Edit: 13 May 2017, 15:01 by Crimson Wizard »

Cassiebsg

  • Cavefish
  • Fleeing the Cylon tyrrany...
Ah, cool.

Thanks CW.  (nod)

But now it's acting up like before I added the check. It just crashes if I remove the dll from compile folder.  8-0

Quote
Error:Unable to create local script: Runtime error. unresolved import 'D3D_Video::get_renderStage'

I have my code in the room script, where I have
Code: Adventure Game Studio
  1.  
  2. D3D_Video* video; // defined at the top of the script
  3.  
  4. function room_Load()
  5. {
  6.   if (Game.IsPluginLoaded("ags_d3d"))
  7.     // load the video code
  8.   else
  9.     Display("Couldn't load the plugin");
  10.  

Still not sure if this is my poor scripting skills, AGS or the plugin.  :-\
There are those who believe that life here began out there...

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
If you are using SCRIPT COMMANDS from plugin in your script, then using IsPluginLoaded won't help you in any way.

This is how AGS works, it must get a script function if it was even mentioned in scripts, and if it cannot get one from plugin, then it refuses to continue.
« Last Edit: 13 May 2017, 16:41 by Crimson Wizard »