Quantcast
Viewing all articles
Browse latest Browse all 6821

How to determine if the app is using Desktop GL or DX.

@willmotil wrote:

I know internally monogame uses if defines for different platforms. My question is as follows.

Is there a public accessor that will return for example DesktopGL or Windows that i can call from within Game1 to return what monogame see's as the targetplatform internally ?

Details...

Recently i was asking about loading a .fx from a string pumpkin pudding helped with that.
I would like to wrap that up into a nice little codeblock.

However to do so...

I need to add both dll's to my project which is fairly easy.
I also need to pass the correct target platform to the call.

In order to do that though... i need to detect the platform programmatically before game load() finishes.

Here is a snippet of code to better illustrate the problem.

        public Effect LoadFxString(GraphicsDevice gd, string fxcode)
        {
            string sourceFile = Directory.GetCurrentDirectory() + "/tmp.txt";
            File.WriteAllText(sourceFile, fxcode);
            EffectImporter importer = new EffectImporter();
            EffectContent content = importer.Import(sourceFile, null);
            EffectProcessor processor = new EffectProcessor();
            PipelineManager pm = new PipelineManager(string.Empty, string.Empty, string.Empty);
            //___________________________
            // ill need to detect the platform to pass the correct target
            //
            // DX
            pm.Platform = TargetPlatform.Windows;
            //
            // GL
            //pm.Platform = TargetPlatform.DesktopGL;
            //
            // ideally instead of the above.
            // pm.Platform = this.CurrentlyRunningTargetPlatform;
            //___________________________
            pm.Profile = GraphicsProfile.HiDef;
            PipelineProcessorContext ppc = new PipelineProcessorContext(pm, new PipelineBuildEvent());
            CompiledEffectContent cecontent = processor.Process(content, ppc);
            ContentCompiler compiler = new ContentCompiler();
            return new Effect(gd, cecontent.GetEffectCode());
        }

Essentially i need to know the TargetPlatform programatically.

Other wise ill have to constantly change this depending on the project template i make instead of the template im running change to the correct target platform in the code block which would be a little bit annoying.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles