首页 \ 问答 \ 如何使用VBO使用OpenGL(特别是LWJGL)绘制一个圆(How to draw a circle with OpenGL(LWJGL specifically) using VBOs)

如何使用VBO使用OpenGL(特别是LWJGL)绘制一个圆(How to draw a circle with OpenGL(LWJGL specifically) using VBOs)

我目前正在学习LWJGL(LightWeight Java游戏库),OpenGL-Java端口,我正在试图弄清楚如何使用VBO绘制一个圆圈。

当我搜索有关我的问题的代码示例时(我搜索OpenGL b / c,OpenGL和LWJGL的语法非常相似),我发现所有人都使用glBegin(GL_QUADS)等等,由于它的差,我不喜欢表现及其不足。 我知道它使用像Math.PI这样的东西(我采用几何学,数学并不是我认为的难点)。

我想知道如何获得从使用Math.cosMath.sin到VBO中获得的X和Y值,使用glDrawArrays时b / c,你必须指定顶点的数量。


I am currently learning LWJGL(LightWeight Java Game Library), the OpenGL-Java port, and am trying to figure out how to draw a circle using VBOs.

When I search for code samples concerning my problem (I search OpenGL b/c the syntax of OpenGL & LWJGL are quite similar), all I find is people using glBegin(GL_QUADS) and such, which I don't like due to its poor performance and its insufficiency. I know it uses thing like Math.PI and such(I've taken Geometry, the math is not the hard part in my opinion).

I want to know how I would get the X and Y values I receive from using Math.cos & Math.sin into the VBO, b/c when using glDrawArrays, you have to specify the number of vertices.


原文:https://stackoverflow.com/questions/23635749
更新时间:2022-04-17 10:04

最满意答案

更新您的模式以使用属性,然后只有MVC 模型绑定才有效

public class Testing
{
    public int a = 0;
    public string name { get; set;} 
    public string age { get; set;} 
}

Update your mode to use properties, then only MVC model binding will work

public class Testing
{
    public int a = 0;
    public string name { get; set;} 
    public string age { get; set;} 
}

相关问答

更多
  • 看起来你需要在这里稍微移动一下。 我对你想要达到的目标做了一些假设,但是 (Repository.cs) public class AppRespository { private DataContext db = new DataContext(); public IEnumerable LoadStates() { var query = from d in db.States.ToList() ...
  • 如上所示: ASP.NET MVC 4 - for循环发布模型集合属性,但foreach没有 MVC助手讨厌foreach循环。 转到for循环,一切都应该正常工作。 编写两个循环并使用Web开发人员工具检查它们,以查看“id”和“name”属性的差异。 As seen on here: ASP.NET MVC 4 - for loop posts model collection properties but foreach does not MVC helpers hate foreach loops. ...
  • 那是因为您没有使用包含其属于List的信息的表达式来访问每个CustomerCDTO 。 改为使用for循环: <%for (var i = 0; i < Model.customerCDTO.Count; ++i) 并参考带有表达式的元素 <%=Html.CheckBoxFor(m => m.customerCDTO[i].Active)%> 基本上你需要将表达式m => ...解析为你感兴趣的属性,从m开始,而不是从其他变量开始。 That's because you are not getting ...
  • 更新您的模式以使用属性,然后只有MVC 模型绑定才有效 public class Testing { public int a = 0; public string name { get; set;} public string age { get; set;} } Update your mode to use properties, then only MVC model binding will work public class Testing { public ...
  • 这是您的ProductsVM : public class ProductsVM { public IList items { get; set; } public IList categories { get; set; } } 这是您要发布的操作方法: [HttpPost] public ActionResult Products(ProductsVM model) 当您提交表单时,它将从表单的控件中获取值并使用控件的名称,它会将它们发布到Produc ...
  • 我会更改您的模型集合以使用能够进行模型绑定的List属性。 举个例子: public List AllRows { get; set; } 然后将循环更改为此模型绑定器将拾取的循环。 @for (int i = 0; i < Model.AllRows.Count; i++) { ..... @Html.EditorFor(model => Model.AllRows[i].Heading) ..... } ...
  • 您将需要另一个单独的控制器操作来检查数据存储并返回ContentResult ,该操作将为true或false (或者您想要判断ID是否包含字节的其他字符串),然后在视图中您将需要: if(@Html.Action("action", "controller").ToString().Equals("true", StringComparison.OrdinalIgnoreCase)){ // render image tag with the call to the other action that r ...
  • @Html.HiddenFor呈现一个 。 因此,如果要发布复杂对象,请确保为该对象的所有属性渲染隐藏字段,并将其回发。 我不知道你的Area对象是怎样的,但是沿着这些方向: @model CurrentArea @* post back the properties of CurrentArea.area we are interested in *@ @Html.HiddenFor(m => m.area.Name) @Html.HiddenFor(m = ...
  • 在尝试访问其属性之前,必须测试模型对象是否为null。 喜欢这个: var isObjectNotnull = @(Model != null && Model.InnerClass != null); 但是,假设Model.InnerClass不为null,这将呈现如下: var isObjectNotnull = True; 并且您将在javascript中收到以下错误,因为“True”中的mayus“T”字母将使浏览器将其视为变量而不是true关键字: 未捕获的ReferenceError:未定 ...
  • 这段代码: @Model.OutputEmail 引用传递给视图的模型实例。 但是, 这段代码: @Html.LabelFor(x => x.OutputEmail) 不引用模型的实际实例。 它反映了模型的类型并生成了针对该类型的标记。 因此,如果您没有将模型传递给视图,那么第一行将失败,因为模型的实例为null ,但第二行将成功,因为模型的类型仍然是已知的。 This code: @Model.OutputEmail references the instance of the model pass ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)