首页 \ 问答 \ Android NDK暂停/恢复的hello-gl2示例是否正确?(Is hello-gl2 example from Android NDK pause/resume correct?)

Android NDK暂停/恢复的hello-gl2示例是否正确?(Is hello-gl2 example from Android NDK pause/resume correct?)

题:

考虑到Android NDK r6b的hello-gl2示例,当用户反复调用GLSurfaceView的暂停/恢复操作时,此示例是否正确? 我问,因为每次调用GL2JNIView.Renderer.onSurfaceChanged()时,它都会创建所有OpenGL资源(着色器,纹理)但它永远不会破坏它们。

背景:

我正在尝试调试一些使用C ++和JNI实现的OpenGL ES 2.0游戏,这些游戏在暂停/恢复期间表现不正确。 我试图找到一些参考示例,但我没有找到任何除了NDK提到的hello2-gl示例,可能恕我直言创建内存泄漏, 这个更复杂的版本,我目前正在使用,但是在GLSurfaceView完成其onPause()方法之前,似乎OpenGL上下文被破坏了,我正在销毁绑定到上下文的所有OpengGL着色器和纹理。 您能否指点我使用NDK在Android上使用OpenGL ES 2.0的一些真正正确的例子,关于暂停/恢复OpenGL资源处理的正确方法?

感谢您的帮助。


Question:

Considering the hello-gl2 example from Android NDK r6b, is this example correct when user repeatedly invokes pause/resume actions of the GLSurfaceView? I'm asking because each time a GL2JNIView.Renderer.onSurfaceChanged() is called, it creates all OpenGL resources (shaders, textures) but it never destroys them.

Background:

I'm trying to debug some OpenGL ES 2.0 game implemented using C++ and JNI which behaves incorrectly during pause/resume. I was trying to find some reference example for this but I haven't found any except of the mentioned hello2-gl example from NDK, which may IMHO create memory leaks, and this more complex version of it, which I'm currently using, but where it seems like OpenGL context is destroyed before GLSurfaceView finishes with its onPause() method where I'm destroying all the OpengGL shaders and textures bound to the context. Could you point me to some truly correct example of OpenGL ES 2.0 on Android using NDK concerning the correct way of pause/resume OpenGL resource handling?

Thank you for your help.


原文:https://stackoverflow.com/questions/8040149
更新时间:2021-12-02 20:12

最满意答案

您需要使用SqlDataReader ,然后启动循环以读取返回的值
假设ReceiptNO是文本字段,此示例将起作用

cn.Open()
Dim reader = da2.SelectCommand.ExecuteReader()
while reader.Read()
    textBox1.Text = reader("ReceiptNO").ToString()
End While

或者,如果您确定您的查询返回零或只有一条记录而您只对ReceiptNO字段感兴趣,那么您可以使用ExecuteScalar

Dim cmd = New SqlCommand("SELECT RecepitNO FROM Receipt WHERE (PaidFor=@PaidFor AND RegNO=@RegNO)")
cmd.Connection = cn
cmd.Parameters.Add("@paidFor", SqlDbType.VarChar).Value = cbMonth.Text
cmd.Parameters.Add("@RegNO", SqlDbType.Int).Value = lblRegNO.Text
cn.Open()
Dim result = cmd.ExecuteScalar()
if result IsNot Nothing Then
    textBox1.Text = result.ToString()
End If

这里有关于ExecuteScalar的MSDN文档


You need to use a SqlDataReader, and then start a loop to read the values returned
This example will work assuming the ReceiptNO is a text field

cn.Open()
Dim reader = da2.SelectCommand.ExecuteReader()
while reader.Read()
    textBox1.Text = reader("ReceiptNO").ToString()
End While

In alternative, if you are sure that your query returns zero or just one record and you are interested only in the ReceiptNO field, then you can use ExecuteScalar

Dim cmd = New SqlCommand("SELECT RecepitNO FROM Receipt WHERE (PaidFor=@PaidFor AND RegNO=@RegNO)")
cmd.Connection = cn
cmd.Parameters.Add("@paidFor", SqlDbType.VarChar).Value = cbMonth.Text
cmd.Parameters.Add("@RegNO", SqlDbType.Int).Value = lblRegNO.Text
cn.Open()
Dim result = cmd.ExecuteScalar()
if result IsNot Nothing Then
    textBox1.Text = result.ToString()
End If

Here the MSDN docs on ExecuteScalar

相关问答

更多
  • 简单的说就是 微软推出的【数据库软件】 Microsoft SQL Server SQL SQL是英文Structured Query Language的缩写,意思为结构化查询语言。SQL语言的主要功能就是同各种数据库建立联系,进行沟通。按照ANSI(美国国家标准协会)的规定,SQL被作为关系型数据库管理系统的标准语言。SQL语句可以用来执行各种各样的操作,例如更新数据库中的数据,从数据库中提取数据等。目前,绝大多数流行的关系型数据库管理系统,如Oracle, Sybase, Microsoft SQL S ...
  • 使用“编辑顶部200”选项,然后单击“显示SQL面板”,使用WHERE子句修改查询,然后执行查询。 您将能够编辑结果。 Use the "Edit top 200" option, then click on "Show SQL panel", modify your query with your WHERE clause, and execute the query. You'll be able to edit the results.
  • 启动SQL SERVER 2005,您可以这样做 USE AdventureWorks; GO WITH OrderedOrders AS ( SELECT SalesOrderID, OrderDate, ROW_NUMBER() OVER (ORDER BY OrderDate) AS 'RowNumber' FROM Sales.SalesOrderHeader ) SELECT * FROM OrderedOrders WHERE RowNumber BETWEEN ...
  • 使用+或CONCAT (从SQL Server 2012开始): USE [HRM_MVC_DEV_Test] GO UPDATE p SET FullName = FirstName + ' ' + LastName FROM [dbo].[ProjectWorkers] as p INNER JOIN [dbo].[Employees] as e ON e.EmployeeId = p.WorkerId GO 其他方式: SET FullName = CONCAT(FirstName,' ' ...
  • 您需要使用SqlDataReader ,然后启动循环以读取返回的值 假设ReceiptNO是文本字段,此示例将起作用 cn.Open() Dim reader = da2.SelectCommand.ExecuteReader() while reader.Read() textBox1.Text = reader("ReceiptNO").ToString() End While 或者,如果您确定您的查询返回零或只有一条记录而您只对ReceiptNO字段感兴趣,那么您可以使用ExecuteSca ...
  • 有四个版本的SQL Server(从SQL Server 2017起) - Enterprise,Standard,Web和Express(开发人员是Enterrpise,是免费的(有时有50美元的媒体费用,但不能在生产中使用)。 。 请参阅以下链接https://docs.microsoft.com/zh-cn/sql/reporting-services/reporting-services-features-supported-by-the-editions-of-sql-server-2016?vi ...
  • 你可以简单地; insert into database2.dbo.table2 (f1, f2, fN) select f1, f2, fN from database1.dbo.table1 where x = y You can simply; insert into database2.dbo.table2 (f1, f2, fN) select f1, f2, fN from database1.dbo.table1 where x = y
  • 只需包装无法在EXEC ()编译的代码: if (SELECT max(version) FROM DatabaseVersion) < x exec('INSERT INTO DatabaseVersion ....... (Current Version Number, Description of Change)') 这是一张exec执行了超过128个字符代码的图片: 这里是文档的链接: EXECUTE-Transact-SQL Just wrap your code that does not c ...
  • select语句正在执行函数dbo.functionToGetAccountType()并将列别名为AccountType 。 它可以重写为: SELECT dbo.functionToGetAccountType() as AccountType FROM AccountLookup The select statement is executing the function dbo.functionToGetAccountType() and aliasing the column as Accou ...
  • 问题1 尝试: SELECT deathDate, finalGameDate FROM Players WHERE Convert(datetime,finalGameDate) <= '1990/01/01' AND deathDate Is Not NULL 问题2 尝试: SELECT weight, birthCountry, case When birthCountry = 'USA' then 'Domestic-Born' ...

相关文章

更多

最新问答

更多
  • 您如何使用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)