Can anyone see what’s wrong with this code?
SIZE_BG is 6MB as I am trying to draw a large bitmap image (3366×600). I use malloc to prevent my image from overflowing the stack. I get an access violation error on the call to glDrawPixels(). bgPtr seems to point to the correct data as I checked the first few bytes before calling glDrawPixels and they are correct.
bgPtr = (char*)malloc(SIZE_BG); fstream inFile(texFileName, ios::in | ios::binary); inFile.read(bgPtr, SIZE_BG); inFile.close(); //... other code glDrawPixels(3366, 600, GL_BGRA_EXT, GL_UNSIGNED_BYTE, bgPtr+54);
3366 × 600 is approximately 1.92 million pixels
BRGA indicates 4 bytes per pixel
so, 3366 × 600 × 4 is just over 7.7MB
Therefore, your buffer is too small…
glDrawPixels()will read past the end into unallocated memory.