textures

Texture Sampling Coordinates to Render a Sprite

北慕城南 提交于 2019-11-29 13:48:00
问题 Let's say we have a texture (in this case 8x8 pixels) we want to use as a sprite sheet. One of the sub-images (sprite) is a subregion of 4x3 inside the texture, like in this image: (Normalized texture coordinates of the four corners are shown) Now, there are basically two ways to assign texture coordinates to a 4px x 3px-sized quad so that it effectively becomes the sprite we are looking for; The first and most straightforward is to sample the texture at the corners of the subregion: //

glGetTexImage reads too much data with texture format GL_ALPHA

删除回忆录丶 提交于 2019-11-29 12:25:38
I'm trying to retrieve the pixel information for an alpha-only texture via glGetTexImage. The problem is, the glGetTexImage-Call seems to read more data than it should, leading to memory corruption and a crash at the delete[]-Call. Here's my code: int format; glGetTexLevelParameteriv(target,0,GL_TEXTURE_INTERNAL_FORMAT,&format); int w; int h; glGetTexLevelParameteriv(target,0,GL_TEXTURE_WIDTH,&w); glGetTexLevelParameteriv(target,0,GL_TEXTURE_HEIGHT,&h); if(w == 0 || h == 0) return false; if(format != GL_ALPHA) return false; unsigned int size = w *h *sizeof(unsigned char); unsigned char *pixels

Is it possible to use a 2d canvas as a texture for a cube?

a 夏天 提交于 2019-11-29 12:04:41
I want to add images to one face of a cube, possibly using a 2d canvas element as the face texture. Here is my code, but I can't get the result I want. The face using the canvas as a texture is blank, the other faces use a THREE.ImageUtils.loadTexture and they're fine. var renderer, camera, scene; var canvas = document.createElement("canvas"); var context = canvas.getContext("2d"); var image0 = new Image(); var image1 = new Image(); image0.onload = function() { context.drawImage(image0, 0, 0); }; image0.src = 'textures/nx.jpg'; var texture = new THREE.Texture(canvas); texture.needsUpdate =

CVOpenGLESTextureCache vs glTexSubImage2D on iOS

China☆狼群 提交于 2019-11-29 10:28:48
问题 My OpenGL app uses OpenGL to render a texture in full screen and updates part of it at regular intervals. So far, I've been using glTexImage2D to push my initial texture and then I update the dirty regions with glTexSubImage2D. To do that, I'm using single buffering. This works well. I've seen that there might be another way to achieve the same thing using CVOpenGLESTextureCache. The textures held in the texture cache reference a CVPixelBuffer. I'd like to know if I can mutate these cached

Get Maximum OpenGL ES 2.0 Texture Size Limit in Android

限于喜欢 提交于 2019-11-29 10:07:39
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 correctly, so my question is if this will work with all Android devices, and if anyone can spot any bug,

How to repeat the texture map like GL_REPEAT?

China☆狼群 提交于 2019-11-29 09:53:59
I have a house model in my game, and I have some materials for the house geometry. There is a material for the wall of the house, and I have a texture-map-image to show the bricks. var mat = new THREE.MeshPhongMaterial( { ambient: 0x969696, map: THREE.ImageUtils.loadTexture( 'textures/G/G0.jpg' ), overdraw: true,combine: THREE.MultiplyOperation } ); In this way above, the texture map appears like GL_CLAMP I want it to show like GL_REPEAT . What should I do? If you can not see the images check this . I have posted a full working example at: http://stemkoski.github.com/Three.js/Texture-Repeat

how to flip a pixmap to draw to a texture in libgdx?

不想你离开。 提交于 2019-11-29 09:45:24
So what I'm trying to do is to generate a background image for my game by drawing pixmaps to a texture. So far I can do that, but now I need to draw the pixmaps flipped in the X or Y axis to the texture. However I can't find anything to do so. The pixmap class does not provide that functionality. Then I thought I could draw a flipped texture region to a texture, but so far I haven't found how to do so. So I was wondering how can I do such a thing, would it be possible to flip a png image with other java libraries and then create a pixmap from that flipped image? I also don't see other option

Texture atlas offset/repeat works for meshes but is ignored for point system particles

孤街醉人 提交于 2019-11-29 08:57:01
I am using a texture atlas to hold a sequence of images. When mapping to a mesh with MeshLambertMaterial , using Texture.offset and Texture.repeat works beautifully to cut the subtexture out of the entire image. However, using the exact same texture instance for a PointCloudMaterial renders the particles with the entire atlas, not just the selected subimage. I tried to follow the three.js source code, but the documentation is scarce. Is there a workaround for this better than using canvases to chop up the image? Edit: As requested, a work-in-progress is available at http://jnm2.com/minesweeper

How to map different textures to different faces of a cube in WebGL?

北慕城南 提交于 2019-11-29 08:44:33
I have the following cube coordinates: var vertices = [ // Front face -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0, // Back face -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0, -1.0, // Top face -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1.0, // Bottom face -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, -1.0, -1.0, 1.0, // Right face 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, // Left face -1.0, -1.0, -1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, -1.0 ]; And these are the texture coordinates: var textureCoordinates = [

How to bind an array of textures to a WebGL shader uniform?

前提是你 提交于 2019-11-29 07:03:49
I need to handle many objects which share only a few textures. Defining and loading textures one by one manually (as described in another post on SO ) does not feel right... even more so since there's no switch (index) {case:...} statement in WebGL. So I wanted to pass the texture to use for a vertex as a vertex attribute, and use this number as an index into some "array of textures" in the fragement shader. But the OpenGL wiki on Samplers (not quite the perfect reference for WebGL, but the one I found) says: A variable of sampler can only be defined in one of two ways. It can be defined as a