Style fixes for Renderer.Cg.
This commit is contained in:
@@ -13,8 +13,6 @@ using System.Drawing;
|
||||
using OpenRA.FileFormats.Graphics;
|
||||
using OpenRA.Renderer.SdlCommon;
|
||||
using Tao.Cg;
|
||||
using Tao.OpenGl;
|
||||
using Tao.Sdl;
|
||||
|
||||
[assembly: Renderer(typeof(OpenRA.Renderer.Cg.DeviceFactory))]
|
||||
|
||||
@@ -31,7 +29,7 @@ namespace OpenRA.Renderer.Cg
|
||||
|
||||
public class GraphicsDevice : SdlGraphics
|
||||
{
|
||||
static string[] RequiredExtensions =
|
||||
static string[] requiredExtensions =
|
||||
{
|
||||
"GL_ARB_vertex_program",
|
||||
"GL_ARB_fragment_program",
|
||||
@@ -39,10 +37,10 @@ namespace OpenRA.Renderer.Cg
|
||||
"GL_EXT_framebuffer_object"
|
||||
};
|
||||
|
||||
internal IntPtr cgContext;
|
||||
internal int vertexProfile, fragmentProfile;
|
||||
internal IntPtr Context;
|
||||
internal int VertexProfile, FragmentProfile;
|
||||
|
||||
static Tao.Cg.Cg.CGerrorCallbackFuncDelegate CgErrorCallback = () =>
|
||||
static Tao.Cg.Cg.CGerrorCallbackFuncDelegate errorCallback = () =>
|
||||
{
|
||||
var err = Tao.Cg.Cg.cgGetError();
|
||||
var msg = "CG Error: {0}: {1}".F(err, Tao.Cg.Cg.cgGetErrorString(err));
|
||||
@@ -51,16 +49,16 @@ namespace OpenRA.Renderer.Cg
|
||||
};
|
||||
|
||||
public GraphicsDevice(Size size, WindowMode window)
|
||||
: base(size, window, RequiredExtensions)
|
||||
: base(size, window, requiredExtensions)
|
||||
{
|
||||
cgContext = Tao.Cg.Cg.cgCreateContext();
|
||||
Context = Tao.Cg.Cg.cgCreateContext();
|
||||
|
||||
Tao.Cg.Cg.cgSetErrorCallback(CgErrorCallback);
|
||||
Tao.Cg.Cg.cgSetErrorCallback(errorCallback);
|
||||
|
||||
Tao.Cg.CgGl.cgGLRegisterStates(cgContext);
|
||||
Tao.Cg.CgGl.cgGLSetManageTextureParameters(cgContext, true);
|
||||
vertexProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_VERTEX);
|
||||
fragmentProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_FRAGMENT);
|
||||
Tao.Cg.CgGl.cgGLRegisterStates(Context);
|
||||
Tao.Cg.CgGl.cgGLSetManageTextureParameters(Context, true);
|
||||
VertexProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_VERTEX);
|
||||
FragmentProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_FRAGMENT);
|
||||
}
|
||||
|
||||
public override IShader CreateShader(string name) { return new Shader(this, name); }
|
||||
|
||||
@@ -28,12 +28,12 @@ namespace OpenRA.Renderer.Cg
|
||||
string code;
|
||||
using (var file = new StreamReader(FileSystem.Open("cg{0}{1}.fx".F(Path.DirectorySeparatorChar, name))))
|
||||
code = file.ReadToEnd();
|
||||
effect = Tao.Cg.Cg.cgCreateEffect(dev.cgContext, code, null);
|
||||
effect = Tao.Cg.Cg.cgCreateEffect(dev.Context, code, null);
|
||||
|
||||
if (effect == IntPtr.Zero)
|
||||
{
|
||||
var err = Tao.Cg.Cg.cgGetErrorString(Tao.Cg.Cg.cgGetError());
|
||||
var results = Tao.Cg.Cg.cgGetLastListing(dev.cgContext);
|
||||
var results = Tao.Cg.Cg.cgGetLastListing(dev.Context);
|
||||
throw new InvalidOperationException(
|
||||
"Cg compile failed ({0}):\n{1}".F(err, results));
|
||||
}
|
||||
@@ -51,8 +51,8 @@ namespace OpenRA.Renderer.Cg
|
||||
|
||||
public void Render(Action a)
|
||||
{
|
||||
Tao.Cg.CgGl.cgGLEnableProfile(dev.vertexProfile);
|
||||
Tao.Cg.CgGl.cgGLEnableProfile(dev.fragmentProfile);
|
||||
Tao.Cg.CgGl.cgGLEnableProfile(dev.VertexProfile);
|
||||
Tao.Cg.CgGl.cgGLEnableProfile(dev.FragmentProfile);
|
||||
|
||||
var pass = Tao.Cg.Cg.cgGetFirstPass(technique);
|
||||
while (pass != IntPtr.Zero)
|
||||
@@ -63,8 +63,8 @@ namespace OpenRA.Renderer.Cg
|
||||
pass = Tao.Cg.Cg.cgGetNextPass(pass);
|
||||
}
|
||||
|
||||
Tao.Cg.CgGl.cgGLDisableProfile(dev.fragmentProfile);
|
||||
Tao.Cg.CgGl.cgGLDisableProfile(dev.vertexProfile);
|
||||
Tao.Cg.CgGl.cgGLDisableProfile(dev.FragmentProfile);
|
||||
Tao.Cg.CgGl.cgGLDisableProfile(dev.VertexProfile);
|
||||
}
|
||||
|
||||
public void SetTexture(string name, ITexture t)
|
||||
@@ -95,7 +95,7 @@ namespace OpenRA.Renderer.Cg
|
||||
if (param == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
switch(length)
|
||||
switch (length)
|
||||
{
|
||||
case 1: Tao.Cg.CgGl.cgGLSetParameter1fv(param, vec); break;
|
||||
case 2: Tao.Cg.CgGl.cgGLSetParameter2fv(param, vec); break;
|
||||
|
||||
Reference in New Issue
Block a user