Esempio n. 1
0
 public RenderSurface4Part(int _width, int _height, Renderer rendering)
 {
     Rendering = rendering;
     Width = _width;
     Height = _height;
     GL.GenFramebuffers(1, out fbo);
     GL.BindFramebuffer(FramebufferTarget.Framebuffer, fbo);
     GL.GenTextures(1, out DiffuseTexture);
     GL.BindTexture(TextureTarget.Texture2D, DiffuseTexture);
     GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, Width, Height, 0, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (uint)TextureMinFilter.Linear);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (uint)TextureMagFilter.Linear);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (uint)TextureWrapMode.ClampToEdge);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (uint)TextureWrapMode.ClampToEdge);
     GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D, DiffuseTexture, 0);
     GL.GenTextures(1, out PositionTexture);
     GL.BindTexture(TextureTarget.Texture2D, PositionTexture);
     GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba32f, Width, Height, 0, PixelFormat.Rgba, PixelType.Float, IntPtr.Zero);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (uint)TextureMinFilter.Linear);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (uint)TextureMagFilter.Linear);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (uint)TextureWrapMode.ClampToEdge);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (uint)TextureWrapMode.ClampToEdge);
     GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment1, TextureTarget.Texture2D, PositionTexture, 0);
     GL.GenTextures(1, out NormalsTexture);
     GL.BindTexture(TextureTarget.Texture2D, NormalsTexture);
     GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba16f, Width, Height, 0, PixelFormat.Rgba, PixelType.Float, IntPtr.Zero);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (uint)TextureMinFilter.Linear);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (uint)TextureMagFilter.Linear);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (uint)TextureWrapMode.ClampToEdge);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (uint)TextureWrapMode.ClampToEdge);
     GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment2, TextureTarget.Texture2D, NormalsTexture, 0);
     GL.GenTextures(1, out DepthTexture);
     GL.BindTexture(TextureTarget.Texture2D, DepthTexture);
     GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.DepthComponent32, Width, Height, 0, PixelFormat.DepthComponent, PixelType.Float, IntPtr.Zero);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (uint)TextureMinFilter.Linear);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (uint)TextureMagFilter.Linear);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (uint)TextureWrapMode.ClampToEdge);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (uint)TextureWrapMode.ClampToEdge);
     GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.DepthAttachment, TextureTarget.Texture2D, DepthTexture, 0);
     GL.GenTextures(1, out RenderhintTexture);
     GL.BindTexture(TextureTarget.Texture2D, RenderhintTexture);
     GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba16f, Width, Height, 0, PixelFormat.Rgba, PixelType.Float, IntPtr.Zero);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (uint)TextureMinFilter.Linear);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (uint)TextureMagFilter.Linear);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (uint)TextureWrapMode.ClampToEdge);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (uint)TextureWrapMode.ClampToEdge);
     GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment3, TextureTarget.Texture2D, RenderhintTexture, 0);
     GL.GenTextures(1, out Rh2Texture);
     GL.BindTexture(TextureTarget.Texture2D, Rh2Texture);
     GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba16f, Width, Height, 0, PixelFormat.Rgba, PixelType.Float, IntPtr.Zero);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (uint)TextureMinFilter.Linear);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (uint)TextureMagFilter.Linear);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (uint)TextureWrapMode.ClampToEdge);
     GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (uint)TextureWrapMode.ClampToEdge);
     GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment4, TextureTarget.Texture2D, Rh2Texture, 0);
     GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
 }
Esempio n. 2
0
 /// <summary>
 /// Called when the window is loading, only to be used by the startup process.
 /// </summary>
 void Window_Load(object sender, EventArgs e)
 {
     SysConsole.Output(OutputType.INIT, "Window generated!");
     DPIScale = Window.Width / CVars.r_width.ValueF;
     SysConsole.Output(OutputType.INIT, "DPIScale is " + DPIScale + "!");
     SysConsole.Output(OutputType.INIT, "Loading base textures...");
     PreInitRendering();
     Textures = new TextureEngine();
     Textures.InitTextureSystem(this);
     ItemFrame = Textures.GetTexture("ui/hud/item_frame");
     SysConsole.Output(OutputType.INIT, "Loading shaders...");
     Shaders = new ShaderEngine();
     GLVendor = GL.GetString(StringName.Vendor);
     CVars.s_glvendor.Value = GLVendor;
     GLVersion = GL.GetString(StringName.Version);
     CVars.s_glversion.Value = GLVersion;
     GLRenderer = GL.GetString(StringName.Renderer);
     CVars.s_glrenderer.Value = GLRenderer;
     SysConsole.Output(OutputType.INIT, "Vendor: " + GLVendor + ", GLVersion: " + GLVersion + ", Renderer: " + GLRenderer);
     if (GLVendor.ToLowerFast().Contains("intel"))
     {
         SysConsole.Output(OutputType.INIT, "Disabling good graphics (Appears to be Intel: '" + GLVendor + "')");
         Shaders.MCM_GOOD_GRAPHICS = false;
     }
     Shaders.InitShaderSystem(this);
     View3D.CheckError("Load - Shaders");
     SysConsole.Output(OutputType.INIT, "Loading rendering helper...");
     Rendering = new Renderer(Textures, Shaders);
     Rendering.Init();
     SysConsole.Output(OutputType.INIT, "Preparing load screen...");
     Texture load_screen = Textures.GetTexture("ui/menus/loadscreen");
     load_screen.Bind();
     Shaders.ColorMultShader.Bind();
     Establish2D();
     Rendering.RenderRectangle(0, 0, Window.Width, Window.Height);
     Window.SwapBuffers();
     SysConsole.Output(OutputType.INIT, "Loading block textures...");
     TBlock = new TextureBlock();
     TBlock.Generate(this, CVars, Textures);
     View3D.CheckError("Load - Textures");
     SysConsole.Output(OutputType.INIT, "Loading fonts...");
     Fonts = new GLFontEngine(Shaders);
     Fonts.Init(this);
     FontSets = new FontSetEngine(Fonts);
     FontSets.Init(this);
     View3D.CheckError("Load - Fonts");
     SysConsole.Output(OutputType.INIT, "Loading animation engine...");
     Animations = new AnimationEngine();
     SysConsole.Output(OutputType.INIT, "Loading model engine...");
     Models = new ModelEngine();
     Models.Init(Animations, this);
     SysConsole.Output(OutputType.INIT, "Loading general graphics settings...");
     CVars.r_vsync.OnChanged += onVsyncChanged;
     onVsyncChanged(CVars.r_vsync, null);
     CVars.r_cloudshadows.OnChanged += onCloudShadowChanged;
     View3D.CheckError("Load - General Graphics");
     SysConsole.Output(OutputType.INIT, "Loading UI engine...");
     UIConsole.InitConsole(); // TODO: make this non-static
     InitChatSystem();
     View3D.CheckError("Load - UI");
     SysConsole.Output(OutputType.INIT, "Preparing rendering engine...");
     InitRendering();
     View3D.CheckError("Load - Rendering");
     SysConsole.Output(OutputType.INIT, "Loading particle effect engine...");
     Particles = new ParticleHelper(this) { Engine = new ParticleEngine(this) };
     SysConsole.Output(OutputType.INIT, "Preparing mouse, keyboard, and gamepad handlers...");
     KeyHandler.Init();
     GamePadHandler.Init();
     View3D.CheckError("Load - Keyboard/mouse");
     SysConsole.Output(OutputType.INIT, "Building the sound system...");
     Sounds = new SoundEngine();
     Sounds.Init(this, CVars);
     View3D.CheckError("Load - Sound");
     SysConsole.Output(OutputType.INIT, "Building game world...");
     BuildWorld();
     View3D.CheckError("Load - World");
     SysConsole.Output(OutputType.INIT, "Preparing networking...");
     Network = new NetworkBase(this);
     RegisterDefaultEntityTypes();
     View3D.CheckError("Load - Net");
     SysConsole.Output(OutputType.INIT, "Playing background music...");
     BackgroundMusic();
     CVars.a_musicvolume.OnChanged += onMusicVolumeChanged;
     CVars.a_musicpitch.OnChanged += onMusicPitchChanged;
     CVars.a_music.OnChanged += onMusicChanged;
     CVars.a_echovolume.OnChanged += OnEchoVolumeChanged;
     OnEchoVolumeChanged(null, null);
     SysConsole.Output(OutputType.INIT, "Setting up screens...");
     TheMainMenuScreen = new MainMenuScreen(this);
     TheGameScreen = new GameScreen(this);
     TheSingleplayerMenuScreen = new SingleplayerMenuScreen(this);
     SysConsole.Output(OutputType.INIT, "Preparing inventory...");
     InitInventory();
     SysConsole.Output(OutputType.INIT, "Showing main menu...");
     ShowMainMenu();
     SysConsole.Output(OutputType.INIT, "Trying to grab RawGamePad...");
     try
     {
         RawGamePad = new XInput();
     }
     catch (Exception ex)
     {
         SysConsole.Output(OutputType.INIT, "Failed to grab RawGamePad: " + ex.Message);
     }
     View3D.CheckError("Load - Final");
     SysConsole.Output(OutputType.INIT, "Ready and looping!");
 }