Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » How do I create a 1D Texture using Allegro?

This thread is locked; no one can reply to it. rss feed Print
How do I create a 1D Texture using Allegro?
SirAlucard
Member #15,275
August 2013

Hi Everyone,

This is my first post here at the forums. I am troubled with this one and can't find a solution, neither in the forums nor google.

I am trying to create a 1D bitmap ( al_create_bitmap(x,1) ) but when trying to bind it to GL_TEXTURE_1D target glGetError returns error flag GL_INVALID_OPERATION.

Just by doing the following will trigger the error:

#SelectExpand
1glEnable(GL_TEXTURE_1D); 2ALLEGRO_BITMAP *bmp = al_create_bitmap(4,1); 3GLuint texname = al_get_opengl_texture(bmp); 4glBindTexture(GL_TEXTURE_1D, texname); 5printf("%d\n", glGetError());//outputs "1282" (GL_INVALID_OPERATION) 6glDisable(GL_TEXTURE_1D);

I was able to create a 1D texture using glGenTexture function but I can't or don't know how to use allegro drawing functions with this texture and not an ALLEGRO_BITMAP.

Is there any other way to accomplish a 1D "ALLEGRO_BITMAP"?

Any help will be greatly appreciated.

-SirAlucard

Kris Asick
Member #1,424
July 2001

I doubt there's a way to make OpenGL 1D textures work with ALLEGRO_BITMAP objects for the simple fact that the entire bitmap handling system in Allegro relies on there being two texture axises, an X and Y. :P

I could be wrong about that... but there may be a better solution to what you're trying to do than using 1D textures. Perhaps you could tell us why you want to use them and we could suggest an alternate approach?

--- Kris Asick (Gemini)
--- http://www.pixelships.com

SirAlucard
Member #15,275
August 2013

Ok, basically what I am doing right now is using a 1D Texture as a HeightMap Texture for a 2D object (terrain, water, lava, etc.) and, using a vertex shader, the position of the vertices at the top are modified based on this 1D Texture.

I have it working right now with a 1D Texture but anytime I want to change the heightMap I have to use glTexImage1D and glTexSubImage1D while for the other Bitmaps I am using allegro functions.

It is Not Crucial for me to find this solution since I got it working as I've explained above but I was just wondering if there was another way or if there was some state I had to establish before al_create_bitmap to accomplish a 1D Texture. It feels kind of awkward accessing all textures from their respective ALLEGRO_BITMAP using al_get_opengl_texture(bmp) but not being able to follow the same habit for these 1D Textures.

But what you are saying makes sense but I don't have that much experience with allegro 5, so here is another question:

What it is the performance advantage using a 1D Texture over using a 2D Texture with size (2^x, 1)?

Kris Asick
Member #1,424
July 2001

What it is the performance advantage using a 1D Texture over using a 2D Texture with size (2^x, 1)?

Virtually none. :P

I thought about the varying situations related to what you seem to be attempting and I couldn't think of a better approach really. I can think of several different approaches, but performance-wise, they're about the same, so you might as well just stick with what works. ;)

With my own current project, since I started it before A5 added fragment shader support, I had to force my program to use OpenGL so I could easily add in GLSL code to perform a full-screen glow effect. One of the good things about A5 is that it makes it easy to manually do things A5 itself can't if you have to. 8-)

--- Kris Asick (Gemini)
--- http://www.pixelships.com

SirAlucard
Member #15,275
August 2013

Thanks for your help Kris! I think I will stay with what works then... ;D

Go to: