- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我已将 1-1 这段代码从 C++/OpenGL 移植到 C# SharpGL:
float[] cameraAngle = { 0, 0, 0 };
float[] cameraPosition = { 0, 0, 10 };
float[] modelPosition = { 0, 0, 0 };
float[] modelAngle = { 0, 0, 0 };
float[] matrixView = new float[16];
float[] matrixModel = new float[16];
float[] matrixModelView = new float[16];
// clear buffer
gl.ClearColor(0.1f, 0.1f, 0.1f, 1);
gl.Clear(OpenGL.COLOR_BUFFER_BIT | OpenGL.DEPTH_BUFFER_BIT | OpenGL.STENCIL_BUFFER_BIT);
// initialze ModelView matrix
gl.PushMatrix();
gl.LoadIdentity();
// ModelView matrix is product of viewing matrix and modeling matrix
// ModelView_M = View_M * Model_M
// First, transform the camera (viewing matrix) from world space to eye space
// Notice all values are negated, because we move the whole scene with the
// inverse of camera transform
gl.Rotate(-cameraAngle[0], 1, 0, 0); // pitch
gl.Rotate(-cameraAngle[1], 0, 1, 0); // heading
gl.Rotate(-cameraAngle[2], 0, 0, 1); // roll
gl.Translate(-cameraPosition[0], -cameraPosition[1], -cameraPosition[2]);
// we have set viewing matrix upto this point. (Matrix from world space to eye space)
// save the view matrix only
gl.GetFloat(OpenGL.MODELVIEW_MATRIX, matrixView); // save viewing matrix
//=========================================================================
// always Draw the grid at the origin (before any modeling transform)
//DrawGrid(10, 1);
// In order to get the modeling matrix only, reset OpenGL.MODELVIEW matrix
gl.LoadIdentity();
// transform the object
// From now, all transform will be for modeling matrix only. (transform from object space to world space)
gl.Translate(modelPosition[0], modelPosition[1], modelPosition[2]);
gl.Rotate(modelAngle[0], 1, 0, 0);
gl.Rotate(modelAngle[1], 0, 1, 0);
gl.Rotate(modelAngle[2], 0, 0, 1);
// save modeling matrix
gl.GetFloat(OpenGL.MODELVIEW_MATRIX, matrixModel);
//=========================================================================
// re-strore OpenGL.MODELVIEW matrix by multiplying matrixView and matrixModel before drawing the object
// ModelView_M = View_M * Model_M
gl.LoadMatrixf(matrixView); // Mmv = Mv
gl.MultMatrixf(matrixModel); // Mmv *= Mm
// save ModelView matrix
gl.GetFloat(OpenGL.MODELVIEW_MATRIX, matrixModelView);
//=========================================================================
// Draw a teapot after ModelView transform
// v' = Mmv * v
//DrawAxis(4);
//DrawTeapot();
gl.PopMatrix();
看起来不像是 ModelView 矩阵相乘,结果是单位矩阵!
有什么问题吗??
谢谢
最佳答案
错误的 glMatrixMode?
关于c# - SharpGL 疯狂,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1407759/
我已将 1-1 这段代码从 C++/OpenGL 移植到 C# SharpGL: float[] cameraAngle = { 0, 0, 0 }; float[] cameraPo
有人在 SharpGL 中使用过几何着色器吗?我不知道如何在我的代码中完成它。正如我所见,ShaderProgram 随 SharpGL.Shaders 一起提供的方法 Create 仅采用 Vert
我正在使用 SharpGL 库在 WPF 中实现一个二维图形。我设法在屏幕上绘制了一些原始对象,我需要检测这些对象上的鼠标点击。 我看过一个关于如何对图形对象执行选择和拾取的 OpenGL 教程,但我
我即将开始一个新项目。有些决定是我无法控制的:使用 WPF 和 OpenGL 就是其中一些。 但是,我已将 OpenGL 选项缩小到两个:OpenTK 或 SharpGL。 SharpGL 有一个 W
我正在尝试使用 sharpgl 在 C# 中画线,但是当我编译代码时,它给我的控制台充满了白色而不是线,如何解决这个问题或者我的代码中是否有任何错误。这是代码。 private static int
我正在尝试使用 VBO 绘制一些简单的东西,例如三角形。 github 上提供了示例代码: https://github.com/dwmkerr/sharpgl/blob/master/source/
目前我一直在制作 C#-WPF-OpenGL 应用程序。我跟着这个http://www.codeproject.com/Articles/265903/Using-OpenGL-in-a-WPF-Ap
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 7 年前。 Improve
我是一名优秀的程序员,十分优秀!