How do color and textures work together?
By : user3441032
Date : March 29 2020, 07:55 AM
hope this fix your issue If you intend to draw one side of the cube with a texture, and the other sides without it, then you need to glEnable(GL_TEXTURE_2D) for the side with the texture and glDisable(GL_TEXTURE_2D) for the sides without it. That's not your problem, but it still needs to be done. If you're trying to render with just a texture, you could pass (1, 1, 1) for the color. However, that just paints over the issue.
|
Why don't my OpenGL textures work?
By : rjr123
Date : March 29 2020, 07:55 AM
may help you . Thank you cubic. I added a debug snippet to help track down the problem: code :
if (DEBUG) {
printf("%s\n", gluErrorString(glGetError()));
fflush(stdout);
}
glEnable(GL_VERTEX_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
|
Getting textures to work in OpenGL 3.2
By : humourous_mug
Date : March 29 2020, 07:55 AM
this one helps. So, I finally figured it out. jozxyqk's advice for testing the texture coords confirmed my suspicions that the texture coordinates were off (every vertex was getting the same coordinate). The problem ended up being that I was calling glVertexAttribDivisor(attributeLoc, 1) in another part of my code and never setting it back to per vertex, so it was affecting my other shaders. Thinking about the design of OpenGL, it makes sense that this would be necessary. Glad that's settled!
|
Metal much slower compared to OpenGL while rendering small textures on a large texture
By : brainmaps
Date : March 29 2020, 07:55 AM
this one helps. Remove all redundancy: Don't create buffers at render time. Allocate sufficient buffers during initialization. Don't create a command encoder for every quad. Use one big vertex buffer with different (properly aligned) offsets for each quad. Use -setVertexBufferOffset:atIndex: to set just the offset as necessary, without changing the buffer. composeImageVertices:... can write directly into the vertex buffer with an appropriate cast, avoiding a memcpy. Depending on what composeImageVertices:... actually does and if deltaX and deltaY are constants, you may be able to set up the vertex buffer once, ever. The vertex shader can transform the vertices as necessary. You would pass in the appropriate data as uniforms (either the destination point and render target size, or even a transform matrix). Assuming they're the same every time, don't set mPipelineState, mBrushTextureBuffer, and mSampleState every time. If any quads share the same brush texture, group them together and do one draw command to draw them all. This may require switching to triangle primitives instead of triangle strip primitives. However, if you do an indexed draw, you can use the primitive restart sentinel to draw multiple triangle strips in one draw command. You can even do multiple brushes in one draw command if the count doesn't exceed the number of textures allowed (31). Pass all of the brush textures to the fragment shader. It can receive them as a texture array. The vertex data would include the brush index, the vertex shader would pass that forward, the fragment shader would use it to look up the texture to sample from the array. You could use instanced drawing to draw everything in a single command. Draw stroke instances of a single quad. In the vertex shader, transform the position based on the instance ID. You would have to pass deltaX and deltaY in as uniform data. The brush indexes can be in a single buffer that's passed in, too, and the shader can look up the brush index in it by the instance ID. Have you considered using point primitives instead of quads? That would reduce the number of vertexes and give Metal information that it can used to optimize rasterization.
|
Is it slower to draw small sprites with large textures on iPhone?
By : user3893695
Date : March 29 2020, 07:55 AM
wish helps you Yes, smaller texture sizes are faster than big ones, but for sprites using multiple small textures will actually be slower. You want to reduce the amount of texture binds, so packing all your sprites into one big texture and drawing them using appropriate uv's would be most efficient.
|