コード例 #1
0
ファイル: Form1.cs プロジェクト: KiwiPapa/some_c_projects
        private void FormMain_Load(object sender, EventArgs e)
        {
            var     position = new vec3(5, 3, 4) * 0.3f;
            var     center = new vec3(0, 0, 0);
            var     up = new vec3(0, 1, 0);
            var     camera = new Camera(position, center, up, CameraType.Perspective, this.winGLCanvas1.Width, this.winGLCanvas1.Height);
            Texture texture0, texture1, texture2;

            GetTextures(out texture0, out texture1, out texture2);
            texture0.TextureUnitIndex = 0; // glActiveTexture(GL_TEXTURE0 + 0); glBindTexture(GL_TEXTURE_2D, texture0.TextureId);
            texture1.TextureUnitIndex = 0; // glActiveTexture(GL_TEXTURE0 + 0); glBindTexture(GL_TEXTURE_1D, texture1.TextureId);
            texture2.TextureUnitIndex = 1; // glActiveTexture(GL_TEXTURE0 + 1); glBindTexture(GL_TEXTURE_2D, texture2.TextureId);
            this.cubeNode             = CubeNode.Create(texture0, texture1, texture2);
            var scene = new Scene(camera);

            scene.RootNode = cubeNode;
            this.scene     = scene;

            var list            = new ActionList();
            var transformAction = new TransformAction(scene);

            list.Add(transformAction);
            var renderAction = new RenderAction(scene);

            list.Add(renderAction);
            this.actionList = list;

            //// uncomment these lines to enable manipualter of camera!
            //var manipulater = new FirstPerspectiveManipulater();
            //manipulater.BindingMouseButtons = System.Windows.Forms.MouseButtons.Right;
            //manipulater.Bind(camera, this.winGLCanvas1);
        }
コード例 #2
0
        public static CubeNode Create(Texture texture0, Texture texture1, Texture texture2)
        {
            // vertex buffer and index buffer.
            var model = new CubeModel();
            // vertex shader and fragment shader.
            var vs    = new VertexShader(vertexCode);
            var fs    = new FragmentShader(fragmnetCode);
            var array = new ShaderArray(vs, fs);
            // which vertex buffer maps to which attribute in shader.
            var map = new AttributeMap();

            map.Add("inPosition", CubeModel.strPosition);
            map.Add("inTexCoord", CubeModel.strTexCoord);
            // build a render method.
            var builder = new RenderMethodBuilder(array, map);
            // create node.
            var node = new CubeNode(model, builder);

            node.SetTextures(texture0, texture1, texture2);
            // initialize node.
            node.Initialize();

            return(node);
        }