问题标签 [glsurfaceview]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
android - Android OpenGL 只渲染一半屏幕
我遵循了一个 opengl 应用程序的示例,但我不知道为什么会发生这种情况......
我有一个 GLSurfaceView ,它的相应渲染器绘制了一个三角形。但是,我没有将整个视图显示在屏幕上,而是只显示了上半部分,并且正如您在图片中看到的那样,它也是重复的。我正在使用 Nexus One
xml:
该活动在清单中有这个:
DrawingLayer 类:
三角形渲染器(大部分来自 Apress Pro Android 2 书)
提前致谢!
android - GLSurfaceView textured rect as button clicks
I just want to ask a simple question related the GLSurfaceView and drawn objects on it. I am drawing a rect and bind a texture to it. It works great. Then, the textured rect I am drawing is on a GLSurfaceView. I am drawing a "button"-like object for which I should know whether the user clicked on the button or not.
I imagined that like this: if the user taps the screen and the .y of the tap are in the rect of the drawn object (in my case the button), I need another operation to be performed (i.e. change another view or so...). Is my idea correct?
Now the question: How do I handle user interactions? And how can I get the Rect of the drawn object (button) maped on the GLSurfaceView (i.e. Rect(120, 80)) so that I can then check whether the user clicked the button or not? Or there is some other approach.
Also I am interested in the following: I have in mind to make my application full opengl es based. I won't use Button views from Android. I am working with big textures and I think OpenGL ES is the better way to do it since animations via translations and rotations and scaling are much easier to handle. Am I right?
Thanks
android - 使用 XML/Java 覆盖的 Android glSurfaceView
我启动了一个 Android OpenGL 应用程序,我有以下类:
当调用 A 类的 onCreate 时,它会创建一个 B 类类型的对象并调用:
到目前为止它有效,我花了几天时间。
现在我想向我的应用程序添加按钮并找到 SurfaceViewOverlay 示例。它使用一些 XML 来创建视图层次结构。我想创建一些与我简单地剪切和粘贴 XML 代码非常相似的东西:
现在记住我原来的类层次结构,我将如何初始化我的视图?我应该在 A 类的 onCreate() 中写什么?
我尝试使用:
它确实在屏幕上绘制了按钮和 GL 视图,但 GL 视图无法接收来自点击/点击的任何输入。
这可能是因为 Bobject 的 onTouchEvent() 没有被调用,因为它仅用作:
而不是:
目的。
而不是上面的代码,我真正想要的是让 Bobject 替换 glSurfaceView。但我不知道该怎么做。当我确实 findViewById() 时,似乎现在已经创建了 glSurfaceView。我如何要求它为 GL 视图使用 B 类型的对象?
对不起任何新手的错误。对 Android 来说是全新的。
编辑:我也试过这个:
我还尝试了以下方法:在我的 XML 文件中,我将 GLSurfaceView 更改为:
在我的 A 类构造函数中,我正在调用:
我应该如何在我的 XML 文件/活动中使用扩展 glSurfaceView 的自定义类?
android - 如何在 Android 上的 GLSurfaceView 上播放视频?
我在 ApiDeoms 的 Cube 演示中添加了一个 SurfaceView。并尝试使用 MediaPlayer 来玩它。但它因低级播放器错误而失败,这在不同设备上有所不同。是否可以在 GLSurfaceView 上播放视频,或者只是硬件支持?
android - 尽管更改了渲染模式,GLSurfaceView 仍会持续渲染
我正在尝试创建一个显示游戏区域地图的 GLSurfaceView。当玩家移动时,游戏 Activity 会调用 highlightSpot,这反过来会触发渲染请求。我想重新绘制视图的唯一时间是玩家移动时。
然而,在我当前的实现中,尽管调用setRenderMode(RENDERMODE_WHEN_DIRTY)
了我的 GLSurfaceView,但它的渲染模式似乎仍然是连续的。为了检查,我在我的 onDrawFrame 方法中抛出了一个 println 语句,当我运行我的应用程序时,输出很快就填满了我的 logcat,而玩家甚至没有移动一次——它显然没有按照我的预期运行。为了使视图仅在被询问时呈现,我还需要做些什么吗?
(这段代码的大部分来自http://insanitydesign.com/wp/projects/nehe-android-ports/的教程。为了简洁起见,我省略了我的 onDrawFrame、OnSurfaceChanged 和 onSurfaceCreated 方法,就像我一样不改变渲染模式或在这些方法的任何地方请求渲染。如果有人认为这可能是相关的,我也可以发布这些。)
android - 计算速度
我试图在我的 GLSurfaceView 中实现惯性滚动,为此我需要弄清楚如何计算速度,但我不知道该怎么做。翻译存储在一个矩阵中,并由下面的代码行计算。
android - GLSurfaceView 上的 Android 视图动画很慢
我们注意到,当您将带有视图动画的 Android 视图(没什么复杂的,只是 AlphaAnimation 和 TranslateAnimation)放在 GLSurfaceView 之上时,动画运行缓慢(即您会看到很多卡顿)。我在GLSurfaceView,我相信我已经确认(通过设置断点)在动画播放时 GL 绘制调用没有受到影响,所以我不确定缓慢来自哪里。
有谁知道解决这个问题的方法?我知道在 iPhone 上这也曾经是一个问题,但他们进行了一些操作系统更新来解决这个问题。它们是短视图动画(例如你赢了!)所以这不是世界上最糟糕的事情,但如果有一些解决方法会很好。
我们不在 GL 中制作动画的原因是它们必须能够从我们游戏中的任何 Activity 运行,并且并非我们所有的 Activity 都有 GLSurfaceViews。
最后,如果重要的话,我们将使用来自 Replica Island http://code.google.com/p/replicaisland/的修改后的 GLSurfaceView 源
android - NDK call in a GLSurfaceView class
I am trying to render an openGL es surface from the NDK, but got halted early in my work. I have a setup similar to the 3d example in the NDK. I have a class inheriting from GLSurface view and one inheriting from GLSurfaceView.Renderer. In my .c file, I have a simple method that does NOTHING. It is just a void function with nothing in it. I can call this function in my class that inherit from activity onCreate method.
private static native void nativeSetup();
The program works fine. However, if i put the call (and declaration) in one of the GLSurfaceView classes, the program immediately fails (nativeSetup is the call in question). I have verified that everything is working fine without the native call (a colored surface is drawn). Does anyone have any ideas about why I cannot call native code from GLSurface classes?
My c file:
My java file in a non working manner:
android - How can I use Multiple GLSurfaceView components in the same Layout?
I'm writing an Information Visualization API for Android and ran into a problem trying to place two units of a custom GLSurfaceView
into a Layout. The Custom GLSurfaceView
at this point is simply an extension of the GLSurfaceView
to eliminate possible faults caused by custom methods.
When I have both components added in layout and start the application it runs. But nothing is drawn, seems like it enters an infinite loop. because debug messages inside the Renderers are printed into the LogCat. However, It works perfectly fine if I only use one of the custom GLSurfaceView
components.
I read that there is a problem using GLSurfaceView
in multiple Activities and I suppose it also applies when using two of those components at the same time. I have tried the workaround posted here but cant seem to get it to work either.
I would appreciate any help. I choose to use openGL for the better performance, but if I cant use multiple components at once I guess I'll have to use Canvas instead.
The manifest looks as follows:
From the Activity the code is like this:
Am I missing something obvious? Or can someone explain why it doesn't work?
android - 滚动视图内的glsurfaceview,移动但不裁剪
我有一个内部带有线性布局的滚动视图。此线性布局中的元素之一是 glsurfaceview。
这一切正常,当我滚动glsurfaceview时上下移动但是当glsurfaceview到达它应该被剪切的滚动视图的顶部或底部时,它不是并且在滚动视图之外继续。此屏幕截图应该更清楚:
不要认为它是完全必要的,但这是我的 layout.xml:
非常感谢所有帮助:)