Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (532)
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  
  Jogl textures suddenly gone[solved]  (Read 619 times)
0 Members and 1 Guest are viewing this topic.
Offline midramble

Junior Newbie





« Posted 2013-03-06 05:06:03 »

Hi all, I'd like to start off by saying I love this site and that this is my first actual post.  Grin

Alright, so here's the story...

I had a program which created objects and put them in a main list (arraylist). These objects would load an image into a texture data buffer map (map so that they had a string identifier) and when the renderer class display method was called from the fpsanimator it would iterate over the buffer map, using the textureIO.newtexture method (because the context is now current), load it into a loadedtexture map, enable the texture, call the display method of each object in the main list, and then clear the buffer. These display methods would bind the needed textures from the loadedtexture map in my renderer class and execute the drawing functions.

This program would normally render correctly. Though I started obviously having simultaneous modification errors on my buffer map because of my main thread adding textures at the same time the animator thread is causing the renderer display thread to iterate over the buffer.

Instead of creating a synchronized modification method for the map I decided to instead make it an arraylist where the main thread could write textures to the end of the list while the animator thread could peal off the first object in the list to use textureIO so that there were no longer thread collisions. To do this I had to make it an arraylist of object[2] with the 0 value being the string identifier and the 1 value being the texture.

Now the textures aren't showing up. After a bit of ghetto debugging I know that the string identifiers in the loadedtexturemap are correct and that the texture data of each key/value pair at least has the correct img height/width showing that they at least aren't null or duplicated. I'm not sure how to println straight pixel array data of textures to make sure that the textures actually have data that should be rendering (btw the textures are RGBA png)

I guess my question is, how (in debugging) can I determine if the texture that I am using has valid data?

Also the only reason I haven't uploaded the code yet is because it seems like a lot to upload here and I'm a bad bad programmer for not putting good comments to make the code readable. I'll upload at least the applicable methods once I get my comments in there  Undecided

Bourbon, Muddy Waters, Cigars, and Java MMORPG programming Cheesy
Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #1 - Posted 2013-03-06 07:38:01 »

1: Use a HashMap.
2: Load all the textures at the start of the game.

Offline midramble

Junior Newbie





« Reply #2 - Posted 2013-03-06 08:18:03 »

Sorry, I should have been a bit more specific. The maps I am using are hashmaps and I can't load EVERY texture at the beginning because there are a massive amount of textures. I'm having the textures loaded based on needs of the zone that the player is in at that moment.

Update: I just tried rewriting the program with a new class called texture pack that has a String Name field and TextureData Data field and created an arraylist with this object (just in case the object[] arraylist concept was what was causing the problem.) Results are still the same, so I'm thinking something may be bad with the input stream...  Clueless  Again, it'd be great if I could find a way to look at the actual pixel array of the texture to see if there is anything there.... Huh

I'll keep updating. Thanks for the feedback HeroesGraveDev

Bourbon, Muddy Waters, Cigars, and Java MMORPG programming Cheesy
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline midramble

Junior Newbie





« Reply #3 - Posted 2013-03-13 03:38:14 »

Hahaha wooow. Whelp this was a case of severe over-thinking haha. I did end up optimizing my rendering pipeline as a result though, which isn't a bad thing. Turns out that all that happend was when I modified my first loaded png and replaced it, I somehow saved it at non power of 2 size. All's fine now. Back to pounding out code and sorry for wasting forum space haha  Clueless

Bourbon, Muddy Waters, Cigars, and Java MMORPG programming 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.

pw (17 views)
2014-07-24 01:59:36

Riven (17 views)
2014-07-23 21:16:32

Riven (14 views)
2014-07-23 21:07:15

Riven (17 views)
2014-07-23 20:56:16

ctomni231 (43 views)
2014-07-18 06:55:21

Zero Volt (40 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (36 views)
2014-07-16 23:30:00

Cero (51 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!