I'm trying to make a Texture importer using the FreeImage library. I'm following the idea in Shawn's blog here:
http://blogs.msdn.com/shawnhar/archive/2007/04/02/any-language-you-like-as-long-as-it-s-at-build-time.aspx
I can't seem to get it to use my importer. Here is a basic skeleton, hopefully someone can shed light on.
File > New Project > Visual Studio Solutions > Blank Solution
Add > New Project > Visual C++ > CLR > Class Library
MyImporter
// MyImporter.h
#pragma once
using namespace System;
using namespace Microsoft::Xna::Framework::Graphics;
using namespace Microsoft::Xna::Framework::Content::Pipeline;
using namespace Microsoft::Xna::Framework::Content::Pipeline::Graphics;
namespace
MyImporter {
[ContentImporter(".foo", DisplayName="My Custom Texture Importer", DefaultProcessor="SpriteTextureProcessor")]
public ref class MyTextureImporter : ContentImporter<TextureContent^>
{
public:
MyTextureImporter() {}
public:
virtual TextureContent^ Import(String^ filename, ContentImporterContext^ context) override
{
Texture2DContent^ texture = gcnew Texture2DContent();
// TODO: Load bitmap from filename
BitmapContent^ bitmap = gcnew PixelBitmapContent<Color>(100,100);
texture->Mipmaps->Add(bitmap);
return texture;
}
};
}
References...
C:\Program Files\Microsoft XNA\XNA Game Studio\v3.1\References\Windows\x86\Microsoft.Xna.Framework.dll
C:\Program Files\Microsoft XNA\XNA Game Studio\v3.1\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.dll
Add > New Project > Visual C# > XNA Game Studio 3.1 > Windows Game (3.1)
WindowsGame1
Content > Add Reference... > Projects > MyImporter
Build Solution: build succeeded
Now I add a file Winter.foo to the Content project, build:
------ Build started: Project: WindowsGame1, Configuration: Debug x86 ------
Building Winter.foo -> C:\Documents and Settings\kselden\My Documents\Visual Studio 2008\Projects\Solution1\WindowsGame1\bin\x86\Debug\Content\Winter.xnb
Content\Winter.foo : error : Cannot find importer "MyTextureImporter".
Done building project "Content.contentproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
The above example seems so minimal I can't imagine what step I'm missing. I'm hoping that Shawn or someone can just provide a basic skeleton for an importer with c++/cli. I suppose I could revert to P/Invoke but I'd rather not.
There also doesn't seem to be a great way to debug the content build process.
Thanks in advance,
Kris