GL11.glTexImage2D(target, 0, pixelFormat, width, height, 0, srcPixelFormat, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);
GL11.glTexSubImage2D(target, 0, 0, 0, texWidth, texHeight, srcPixelFormat, GL11.GL_UNSIGNED_BYTE, textureBuffer);
Where width/height is a power of 2 and texWidth/texHeight is the original dimension. pixelFormat/srcPixelFormat is GL11.GL_RGBA ... I tried some other formats but failed too.
This works on AMD and Intel but for some reason it crashes on Nvidia cards. Does anyone have a solution? Is a hack required? Thanks.
It would help a lot if we knew what error you're getting. :P
OpenGL error 1282 invalid operation
I use this way for uploading texture since ages - and it works everywhere. So it is most likely an error in your code.
http://www.opengl.org/sdk/docs/man/xhtml/glTexSubImage2D.xml
Read the very bottom of the page; it has descriptions for possible INVALID_OPERATIONs
EDIT: you're passing null as your last value to glTexImage2D
Thanks for the responses. I tried not passing null but it doesn't work either. Note that this does work on AMD/Intel but just not Nvidia which is alright weird.
I've moved to hacking the png to be the right size when it's loaded for now. Will look into it again later.