Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (575)
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 1671 times)
0 Members and 1 Guest are viewing this topic.
Offline DavidYazel

Junior Duke




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
http://xith3d.dev.java.net

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

Senior Duke




Speak Java!


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

Hi,

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


Yuri Vl. Gushchin
JProof Group
Offline DavidYazel

Junior Duke




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
http://xith3d.dev.java.net

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 Duke




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
http://xith3d.dev.java.net

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

Junior Duke




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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (34 views)
2014-10-17 03:59:02

Norakomi (25 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (26 views)
2014-10-15 16:18:58

TehJavaDev (50 views)
2014-10-14 00:39:48

TehJavaDev (50 views)
2014-10-14 00:35:47

TehJavaDev (40 views)
2014-10-14 00:32:37

BurntPizza (63 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (74 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!