Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android CCRenderTexture、GL11ExtensionPack、Libgdx如何_Android_Opengl Es_Libgdx - Fatal编程技术网

Android CCRenderTexture、GL11ExtensionPack、Libgdx如何

Android CCRenderTexture、GL11ExtensionPack、Libgdx如何,android,opengl-es,libgdx,Android,Opengl Es,Libgdx,我目前正在研究一种效果,比如“小翅膀”,发现CCRenderTexture就是解决方案。所以我想知道如何在android上产生这种效果,最后我找到了这个链接 它显示其GL11ExtensionPack GL11ExtensionPack egl = (GL11ExtensionPack)CCDirector.gl; egl.glGetIntegerv(GL11ExtensionPack.GL_FRAMEBUFFER_BINDING_OES, oldFBO_, 0); ... 但

我目前正在研究一种效果,比如“小翅膀”,发现CCRenderTexture就是解决方案。所以我想知道如何在android上产生这种效果,最后我找到了这个链接 它显示其GL11ExtensionPack

GL11ExtensionPack egl = (GL11ExtensionPack)CCDirector.gl;
        egl.glGetIntegerv(GL11ExtensionPack.GL_FRAMEBUFFER_BINDING_OES, oldFBO_, 0);
...
但在GLWrapperBase.java中,它显示

// Unsupported GL11ExtensionPack methods
public void glBindFramebufferOES (int target, int framebuffer) {
        throw new UnsupportedOperationException();
}
似乎gdx没有实现这个功能。我想知道libgdx的相同功能是什么,或者如何在桌面上使用GL11ExtensionPack~
感谢libGDX中的,您希望使用
FrameBuffer
对象来执行与“CCRenderTexture”等效的操作。FrameBuffer基本上允许您使用OpenGL命令绘制屏幕外缓冲区,然后您可以在以后将该缓冲区的内容显示为纹理。看见请注意,只有当您的应用程序需要OpenGL ES 2.0时,帧缓冲区对象才可用

根据您想要绘制的内容,您还可以查看libGDX中的类。这支持一些简单的运行时绘图操作(如直线、矩形和像素)。同样的想法是,你画进这个纹理,然后在屏幕上渲染生成的纹理。这在OpenGL ES 1.0中也可用

FrameBuffer和Pixmap在Android和桌面上都可以正常工作(我相信在GWT和iOS上也是如此)


小心理解当你的应用程序暂时失去焦点(OpenGL上下文丢失会导致一些纹理内容消失)时Android上会发生什么情况。

在libGDX中,你想使用一个
帧缓冲区
对象来做与“CCRenderTexture”等价的事情。FrameBuffer基本上允许您使用OpenGL命令绘制屏幕外缓冲区,然后您可以在以后将该缓冲区的内容显示为纹理。看见请注意,只有当您的应用程序需要OpenGL ES 2.0时,帧缓冲区对象才可用

根据您想要绘制的内容,您还可以查看libGDX中的类。这支持一些简单的运行时绘图操作(如直线、矩形和像素)。同样的想法是,你画进这个纹理,然后在屏幕上渲染生成的纹理。这在OpenGL ES 1.0中也可用

FrameBuffer和Pixmap在Android和桌面上都可以正常工作(我相信在GWT和iOS上也是如此)

当你的应用程序暂时失去焦点(OpenGL上下文丢失会导致一些纹理内容消失)时,请小心理解Android上会发生什么情况。

问题:CCRenderTexture、GL11ExtensionPack、Libgdx如何
解释为:在libgdx中,如何创建动态纹理。
答:使用专用渲染函数在专用帧中绘制
示例框架:
==================
包com.badlogic.gdx.tests.bullet;
/**
问题:CCRenderTexture、GL11ExtensionPack、Libgdx如何
解释为:在libgdx中,如何创建动态纹理?
答:使用专用渲染函数在专用帧缓冲区中绘制
将帧bufder转换为Pixmap,创建纹理。
作者:乔恩·古德温
**/
导入com.badlogic.gdx.graphics.Texture;
导入com.badlogic.gdx.graphics.Pixmap;
…/(ctrl-shift-o)在Eclipse中自动加载导入
公共类BaseBulletTest扩展了BulletTest
{
//类变量
=================
公共纹理纹理=null;//创建此
public Array disposables=new Array();
公共Pixmap pm=null;
//---------------------------
@凌驾
公共void创建()
{
init();
}
//---------------------------
公共静态void init()
{
if(texture==null)纹理(Color.BLUE,Color.WHITE);
TextureAttribute ta_tex=TextureAttribute.createDiffuse(纹理);
最终材质材质框=新材质(ta_tex,ColorAttribute.createSpecular(1,1,1,1),
FloatAttribute.createshiness(8f));
最终长属性1=用法.位置|用法.正常|用法.纹理坐标;
最终模型框Model=modelBuilder.createBox(1f、1f、1f、材质框、属性1);
...
}
//---------------------------
公共纹理纹理(颜色fg\U颜色、颜色bg\U颜色)
{
Pixmap pm=渲染(前景颜色、背景颜色);
纹理=新纹理(pm);//***这是您的新动态纹理***
一次性。添加(纹理);//存储纹理
}
//---------------------------
公共像素贴图渲染(颜色fg\U颜色、颜色bg\U颜色)
{
int-width=Gdx.graphics.getWidth();
int height=Gdx.graphics.getHeight();
SpriteBatch SpriteBatch=新SpriteBatch();
m_fbo=新帧缓冲区(Format.RGB565,(int)(宽度*m_fboScaler),(int)(高度*m_fboScaler),false);
m_fbo.begin();
Gdx.gl.glClearColor(bg_color.r,bg_color.g,bg_color.b,bg_color.a);
Gdx.gl.glClear(GL20.gl\u颜色\u缓冲\u位);
Matrix4 normalProjection=new Matrix4().setToorTo2D(0,0,Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
spriteBatch.setProjectionMatrix(法线投影);
spriteBatch.begin();
spriteBatch.setColor(fg_颜色);
//画画***这里是你画动态纹理的地方***
...
spriteBatch.end();//完成对缓冲区的写入
pm=ScreenUtils.getFrameBufferPixmap(0,0,(int)宽度,(int)高度);//将帧缓冲区写入Pixmap
m_fbo.end();
//pm.dispose();
//翻转。处置();
//tx.dispose();
m_fbo.dispose();
m_fbo=null;
spriteBatch.dispose();
//返回纹理;
返回pm;
}
//---------------------------
}//基于类的测试
//---------------------------
Question : CCRenderTexture,GL11ExtensionPack,Libgdx How TO interpreted as : In libgdx, how to create dynamic texture. Answer : Use a private render function to draw in a private frame Example framework: ================== package com.badlogic.gdx.tests.bullet; /** Question : CCRenderTexture,GL11ExtensionPack,Libgdx How TO interpreted as : In libgdx, how to create dynamic texture? Answer : Use a private render function to draw in a private frame buffer convert the frame bufder to Pixmap, create Texture. Author : Jon Goodwin **/ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Pixmap; ...//(ctrl-shift-o) to auto-load imports in Eclipse public class BaseBulletTest extends BulletTest { //class variables ================= public Texture texture = null;//create this public Array<Disposable> disposables = new Array<Disposable>(); public Pixmap pm = null; //--------------------------- @Override public void create () { init(); } //--------------------------- public static void init () { if(texture == null) texture(Color.BLUE, Color.WHITE); TextureAttribute ta_tex = TextureAttribute.createDiffuse(texture); final Material material_box = new Material(ta_tex, ColorAttribute.createSpecular(1, 1, 1, 1), FloatAttribute.createShininess(8f)); final long attributes1 = Usage.Position | Usage.Normal | Usage.TextureCoordinates; final Model boxModel = modelBuilder.createBox(1f, 1f, 1f, material_box, attributes1); ... } //--------------------------- public Texture texture(Color fg_color, Color bg_color) { Pixmap pm = render( fg_color, bg_color ); texture = new Texture(pm);//***here's your new dynamic texture*** disposables.add(texture);//store the texture } //--------------------------- public Pixmap render(Color fg_color, Color bg_color) { int width = Gdx.graphics.getWidth(); int height = Gdx.graphics.getHeight(); SpriteBatch spriteBatch = new SpriteBatch(); m_fbo = new FrameBuffer(Format.RGB565, (int)(width * m_fboScaler), (int)(height * m_fboScaler), false); m_fbo.begin(); Gdx.gl.glClearColor(bg_color.r, bg_color.g, bg_color.b, bg_color.a); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Matrix4 normalProjection = new Matrix4().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); spriteBatch.setProjectionMatrix(normalProjection); spriteBatch.begin(); spriteBatch.setColor(fg_color); //do some drawing ***here's where you draw your dynamic texture*** ... spriteBatch.end();//finish write to buffer pm = ScreenUtils.getFrameBufferPixmap(0, 0, (int) width, (int) height);//write frame buffer to Pixmap m_fbo.end(); // pm.dispose(); // flipped.dispose(); // tx.dispose(); m_fbo.dispose(); m_fbo = null; spriteBatch.dispose(); // return texture; return pm; } //--------------------------- }//class BaseBulletTest //---------------------------