textures

OpenCV image loading for OpenGL Texture

非 Y 不嫁゛ 提交于 2019-11-27 18:13:11
I want to load an image (jpg and png) with OpenCV as OpenGL Texture. Here is how I load the image to OpenGL: glEnable(GL_TEXTURE_2D); textureData = loadTextureData("textures/trashbin.png"); cv::Mat image = cv::imread("textures/trashbin.png"); if(image.empty()){ std::cout << "image empty" << std::endl; }else{ glGenTextures( 1, &textureTrash ); glBindTexture( GL_TEXTURE_2D, textureTrash ); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S , GL_REPEAT ); glTexParameterf(

How do I blend two textures with different co-ordinates in OpenGL ES 2.0 on iPhone?

社会主义新天地 提交于 2019-11-27 18:05:21
问题 I can blend two textures with different blending modes in the fragment shader when both the textures covers the same rectangles. But now my problem is, one texture is a plain rectangle with no rotation and the other texture is another rectangle with a rotation/scale and translation. How do I merge these textures in the way I want? (In the picture) I know how to do this... But not sure how to do this... For blending textures in one rectangle (the first image), I used the following code..

Stretch background image for UIButton

天涯浪子 提交于 2019-11-27 17:18:23
I got texture, which really shorter, than my UIButton. I got this texture: And i should create this button: How should i stretch (not tile), this texture? Stretching in horizontal direction Thnx From the example images you provided I'm pretty sure you're looking for UIImage 's resizableImageWithCapInsets: UIImage *originalImage = [UIImage imageNamed:@"myImage.png"]; UIEdgeInsets insets = UIEdgeInsetsMake(top, left, bottom, right); UIImage *stretchableImage = [originalImage resizableImageWithCapInsets:insets]; [myButton setBackgroundImage:stretchableImage forState:UIControlStateNormal]; // the

How to use GL_HALF_FLOAT_OES typed textures in iOS?

荒凉一梦 提交于 2019-11-27 16:21:44
问题 I'm trying to create a float texture to store intermediate results of my rendering pipeline created by a fragment shader. I need the values of the fragments to be signed floats . I understand that there is the OES_texture_float extension which should be supported by all new iOS devices (i.e. beginning from iPhone 3GS/iPod Touch 3/iPad according to the Apple guide). However, when I create such a texture using glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_HALF_FLOAT_OES,

How to remove gaps between tiled textures?

China☆狼群 提交于 2019-11-27 16:19:11
问题 I'm using LibGDX to make a platformer. I'm using square tiles for the platforms but when they are drawn some of them have gaps between them. When I zoom in/out or move the camera around the gaps move position. More details: Tiles are 32x32 and I have tried both 32x32 and 64x64. Tiles are lined up 32 pixels apart (e.g. first tile would be x=0 y=0, second x=32 y=0, and so on in both x and y directions). The gaps are not texture artifacts as I have checked this. I use the TexturePacker with

sf::Texture as class member doesn't work?

半腔热情 提交于 2019-11-27 16:14:16
Heyy, I want to draw a sprite in my SFML application but its texture is always white when I use an image and a texture that are class members Class members: sf::Sprite myimg; sf::Image myimg_image; sf::Texture myimg_texture; When I then create the sprite like this in my cpp file // create image myimg_image.create(icon.width, icon.height, icon.pixelData); // create texture from image myimg_texture.create(icon.width, icon.height); myimg_texture.update(myimg_image); // apply texture to sprite myimg.setTexture(myimg_texture); It only draws a white sprite when I draw it with window.draw(myimg)

How to load a bmp on GLUT to use it as a texture?

别来无恙 提交于 2019-11-27 15:53:26
问题 I've been searching all around for a simple solution to add sprites to my OpenGl GLUT simple moon lander game in c++ and it appears I must use bmp's since they're easiest to load and use them as textures on a rectangle. How exactly can I load the bmp's as textures though? 回答1: Look my simple c implementation function to load texture. GLuint LoadTexture( const char * filename ) { GLuint texture; int width, height; unsigned char * data; FILE * file; file = fopen( filename, "rb" ); if ( file ==

Responding to RAM availability in iOS

那年仲夏 提交于 2019-11-27 14:28:22
I have a texture-heavy OpenGL game that I'd like to tune based on how much RAM the device has. The highest resolution textures I have work fine on an iPhone 4 or iPad2, but earlier devices crash in the middle of loading the textures. I have low-res versions of these textures, but I need to know when to use them. My current tactic is to detect specific older devices (3GS has a low-res screen; iPad has no camera), then only load the hi-res textures for IPad2 and above and iPhone 4 and above — and I suppose I'll need to do something for the iPod touch. But I'd much rather use feature detection

Three.js - multiple material plane

橙三吉。 提交于 2019-11-27 14:25:30
问题 I'm trying to have mutiple materials on a single plane to make a simple terrain editor. So I create a couple of materials, and try to assign a matetrial index to each vertex in my plane: var materials = []; materials.push(new THREE.MeshFaceMaterial( { color: 0xff0000 })); materials.push(new THREE.MeshFaceMaterial( { color: 0x00ff00 })); materials.push(new THREE.MeshFaceMaterial( { color: 0x0000ff })); // Plane var planegeo = new THREE.PlaneGeometry( 500, 500, 10, 10 ); planegeo.materials =

WebGL - wait for texture to load

杀马特。学长 韩版系。学妹 提交于 2019-11-27 14:23:13
How do I test if the WebGLTexture object is 'complete' ? Currently I get this message: [WebGLRenderingContext]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering or is not 'texture complete' I get this warning because the render-loop is trying to use the texture before its image has finished loading, so how to fix that? gman The easiest way to fix that is to make a 1x1 texture at creation time. var tex = gl.createTexture(); gl.bindTexture(gl.TEXTURE_2D, tex); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA