Tangeleno's picture

Resetting colors

I'm new to OpenTK so I know I'm not doing something I need to to get this to work properly and I'm completely at a loss as to what. But when I draw my mesh with a texture on it everything is fine until I then draw a voxelized, untextured, colored version over top of it. The voxelized mesh displays properly but when I toggle the voxelized mesh off my original mesh is colored as the last color used while drawing the voxelized mesh. And incase that made no sense, here are some pictures that show what I mean. http://imgur.com/a/yczVL#0

And code snippets of the involved pieces.

The code to draw the Original mesh... Called every OnRenderFrame
http://privatepaste.com/eee926994c#

And the code to draw the Voxelized Mesh... Called when the user toggles it on.

http://privatepaste.com/88c6517ff7

And if it's needed my OnRenderFrame()

 protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Disable(EnableCap.Texture2D);
 
 
            GL.Light(LightName.Light0, LightParameter.Position,
                     new Vector4(_camera.ProjectionMatrix.Translation + _light0Direction));
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadMatrix(ref _camera.ProjectionMatrix);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadMatrix(ref _camera.ViewMatrix);
 
            if(_showMesh)
                _mesh.Draw(1);
            if(_showPolyMesh)
                _polyMesh.Draw(-1);
            if (_showHf)
                DrawVoxels(_hfVerts, _hfColors);
            if (_showChf)
                DrawVoxels(_chfVerts, _chfColors);
            SwapBuffers();
        }