• 10
• 9
• 12
• 14
• 15
• ### Similar Content

• By cebugdev
hi all,
how to implement this type of effect ?
Also what is this effect called? this is considered volumetric lighting?
what are the options of doing this?
a. billboard? but i want this to have the 3D effect that when we rotate the camera we can still have that 3d feel.
b. a transparent 3d mesh? and we can animate it as well?

2. how to implement things like fireball projectile (shot from a monster) (billboard texture or a 3d mesh)?

Note: im using OpenGL ES 2.0 on mobile.

thanks!

• Hey guys. Wow it's been super long since I been here.

Anyways, I'm having trouble with my 2D OrthoM matrix setup for phones / tablets. Basically I wan't my coordinates to start at the top left of the screen. I also want my polygons to remain squared regardless if you have it on portrait or landscape orientation. At the same time, if I translate the polygon to the middle of the screen, I want it to come to the middle regardless if I have it in portrait or landscape mode. So far I'm pretty close with this setup:
private float aspectRatio; @Override public void onSurfaceChanged(GL10 glUnused, int width, int height) { Log.d("Result", "onSurfacedChanged()"); glViewport(0, 0, width, height); if (MainActivity.orientation == Configuration.ORIENTATION_PORTRAIT) { Log.d("Result", "onSurfacedChanged(PORTRAIT)"); aspectRatio = ((float) height / (float) width); orthoM(projectionMatrix, 0, 0f, 1f, aspectRatio, 0f, -1f, 1f); } else{ Log.d("Result", "onSurfacedChanged(LANDSCAPE)"); aspectRatio = ((float) width / (float) height); orthoM(projectionMatrix, 0, 0f, aspectRatio, 1f, 0f, -1f, 1f); } } When I translate the polygon using TranslateM( ) however, goes to the middle in portrait mode but in landscape, it only moved partially to the right, as though portrait mode was on some of the left of the screen. The only time I can get the translation to match is if in Landscape I move the aspectRatio variable in OrthoM( ) from the right arguement to the bottom arguement, and make right be 1f. Works but now the polygon is stretched after doing this. Do I just simply multiply the aspectRatio to the translation values only when its in Landscape mode to fix this or is there a better way?
if (MainActivity.orientation == Configuration.ORIENTATION_PORTRAIT) { Matrix.translateM(modelMatrix, 0, 0.5f, 0.5f * aspectRatio, 0f); } else { Matrix.translateM(modelMatrix, 0, 0.5f * aspectRatio, 0.5f, 0f); } Thanks in advance.

• I'm trying to capture a frame with gl.readPixels and send the data to my server. For testing purposes, I tried rendering a texture with the same Uint8Array I used with gl.readPixels, but unfortunately can't get the texture to show an image.   Let me share the steps I'm taking.
I made sure to allocate memory outside of the game loop:
const width = Game.Renderer.width; const height = Game.Renderer.height; let pixels = new Uint8Array(4 * width * height); And before i unbind the frame buffer in the drawing function, I pick up the pixels:
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels); if (stream) { if (stream.ready) stream.socket.send(pixels); } This is also where I send the pixels to the server.
In my render function I have a function updating the texture I use for displaying video, or in this case: a different image every frame:
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this._video) This works perfectly with a video or an image element, but if I pass in my uint8array no image is rendered.
The plan is to have the server send that same array to the other clients so they can use it to update their textures. Hopefully this makes sense. Thanks!
BTW: Not sure why my thread appeared two times, my connection timed out and I guess I pressed it two times. My apologies mods, I hid the duplicate thread.

# OpenGL ES 3.0 Playing videos on android

## Recommended Posts

I just found a code which uses libavcodec to decode videos and display them on screen

Canvas canvas = surfaceHolder.lockCanvas();
canvas.drawBitmap(mBitmap, mDrawLeft, mDrawTop,
prFramePaint);
surfaceHolder.unlockCanvasAndPost(canvas);

anyway it looks like a ton of useless garbage, it first decodes then draws a bitmap, i would like to somehow transfer video data to gpu directly so i can just draw a video frame in a simple poly (made of 4 verts), however it may be undoable, anyone has any more information about it?

##### Share on other sites

OpenGL?

From what I'm understanding, you want direct access to the pixels of a texture, then modify the pixels of that texture (by consequence removing the middle process of decoding to a pixel array in the client's memory).

You can do that with glMapBuffer/glUnmapBuffer :)

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glMapBuffer.xhtml
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glUnmapBuffer.xhtml

When you use glMapBuffer(), you will get a pointer to that (pixel) buffer on client-side. After modifying the buffer, you can use glUnmapBuffer() to let the graphic card know that the buffer is ready. I think this is the most "permissive" method to do that in OpenGL.