Questions tagged [glteximage2d]
72 questions
22
votes
1 answer
Updating a texture in OpenGL with glTexImage2D
Are glTexImage2D and glTexSubImage2D the only ways to pass a buffer of pixels to a texture?
At the moment I use in a setup function glTexImage2D passing null as the buffer, and then on the render loop I call glTexSubImage2D with the new buffer data…

PerracoLabs
- 16,449
- 15
- 74
- 127
18
votes
1 answer
What is the difference between glBindImageTexture() and glBindTexture()?
What is the difference between glBindImageTexture and glBindTexture? And also what is the difference between the following declarations in a shader:
layout (binding = 0, rgba32f) uniform image2D img_input;
and
uniform sampler2D img_input;

markwalberg
- 311
- 2
- 10
13
votes
2 answers
Difference between glTexSubImage and glTexImage function in OpenGL
What is the difference between the two functions?
Any performance difference?
Thanks..

Edwin
- 803
- 1
- 11
- 19
11
votes
3 answers
What happens to pixels after passing them into glTexImage2D()?
If for example I create an array of pixels, like so:
int *getPixels()
{
int *pixels = new int[10];
pixels[0] = 1;
pixels[1] = 0;
pixels[1] = 1;
// etc...
}
glTexImage2D(..., getPixels());
Does glTexImage2D use that reference or…

Nick Bolton
- 38,276
- 70
- 174
- 242
7
votes
2 answers
Render QImage with OpenGL
Related to my other question, I think the more central question would be, how you render a QImage with OpenGL?
I think the code has to look something like this, but I'm not sure what else I need, besides maybe…

Dreiven
- 687
- 3
- 9
- 22
5
votes
1 answer
How is texture data accessed on the GPU in OpenGL?
I don't fully understand the way texture data is accessed on the GPU. If possible - could anyone explain these?
When the number of texture units is limited, does this limit the number of textures I can generate using glGenTextures() and upload to…

user1081465
- 61
- 1
- 5
5
votes
1 answer
What does border mean in the glTexImage2D function?
What is the border value of glTexImage2D? It's either 0 or 1. Does it decide whether this texture will have a border or not?
Where is the border values set?
orokatu
5
votes
2 answers
OpenGL vers >=2.0 requires texture dimensions to be multiples of 4 pixels?
I'm working on a Mac application using OpenGL textures that I load from image files on disk using glTexImage2D.
According to the docs, for OpenGL versions >= 2.0, textures can be any arbitrary size. (for versions <2.0, the x and y dimensions both…

Duncan C
- 128,072
- 22
- 173
- 272
5
votes
1 answer
gl texture sampler always returning vec4(0.,0.,0.,1.) on iOS (but is functional on OSX/Android)
I have code that just uploads some contrived data to a texture:
glActiveTexture(GL_TEXTURE0+gl_sim_texture_active_n);
glBindTexture(GL_TEXTURE_2D, gl_sim_texture_buff_id);
for(int i = 0; i < w*h; i++) buff[i] =…

Phildo
- 986
- 2
- 20
- 36
5
votes
1 answer
How to use unsigned short in an opengl shader?
I'm trying to upload a texture with unsigned shorts in a shader but it's not working.
I have tried the following:
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, vbt[1]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 640, 480, 0, GL_RED,…

eaponte
- 409
- 5
- 15
4
votes
2 answers
OpenGL with C++: vtable troubles when passing class array to glTexImage2d
I made a class Color with float r, float g, float b, float alpha. It has a base class with a virtual destructor.
I am trying to pass an array of Color to the opengl function glTexImage2D, with a GL_RGBA organization of type float (which would be an…

Nicolas Lutz
- 93
- 1
- 7
3
votes
3 answers
How can I use a dynamically sized texture array with glTexImage2D?
Currently, I'm able to load in a static sized texture which I have created. In this case it's 512 x 512.
This code is from the header:
#define TEXTURE_WIDTH 512
#define TEXTURE_HEIGHT 512
GLubyte…

Nick Bolton
- 38,276
- 70
- 174
- 242
3
votes
1 answer
Opengl textures and endianness
I'm using glTexSubImage2D with GL_LUMINANCE and GL_UNSIGNED_BYTE to display raw greyscale data from a camera directly - rather than having to repack it into an RGB bitmap manually.
I would like to run the camera in higher resolution mode, with 12 or…

Martin Beckett
- 94,801
- 28
- 188
- 263
3
votes
0 answers
glTexImage2D memory usage in RAM (used in conjunction with an FBO)
When using glTexImage2D to attach textures to a Framebuffer Object (FBO), i recognized that the memory usage goes up in RAM. It looks like textures are allocated by OpenGL not only on the GPU but also in main memory.
Why is that happening?
Does it…

j00hi
- 5,420
- 3
- 45
- 82
3
votes
1 answer
glTexImage2D vs. gluBuild2DMipmaps
Very basic OpenGL texture creation code:
int width, height;
BYTE * data;
FILE * file;
// open texture data
file = fopen( filename, "rb" );
if ( file == NULL ) return 0;
// allocate buffer
width = 256;
height = 256;
data =(BYTE*) malloc( width *…

jalal sadeghi
- 362
- 4
- 19