LWJGL
February 07, 2012, 06:40:57 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: Empty texture creation  (Read 2682 times)
Zengar
Newbie
*
Posts: 2


« on: April 19, 2007, 01:38:54 »

Hi,

 I need to create some empty textures. That is, pass last parameter to glTextImage* as zero pointer. Is it even possible?  It is very annoying, having to create all that temporary buffers noone needs.

 Optional question: Also, what is the fastest way to convert java string with a shader source to a byte buffer? Smiley

 Thanks!

Logged
Matzon
Administrator
Demigod
*****
Posts: 2163



« Reply #1 on: April 19, 2007, 02:00:49 »

Why dont you just create 1 buffer and reuse it ?
many people create a 256 byte "scratch" buffer and then position and limit or slice it accordingly.


as for the shader stuff:
byte[] bytes = sharderstring.getBytes();
ByteBuffer b = BufferUtils.createByteBuffer(bytes.length);
b.put(bytes).flip();
Logged

http://certusgames.com (Free Online Multiplayer Java Games)
http://lwjgl.org (OpenGL/OpenAL for Java)
Zengar
Newbie
*
Posts: 2


« Reply #2 on: April 19, 2007, 04:41:46 »

Thanks a lot!

Well, I would like to elliminate the useless copy... Also, additional 5 Mb do make a difference. Could you probably consider adding such feature to the next library release? Something like EmptyBuffer etc. Or a new function entry without data pointer.

Logged
elias
Nerdus Imperius
*****
Posts: 899



WWW
« Reply #3 on: April 19, 2007, 05:29:59 »

You can pass in a null buffer just fine. Remember to cast the null buffer to something ("(ByteBuffer)null") to tell javac which overloaded version of glTexImage you want.

 - elias
Logged

elias
Nerdus Imperius
*****
Posts: 899



WWW
« Reply #4 on: April 19, 2007, 05:31:08 »

Btw, the upcoming version of LWJGL adds support for non-direct buffers, so you can be more liberal with the buffer allocation (at least for init code).

 - elias
Logged

Fool Running
Nerdus Imperius
*****
Posts: 628


« Reply #5 on: April 19, 2007, 11:33:33 »

Quote
Btw, the upcoming version of LWJGL adds support for non-direct buffers, so you can be more liberal with the buffer allocation (at least for init code).
Really? What's the reason for that? It seems like so much effort has gone into forcing direct buffers, I'm curious why the sudden change? Won't that cause a performance hit? (I thought that was the reason for the direct buffers in the first place)
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
elias
Nerdus Imperius
*****
Posts: 899



WWW
« Reply #6 on: April 19, 2007, 13:55:50 »

Quote
Btw, the upcoming version of LWJGL adds support for non-direct buffers, so you can be more liberal with the buffer allocation (at least for init code).
Really? What's the reason for that? It seems like so much effort has gone into forcing direct buffers, I'm curious why the sudden change? Won't that cause a performance hit? (I thought that was the reason for the direct buffers in the first place)

You're half way right. We've advocated direct buffers, and still do - they're faster than non-direct buffers. Non-direct buffer support is implemented as a slower fallback. The support should not affect the performance of direct buffers, since we already check isDirect() for sanity checking - the difference is that instead of throwing an exception, we fall back to a different code path.

  - elias
Logged

Fool Running
Nerdus Imperius
*****
Posts: 628


« Reply #7 on: April 23, 2007, 09:39:42 »

Ah, OK. Thanks for clearing that up Smiley
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!