Does Cocos2d-x support ETC2 textures? - cocos2d-x

I'm building a game and I'm currently supporting the following texture formats:
ATC
DXT
PNG
PVR
I'd like to add support for ETC2 (ETC1 won't work for us because most of our graphics require an alpha channel). Does Cocos2d-x support ETC2 textures?

No.
But two things.
Cocos2d-x doesn't have ETC2 defines in CCTexture2D.h. You need to add ETC2 defines yourself.
https://github.com/cocos2d/cocos2d-x/blob/v4-develop/cocos/renderer/CCTexture2D.h#L95-L96
https://github.com/cocos2d/cocos2d-x/blob/v4-develop/cocos/renderer/CCTexture2D.cpp#L60-L110
//! 2-bit PVRTC-compressed texture: PVRTC2 (has alpha channel)
PVRTC2A,
//! ETC-compressed texture: ETC
ETC,
//! S3TC-compressed texture: S3TC_Dxt1
S3TC_DXT1,
And Cocos2d-x uses OpenGL ES 2.0 context, at least, on Android.
https://github.com/cocos2d/cocos2d-x/blob/v4-develop/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java#L76
this.setEGLContextClientVersion(2);
So using ETC2 for glCompressedTexImage2D needs these extensions.
OES_compressed_ETC2_RGB8_texture
OES_compressed_ETC2_sRGB8_texture
OES_compressed_ETC2_punchthroughA_RGBA8_texture
OES_compressed_ETC2_punchthroughA_sRGB8_alpha_texture
OES_compressed_ETC2_RGBA8_texture
OES_compressed_ETC2_sRGB8_alpha8_texture

Related

How to add Library 'android-android-25' to LibGdx?

I'm trying to use the android's AudioRecord in LibGdx, but when I press on "Add library 'android-android-25' to classpath" nothing happens.
I cannot use LibGdx's AudioRecorder, because I want to get the amplitude of the microphone (like .getMaxAmplitude).
Thanks
You can't use AudioRecord class of Android platform because LibGDX is cross platform development library.
but you can use it only for Android platform using interface and core module of LibGDX

libGDX: same texture with shaders, different textures without

my name ist Tom (Ger) and i am developing a small 3D game with libGDX.
when i am using a Model, ModelInstance with a ModelBatch and the Environment, i can render different ModelInstances (with different Models) with there right textures.
But i need to use a shader for some wobble effects.
But when i use a shader everything works finde, except for the textures. there are the same for every ModelInscance i want to render.
i guess there is a texture binding problem. I load my Models this way:
assets = new AssetManager();
assets.load("blob.g3db", Model.class);
and fetch them with a simple:
public static Model getModel(String name) {
return assets.get(name + ".g3db", Model.class);
}
So i guess the assetsManager is loading the textures as well (cause it works without the shader).
My Question is:
How can i render differend 3D Objects with a Shader with there correct Textures?
Thanks in Advance...
Tom
The Models and the ModelInstances have a Material, where you can set a Texture, Color and other things to it.
So if 2 ModelInstances share the same Model you can set different Materials to their ModelInstances. By doing this you have different Textures. The DefaultShader implementation takes care about them. If you create your own Shader you need to take care about them.
Important: It does not work without Shader, cause you always render with Shader. You don't set the Shader manually, but libgdx uses DefaultShader by default.
I suggest you read some of Xoppas tutorials.

Which shader to use in order to render a mesh as is?

I am using GL 2.0 (in order to display pictures that are not power of 2), and I am trying to simply render a mesh (that displays some triangles).
When using GL 1.0, I didn't have any problem, but now, I have to pass a ShaderProgram object as a parameter.
How can I make it work like it would in GL 1.0?
Should I make a shader that simply does nothing?
You have to use a vertex shader to convert world space coordinates into screen space coordinates. And you need a pixel shader to look up texture coordinates for each rendered pixel of your quad.
Look at the shaders that Libgdx uses for its SpriteBatch, they are pretty minimal texture-a-quad shaders. You can literally use SpriteBatch.createDefaultShader() to get them or just use them as inspiration for your own shaders.
The libgdx wiki page on shaders already contains an example code for a simple shader:
https://github.com/libgdx/libgdx/wiki/Shaders
I assume it's basically the same as the createDefaultShader() as in P.T.'s answer...
Hope it helps...

3D sphere with texture in Canvas (HTML5)

Can we bind texture with Canvas (HTML5) 3D Sphere ?
I am referring to this example - http://www.bitstorm.it/blog/en/2011/05/3d-sphere-html5-canvas/
Thanks,
EDIT :
alternate link -
http://sebleedelisle.com/2011/02/html5-canvas-3d-particles-uniform-distribution/
Yes it is possible just like http://www.nihilogic.dk/labs/canvas3dtexture_0.2/ . But if you actually looking for 3d texture you must use WEBGL texture
A nice introduction can be found in Learning WebGL

How do I create 3D cylinder, sphere and cone using Actionscript 3 (Flash 10)?

I want to create a 3D cylinder, sphere, cone using Actionscript for Flash Player 10. Is there any available class?
I also want to know how to paint gradient, wrap text and texture around them. It would be nice if these class have these functions. I can't use non DisplayObject in this project so PV3D is not an option
As Cameron says, you should probably use a framework like PV3D or Away3D. That said, all those frameworks are written in AS so you could roll your own.
Here are a few examples I created using only the fp10 3d engine:
http://actionsnippet.com/?p=1726
http://actionsnippet.com/?p=2092
http://actionsnippet.com/?p=2097
http://actionsnippet.com/?p=2158
You can create primative shapes using parametric equations:
sphere :
x = r sin(u) cos(v)
y = r cos(u) cos(v)
z = r sin(v)
For a cylinder you can just use the equation for a circle and extrude it:
x = r cos(t)
y = r sin(t)
z = increase at some interval to the height of the cylinder
I can post some additional information about this topic if your interested.
There are 3D drawing functions for Flash 10, but I don't think they support wrapping text around a 3D object. It sounds like you need a 3D framework. Some popular ones (there's lots):
Sandy3D
Papervision3D
Away3D
Keep mind that Adobe has announced that it will soon be releasing a new version of Flash with built-in hardware-accelerated 3D rendering APIs (codenamed "molehill").