Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  glTexSubImage2D  (Read 1883 times)
0 Members and 1 Guest are viewing this topic.
Offline DavidYazel

Junior Devvie

Java games rock!

« Posted 2003-11-23 00:11:28 »

I have been looking into using this function and I had a question.  It looks like the API requires that the image you are submitting as a replacement must be a contiguous piece of memory.  In other words if you have 512x512 texture and you want to replace a 200x200 peice of it, you must have the image data in 4*200*200 array of bytes (including alpha).

This makes it pretty expensive to use since we would have to create temporary buffers to hold that.  What I would like to do is update a portion of the PC memory copy of the texture and then transfer that portion into texture on the 3d card.  But it looks like I would have to create a buffer, copy the data from the PC memory image into the buffer and then update the texture with the buffer.  That copy is going to be expensive, and the buffer memory is going to hurt also.

Am  I understanding the interface properly?  Any suggestions on how I can make this perform well?

What I thought would be nice is to expose several functions on the ImageComponent2D.  One would take an array of "dirty" rectangles of the main image which would result in the subimages being moved over on the next frame, sourced by the image components memory buffer.  One would take an image and would move that over on the next frame, sourced by the supplied image.

David Yazel
Xith3D Project Founder

It may look complicated, but in the end it is just a bunch of triangles
Offline Yuri Vl. Gushchin

Senior Devvie

Speak Java!

« Reply #1 - Posted 2003-11-23 08:24:39 »


So, if I understand you properly, you want to modify texture image stored in backing store of DirectBufferedImage in-place [without allocating new array] and transfer only updated [dirty] areas using glTexSubImage2D?

If you will use glTexSubImage2D alone, you will have to make a copy. But you can make a trick - you can specify glPixelStore* parameters to describe format how your texture data is stored in memory. You will have to specify GL_UNPACK_ROW_LENGTH (defines stride X, i.e. width of original texture), GL_UNPACK_SKIP_PIXELS (X offset of dirty rect), and GL_UNPACK_SKIP_ROWS (y offset of dirty rect). This will define the storage model of texture data, and subsequent call to glTexSubImage2D(...) will copy only data defined by this model. The width and height of dirty rect will be defined in glTexSubImage2D call as width and height.

Also please keep GL_UNPACK_ALIGNMENT = 1 (i.e. don't change it) - the def alignment was 4, and it was a source of bug with small (1x1 and 2x2) RGB textures because of row was not multiple of 4 [caused strange and funny color shifts].


Yuri Vl. Gushchin
JProof Group
Offline DavidYazel

Junior Devvie

Java games rock!

« Reply #2 - Posted 2003-11-23 11:10:50 »

Wow, can I tell you I would never have figured that out?  I will give it a shot and see how it goes.

David Yazel
Xith3D Project Founder

It may look complicated, but in the end it is just a bunch of triangles
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline DavidYazel

Junior Devvie

Java games rock!

« Reply #3 - Posted 2003-11-23 21:44:13 »

Works like a champ.  Changes have been tested and committed.  In addition isLive() now is dependable, the user interface is 100 times faster and uses half the texture memory and 1/3 the PC memory.

David Yazel
Xith3D Project Founder

It may look complicated, but in the end it is just a bunch of triangles
Offline Daath

Junior Devvie

Java games rock!

« Reply #4 - Posted 2003-11-23 22:15:12 »

been patiently waiting for this a while .... GREAT!!!! Cheesy
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Jesse (11 views)
2015-07-29 04:35:27

Riven (33 views)
2015-07-27 16:38:00

Riven (16 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (10 views)
2015-07-27 12:23:39

BurntPizza (28 views)
2015-07-25 00:14:37

BurntPizza (39 views)
2015-07-24 22:06:39

BurntPizza (22 views)
2015-07-24 06:06:53

NoxInc (25 views)
2015-07-22 22:16:53

NoxInc (17 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!