texture

Doing readback from Direct3D textures and surfaces

I need to figure out how to get the data from D3D textures and surfaces back to system memory. What's the fastest way to do such things and how? Also if I only need one subrect, how can one read back only that portion without having to read back the entire thing to system memory? In short I'm looking for concise descriptions of how ...

How to output video to a texture in Java?

I need to put video playback to my game, and the video must be in a texture so that it is played inside the game world. I am using Java (Java3D, JOGL). How can I do this? Any ideas? ...

Packing rectangular image data into a square texture.

I have N items of 2D image data that will be rectangular and I want to pack them into a single power of 2 texture as efficiently as possible. A simple non-efficient and naive implementation of an algorithm to pack these rects would be easy to whip up, but I'm sure people have come up with algorithms to do this as space efficiently as po...

BlendFunc for textured fonts with changing background

I am attempting to use Textured fonts as so that I can display text in my openGL scene. However I am having trouble finding glBlendFunc values that will work. The background that the text will be placed on is a grayscale image but will change throughout the execution. Because the background changes the text could possibly be on top of ...

How to apply texture to glutSolidCube

Hi, I can find tutorials about mapping textures to polygons specifying vertices etc. but nothing regarding how to apply a texture to a cube (or other stuff) drawn with glut (glutSolidCube). I am doing something like: glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, decal); glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeat); glT...

How can I apply 2 or more texture maps to a gluSphere OpenGL object?

I'm writing a basic planet viewer OpenGL Perl application, just for fun. I have the basics working, with the glorious planet, implemented through a gluSphere(), rotating with the classic earth texture map applied. Now, what if I want to apply a second texture map through OpenGL (say, the "earth clouds")? Of course, I can mix the two te...

opengl slow on texture blit

I called this function once per frame and it took my FPS from >400 to 33. Why? sw blt(const PtRect *dstRect, Texture *src, const PtRect *srcRect, RenderDevice::bltFlags flags=RenderDevice::bltDefault) { assert(src); GL_Texture *glsrc = dynamic_cast<GL_Texture*>(src); if (glsrc == 0) return -1; PtRect srcRect2(0, 0, src->width, sr...

Texture Image processing on the GPU?

I'm rendering a certain scene into a texture and then I need to process that image in some simple way. How I'm doing this now is to read the texture using glReadPixels() and then process it on the CPU. This is however too slow so I was thinking about moving the processing to the GPU. The simplest setup to do this I could think of is t...

How to index a texture as a discrete lookup table from a shader?

I'm writing a shader in GLSL and I need to pass it a certain amount of information. The only practical way to pass this information is using a 1-D texture. I'm creating the texture and setting GL_TEXTURE_MIN_FILTER and GL_TEXTURE_MAG_FILTER to GL_NEAREST Now from the shader I need to access the texture so I'll be able to exactly index ea...

How to copy the pixel data from a texture into a bitmap (direct3d)?

I have rendered the scene into a texture, and then I want to save it into a bitmap, but after lock the texture, I found there is no pixel data in the lock area. The texture can be displayed correctly on the screen. I am not sure why? 1> the format is incorrect? A8R8G8B8 has been used. 2> have I missed some important steps before get the ...

Implimenting a Texture atlas, with triangle_strip or triangles. iPhone opengl es

Multiple places reccomend using a texture atlas for performance. Apple suggest the function gltexcoordpointer. In my example I have a row of squares each one is given a random texure. I put all the random textures into the super-texture. Now the problem is I can't seem to create a texcoordarray. I can't find any information on how gltexc...

How can I manage a cache texture in OpenGL?

I am writing a text renderer for an OpenGL application. Size, colour, font face, and anti-aliasing can be twiddled at run time (and so multiple font faces can appear on the screen at once). There are too many combinations to allocate one texture to each combination of string and attributes. However, only a small subset of the entire d...

OpenGL alpha value makes texture whiter?

I'm trying to load a texture with RGBA values but the alpha values just seem to make the texture more white, not adjust the transparency. I've heard about this problem with 3D scenes, but I'm just using OpenGL for 2D. Is there anyway I can fix this? I'm initializing OpenGL with glViewport(0, 0, winWidth, winHeight); glDisable(GL_TEXTU...

fixing glCopyTexSubImage2D upside down textures

Since I've started learning about rendering to a texture I grew to understand that glCopyTexSubImage2D() will copy the designated portion of the screen upside down. I tried a couple of simple things that came to mind in order to prevent/work around this but couldn't find an elegant solution. there are two problems with doing a ::glScal...

SDL_surface to OpenGL texture

Hey, I have this script to load a SDL_Surface and save it as a OpenGL texture: typedef GLuint texture; texture load_texture(std::string fname){ SDL_Surface *tex_surf = IMG_Load(fname.c_str()); if(!tex_surf){ return 0; } texture ret; glGenTextures(1, &ret); glBindTexture(GL_TEXTURE_2D, ret); glTexImage2D(GL_TEXTURE_2D, 0, 3, te...

Render a section of an image to a Bitmap C# Winforms

I'm working on a Map Editor for an XNA game I'm designing in my free time. The pieces of art used in the map are stored on a single texture and rectangles are stored with coordinates and widths etc. In the winforms application I can add segments by selecting the segment I want from a listbox, which is populated from the array of possib...

OpenGL - Copy texture from screen smaller than that screen.

I'm trying to capture the screen to a texture with a lower resolution than the screen itself (to render back onto the screen and create a blur/bloom effect), and it doesn't work quite well. I understand mipmaps can be used to do this, but I just can't get the correct sequence of commands to work. My current code: width=1024; height=102...

Copy arbitrarily sized block of pixels into OpenGL ES texture... somehow?

I'm writing a drawing application, and the drawing canvas is an OpenGL texture. When you draw onto the canvas, it determines which region of the canvas texture has been changed, and copies that pixel data out (using glReadPixels) before applying the changes you made. To undo, I want to simply revert to the previous texture state using t...

iPhone : Texture bigger than 64x64?

Hi, I took the example of GLPaint... I'm trying to put a background into the "PaintingView", so you could draw over the background and finally save the image as a file..... I'm lost. I'm loading the PNG (512x512) and try to "paint with it" at the very beginning of the program, but it's painted as 64x64 instead of 512x512... I tried be...

XNA or OpenGL sphere texture mapping

I'm trying to map a completly normal texture into a sphere. I can't change my texture to a wrapped one, so I need to find some mapping function. This is my vertex shader code: vec3 north = vec3(0.0, 0.0, 1.0); vec3 equator = vec3(0.0, 1.0, 0.0); vec3 northEquatorCross = cross(equator, north); vec3 vertexRay = normalize(gl_Vertex.xyz);...