- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试使用这个 GLWidget 来使用 OpenTK 和 GTK# 进行开发,这似乎是一件好事,但遗憾的是几乎没有关于它的文档。我试图了解如何在该小部件中呈现任何内容。到目前为止,我创建了一个 modevelop 解决方案,添加了对 OpenTK 和 GLWidget 的引用,现在我在 Stetic 的工具 Pane 中看到了 GLWidget,我添加了一个带有两个插槽的 Vbox,在上面的那个我添加了一个菜单栏,在下面的那个著名的 GLWidget。我还为 OnRender 事件和 Initialized 事件创建了事件处理程序,但我什至无法绘制三角形。有没有人曾经使用过 GLWidget 并且可以给我一些建议?这是我的 MainWindow.cs 代码:
using System;
using Gtk;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Audio;
using OpenTK.Audio.OpenAL;
using OpenTK.Input;
public partial class MainWindow : Gtk.Window{
public MainWindow () : base(Gtk.WindowType.Toplevel)
{
Build ();
}
protected void GLWidgetInitialize (object sender, System.EventArgs e)
{
int width = 0, height = 0;
//glwidget7.GdkWindow.GetSize(out width, out height);
this.vbox3.GetSizeRequest(out width, out height);
GL.Viewport(0, 0, width, height);
GL.ClearColor(1.0f, 1.0f,1.0f,1.0f);
GL.Clear(ClearBufferMask.ColorBufferBit);
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
a.RetVal = true;
}
protected void OnRenderFrameWidget (object sender, System.EventArgs e)
{
GL.ClearColor(1.0f, 1.0f,1.0f,1.0f);
GL.Begin(BeginMode.Triangles);
GL.Color3(1.0f, 1.0f, 0.0f); GL.Vertex3(-1.0f, -1.0f, 4.0f);
GL.Color3(1.0f, 0.0f, 0.0f); GL.Vertex3(1.0f, -1.0f, 4.0f);
GL.Color3(0.2f, 0.9f, 1.0f); GL.Vertex3(0.0f, 1.0f, 4.0f);
GL.End();
}
顺便说一句,更改 GLClearColor 值确实会使我的 GLWidget 更改背景颜色。
最佳答案
好吧,我终于让它工作了,MainWindow 代码应该是这样的:
public partial class MainWindow : Gtk.Window
{
public bool GLinit;
public MainWindow () : base(Gtk.WindowType.Toplevel)
{
Build ();
GLinit = false;
}
protected virtual void GLWidgetInitialize (object sender, System.EventArgs e)
{
//this might be overkill to some people, but worked for me
int width = 0, height = 0;
this.vbox3.GetSizeRequest(out width, out height);
float aspectRatio = width/ height;
GL.Viewport(0, 0, width, height);
GL.ClearColor(1.0f, 1.0f,1.0f,1.0f);
GL.Clear(ClearBufferMask.ColorBufferBit);
GL.MatrixMode(MatrixMode.Modelview);
GL.LoadIdentity();
GL.ShadeModel(ShadingModel.Smooth);
Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView((float)Math.PI / 4, aspectRatio, 1.0f, 64.0f);
GL.MatrixMode(MatrixMode.Projection);
GL.LoadMatrix(ref projection);
GL.ClearDepth(1);
GL.Disable(EnableCap.DepthTest);
GL.Enable(EnableCap.Texture2D);
GL.Enable(EnableCap.Blend);
GL.DepthFunc(DepthFunction.Always);
GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);
//add idle event handler to process rendering whenever and as long as time is availble.
GLinit = true;
GLib.Idle.Add(new GLib.IdleHandler(OnIdleProcessMain));
}
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
Application.Quit ();
a.RetVal = true;
}
protected void RenderFrame(){
//Here's where you write your OpenGL code to draw whatever you want
//Don't forget to swap your buffers
OpenTK.Graphics.GraphicsContext.CurrentContext.SwapBuffers();
}
protected bool OnIdleProcessMain ()
{
if (!GLinit) return false;
else{
RenderFrame();
return true;
}
}
}
有关详细信息,请参见此处:http://www.opentk.com/node/2910 (已存档)
关于c# - 如何在 Monodevelop 中使用 OpenTK GLWidget 进行渲染?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9778875/
在我将 MonoDevelop IDE 更新到最新版本 3.0.1 后,不再检测到我的 Monobjc 项目。我尝试重新安装 Monobjc,但未安装加载项,因为它们仅支持 MonoDevelop 2
我不知道它是怎么发生的,但是当我启动 Monodevelop 时,菜单突然以英语以外的语言出现。我尝试重新安装应用程序以及手动删除库下其他目录中的工件。没运气。重新安装后,它仍然以另一种语言加载。 最
MonoDevelop 中是否有任何方法可以创建您自己的代码片段,即可重用的代码?我知道在工具箱中你可以得到其他人的,但我似乎无法找到一种方法来添加我自己的东西。当然,我对 Monodevelop 还
我在 Mac 上使用 MonoDevelop 编写 MonoTouch 应用程序。当我打字时,Automatica 代码缩进/格式化效果很好。 问题是,当我复制和粘贴代码片段时,在很多情况下我会丢失格
我的任务列表板充满了旧的//Todo 注释任务,这些任务已从代码中解析出来。不幸的是,他们引用的文件早已消失,任务像僵尸一样徘徊。删除每个任务只会引发文件丢失的错误。如何手动强制完全清除任务列表以便它
我在哪里可以看到 MonoDevelop 中的 System.Diagnostics.Debug 和 System.Diagnostics.Trace 输出?我认为它应该出现在 Application
MonoDevelop 为每个项目创建这些。我应该将它们包含在源代码管理中吗? 最佳答案 来自MonoDevelop blog post : There were several long time
有谁知道是否可以设置运行您在 monodevelop 中创建的应用程序的工作目录? 应用程序被写入 bin/Debug 目录,这似乎是您调试应用程序时的工作目录。对于我的应用程序(我正在从 Windo
我想在 MonoDevelop 2.0(在 Ubuntu 下)中创建一些自定义模板,但我发现这个过程并不像我想要的那样直观。有谁知道模板存储在哪里?采用什么格式? 善良, 丹 最佳答案 在 MD 2.
题目说明了一切。我在 monodevelop 网站或通过谷歌找不到任何信息。 偶加System.Diagnostics.Debugger.Break()并运行 mono --debug MonoDev
我有 Ubuntu 12.04、MonoDevelop 2.8 和一些 valac .我知道 MD 支持 Vala 语言,但实际上我没有看到对 Vala 的任何支持。如果从头开始制作 C 解决方案,则
我正在尝试在 linux 上进行单声道开发,但是尝试创建一个包,给我错误无法获得 C# 编译器。找不到用于 Mono/.NET 3.5 的 C# 编译器。 我假设编译器是用 monodevelop 安
您可以将 MSpec 与 MonoDevelop 测试运行器集成吗?它是 working in Sharp-Develop .谷歌说'nothing ' 所以我猜在当前版本(2.8.2)中这是不可能的
右键单击(或按住 Control 单击,因为我使用的是 Mac)不会显示解决方案或项目的上下文菜单。 例如,在 Visual Studio 中,我会右键单击解决方案以将新项目添加到解决方案中。我已经查
阅读Using NuGet without committing packages to source control我明白我应该添加 .nuget文件夹到我的项目以在构建期间启用包还原...并阅读
我尝试将 Visual Studio 2012 csproj 文件导入 Monodevelop。一切正常,直到我编译。当我编译项目时,它为第一个表单生成 1 *.resources 文件,但对于以下表
我正在尝试在 Monodevelop for Mac 上安装 Monocross Framework。步骤应该是:1. 启动MonoDevelop。2. 在 MonoDevelop 中,选择 Tool
我想使用一些 GUI 对象来输出一些表的信息(此信息是只读的)。 Windows 窗体中有 DataGrid 和 DataGridView,但我找不到相同的 GTK# 类似物。谁能告诉我可以使用什么
在 Windows 上,我安装了 MonoDevlop 并尝试编译需要 Mono.Data.SQLiteClient 引用的 SQLite 示例。我在 MonoDevelop 中打开了“编辑引用”,除
我从 GitHub 得到了一个大项目,我正在尝试编译,但这些错误让我抓狂: Error CS0219: Warning as Error: The variable `memberInfo' is a
我是一名优秀的程序员,十分优秀!