textures

Combine Array of Sprite objects into One Sprite - Unity

被刻印的时光 ゝ 提交于 2019-12-04 00:29:21
I have an array of Sprite objects in Unity. Their size vary depending on the image loaded. I want to combine them side by side like a tiled map into one image. I want them to be layout like your are forming a line of images, one after the other. (note: NOT one on top of the other) How may I be able to do this? The reason why I'm combining (just for those who want to know) is because I'm using a polygon2D Collider. Since there are some weird behaviors happening when I use multiple colliders side by side, I decided to just combine the images before adding one big polygon collider. Note that

How to copy frontBuffer data to texture DirectX 9

我的梦境 提交于 2019-12-03 21:02:00
I can't seem to find a way to create a texture from the surface data I acquire through the front buffer data of my application This is the code I'm pretty sure is working (Direct X 9, C++) // capture screen IDirect3DSurface9* pSurface; g_pd3dDevice->CreateOffscreenPlainSurface(640, 480, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &pSurface, NULL); g_pd3dDevice->GetFrontBufferData(0, pSurface); Now that I've got my frontBufferData, I would like to create a IDirect3DTexture9 object with it. This function / D3DXCreateTextureFromFileInMemory / seemed the most logical but doesn't seem to do the trick. I'm

Android OpenGL combination of SurfaceTexture (external image) and ordinary texture

天涯浪子 提交于 2019-12-03 18:51:47
问题 i would like to mix camera preview SurfaceTexture with some overlay texture. I am using these shaders for processing: private final String vss = "attribute vec2 vPosition;\n" + "attribute vec2 vTexCoord;\n" + "varying vec2 texCoord;\n" + "void main() {\n" + " texCoord = vTexCoord;\n" + " gl_Position = vec4 ( vPosition.x, vPosition.y, 0.0, 1.0 );\n" + "}"; private final String fss = "#extension GL_OES_EGL_image_external : require\n" + "precision mediump float;\n" + "uniform samplerExternalOES

Get Maximum OpenGL ES 2.0 Texture Size Limit in Android

放肆的年华 提交于 2019-12-03 18:05:54
问题 I am trying to get the maximum texture size limit in Android for OpenGL 2.0. But I've found that the next instruction only works if I'm currently within the OpenGL Context, in other words I must have a GL Surface and a GL Renderer, etc, which I don't want. int[] maxTextureSize = new int[1]; GLES20.glGetIntegerv(GLES20.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0); So I came with the next algorithm, which gives me the maximum texture size without having to create any surface or renderer. It works

OpenGL4.5 - bind multiple textures and samplers

六眼飞鱼酱① 提交于 2019-12-03 17:02:37
问题 I'm trying to understand Textures, Texture Units and Samplers in OpenGL 4.5. I'm attaching a picture of what I'm trying to figure out. I think in my example everything is correct, but I am not so sure about the 1D Sampler on the right side with the question mark. So, I know OpenGL offers a number of texture units/binding points where textures and samplers can be bound so they work together. Each of these binding points can support one of each texture targets (in my case, I'm binding targets

OpenGl glTexImage2D data

浪子不回头ぞ 提交于 2019-12-03 16:56:58
I am trying to read floatingpoint numbers from a CSV file , that contains a precomputed texture, store it in a 1 dimensional array, and then put that read data into a 2 dimensional texture. I need to make sure the following code does that, because i have problems accessing the data and I cannot figure out where the error is: // Allocate memory float * image = new float [width * height * 3 ]; for( int i = 0; i < height; i++) { for( int j = 0; j < width-1; j++) { fscanf( fDataFile, "%f,", &fData ); image[ 4 * i * j + 0 ] = fData; image[ 4 * i * j + 1 ] = fData; image[ 4 * i * j + 2 ] = fData; }

How do I make textures transparent in OpenGL?

淺唱寂寞╮ 提交于 2019-12-03 16:37:33
I've tried to research this on Google but there doesn't appear to me to be any coherent simple answers. Is this because it's not simple, or because I'm not using the correct keywords? Nevertheless, this is the progress I've made so far. Created 8 vertices to form 2 squares. Created a texture with a 200 bit alpha value (so, about 80% transparent). Assigned the same texture to each square, which shows correctly. Noticed that when I use a texture with 255 alpha, it appears brighter. The init is something like the following: glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); glEnable(GL

Loading 4-channel texture data in iOS

不羁岁月 提交于 2019-12-03 16:10:43
I want to load 4-channel texture data from a file in iOS, so I consider the texture as a (continuous) map [0,1]x[0,1] -> [0,1]x[0,1]x[0,1]x[0,1] If I use the fileformat .png , XCode/iOS consider the file as an image, and so multiplies each component rgb with a (premultiplied alpha), corrupting my data. How should I solve this? Examples may be use two textures with components rgb (3-channel) postdivide alpha use another file format Of these, I consider the best solution to be to use another file format. The GL-compressed file format (PVRTC?) is not Apple-platform independent and seems to be of

Unity build project game 2d to apk with huge size because textures

拈花ヽ惹草 提交于 2019-12-03 16:05:42
I have a project unity game 2d. when i build it with 70 MB in apk, i think it too large with my game. I try to delete some pictures (textures for backgrounds of game) about 6MB in my folder Assets\Resources (because my game load resource dynamically base on current level). Then rebuild it to apk. And it get 30MB. I wonder about it. this is editor log when i build apk with 70MB Textures 182.1 mb 95.7% Meshes 0.0 kb 0.0% Animations 0.0 kb 0.0% Sounds 1.1 kb 0.0% Shaders 42.5 kb 0.0% Other Assets 594.9 kb 0.3% Levels 485.3 kb 0.2% Scripts 1.2 mb 0.6% Included DLLs 5.1 mb 2.7% File headers 791.0

Full screen background texture with OpenGL performance issue (iPad)

谁都会走 提交于 2019-12-03 14:28:39
I am quite puzzled with the poor performance I'm seeing when drawing a full screen background using a textured triangle mesh in OpenGL: drawing just the background and nothing else maxes out at 40 fps using the most basic shader, and 50 fps using the default pipeline. While 40 fps doesn't seem too bad, adding anything else on top of that makes the fps drop, and considering I need to draw 100-200 other meshes on top of that, I end up with a paltry 15 fps that is simply not usable. I have isolated the relevant code into an XCode project available here , but the essence of it is the canonical