Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (578)
games submitted by our members
Games in WIP (499)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Loading Resources in Runnable Jar on: 2014-04-17 02:42:45
Danny, you're a lifesaver! That worked great!

Now I'm just going to strip out the Guava stuff; very useful tool!

- Steve
2  Game Development / Newbie & Debugging Questions / Re: Loading Resources in Runnable Jar on: 2014-04-16 17:02:35
Wow! That is awesome! I'm going to have to give this a shot; thank you so much! Smiley

- Steve
3  Game Development / Newbie & Debugging Questions / Loading Resources in Runnable Jar on: 2014-04-16 15:55:07
So, I have the following code in a method to load all PNG files found in a specific directory as textures.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
String files;
File folder = new File(GRAPHICS_FILE_PATH);
File[] listOfFiles = folder.listFiles();
           
for (int i = 0; i < listOfFiles.length; i++)
{          
       if (listOfFiles[i].isFile())
       {
          files = listOfFiles[i].getName();
           if (files.endsWith(".png") || files.endsWith(".PNG"))
           {                    
              Texture temp = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(GRAPHICS_FILE_PATH + "/" + files));
              texture.put(files.substring(0, files.indexOf(".")), temp);
                }
        }
}


This works great when testing in the IDE, but I want to distribute my final program as a runnable jar. Since there is only a single jar file and not this blown up file structure, the program freaks out saying it can't find the specified resource.

If I hard code the texture names, slick's ResourceLoader class works great in a jar or when the file structure exists; where's the fun in hard-coding all those texture filenames though? This is programming; we want things done automatically! Wink

My question is: is there a simple way to retrieve all the resources at a specific path in either a jar or file structure? I found this method, but I'm not having much luck implementing it in a way I can just point to "res/graphics"; it seems to depend on the same folder where the provided class exists.

- Steve
4  Games Center / WIP games, tools & toy projects / Re: Helibomber SDX on: 2014-01-07 14:51:07
Here's a short trailer showing the arcade action in motion! Take a look!  Shocked

<a href="http://www.youtube.com/v/sPZsyAwuSp0?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/sPZsyAwuSp0?version=3&amp;hl=en_US&amp;start=</a>

- Steve
5  Games Center / WIP games, tools & toy projects / Helibomber SDX on: 2014-01-05 21:53:07
Hey guys!

Port/rewrite of the old S&F Software freeware game Helibomber DX here - Helibomber SDX (SUPER Deluxe)!! New additions include original soundtrack, controller support, online high scores, and some fun, new gameplay features.



Basically, if you like some of the classics like Defender of Choplifter, you'll be able to sink some time into this one. It's a very straightforward arcade-type game that gets hard pretty quickly.

Follow us on twitter for updates! More info coming soon!

- Steve
6  Java Game APIs & Engines / OpenGL Development / Re: Easiest Way to Pass Textures to Fragment Shader on: 2013-09-03 21:08:56
Hmm, then I find pages like this where it makes me think those can just be populated by something like this in the vertex shader:

1  
2  
3  
4  
5  
6  
7  
8  
void main()
{
    // Transforming The Vertex
   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

    // Passing The Texture Coordinate Of Texture Unit 0 To The Fragment Shader
   texture_coordinate = vec2(gl_MultiTexCoord0);
}


From - http://stackoverflow.com/questions/11537356/pass-through-vertex-shader-for-texture-mapping

I keep thinking about this in terms of me setting an attribute from my Java code in the shader program...

- Steve
7  Java Game APIs & Engines / OpenGL Development / Re: Easiest Way to Pass Textures to Fragment Shader on: 2013-09-03 13:50:19
So I am messing around with the rendering method for individual sprites. I think I'm starting to get an idea of how things'll work, but I still have to bind the TexCoord to the vertex shader as an attribute, correct?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
// Bind the current texture to the current shader if one is in use.
if(useShader)
{
     setShaderUniform(currentShader, "texture", getTextureId(temp));
}
           
temp.bind();
           
float fSrcX = ((float)srcX / temp.getTextureWidth());
float fSrcY = ((float)srcY / temp.getTextureHeight());
float fSrcWidth = (((float)srcX + (float)srcWidth) / temp.getTextureWidth());
float fSrcHeight = (((float)srcY + (float)srcHeight) / temp.getTextureHeight());
           
GL11.glColor4f(red, green, blue, alpha);
GL11.glBegin(GL11.GL_QUADS);
// Top Left
GL11.glTexCoord2f(fSrcX, fSrcY);
GL11.glVertex2f(x,y);
// Top Right
GL11.glTexCoord2f(fSrcWidth, fSrcY);
GL11.glVertex2f(x + width, y);
// Bottom Right
GL11.glTexCoord2f(fSrcWidth,fSrcHeight);
GL11.glVertex2f(x + width,y + height);
// Bottom Left
GL11.glTexCoord2f(fSrcX,fSrcHeight);
GL11.glVertex2f(x,y + height);
GL11.glEnd();


Thanks for answering the endless of array of stupid questions. Smiley

- Steve
8  Java Game APIs & Engines / OpenGL Development / Re: Easiest Way to Pass Textures to Fragment Shader on: 2013-09-03 04:41:22
So the way I'm reading this... when you bind a texture to a quad, it should automatically be handed off to the vertex shader where it can, in turn, be processed by the fragment shader?

Do you need to manually modify any uniforms in the shaders for the texture or anything?

Great tutorials, by the way. I was going off the LWJGL ones which use the ARB stuff. I've done a decent amount of 2D game dev in the past, but never really messed with shaders til now; seems like you can do some really cool stuff with them.

- Steve
9  Java Game APIs & Engines / OpenGL Development / Easiest Way to Pass Textures to Fragment Shader on: 2013-09-03 02:04:58
Hey guys,

I'm pretty new to shaders, so I'm a little bit stuck. What i'm trying to do *should* be easy. I'm trying to get the current pixel and multiply it by another color to get kind of a blue hue over the entire screen (not including the HUD). The end goal is to kind of have a night type feel to everything by doing this.

It seems like every example I am finding uses the SpriteBatch class with LibGDX or Slick to handle passing texture data to the shader. I already have a large portion of rendering code in place and I'd like to find a way to do something like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
ARBShaderObjects.glUseProgramObjectARB(shaderProgram);
updatePlayingField(0);      
Actor.updateCast();                        
player.update();  
updatePlayingField(1);
Particle.updateAll();
ARBShaderObjects.glUseProgramObjectARB(0);

FloatingText.updateAll();
updateHUD();


That would be in my main game loop. Basically I have a simple shader working now, but all it does is change every pixel to a specific color. All of the individual sprites are drawn in each of those methods in that loop. It doesn't seem possible that I can just get the "current" pixel color value when the fragment shader is run sadly... Sad

Is there an easy way to handle shaders without re-writing all of my existing rendering code and over-complicating the systems I already have in place? I guess another option might be that I could apply a shader to the entire buffer before rendering the HUD? I don't know - any and all suggestions are welcome. More code available upon request - didn't want to overcomplicate things since I have basic shaders already working. Grin

- Steve
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (28 views)
2014-04-15 18:08:23

BurntPizza (26 views)
2014-04-15 03:46:01

UprightPath (41 views)
2014-04-14 17:39:50

UprightPath (23 views)
2014-04-14 17:35:47

Porlus (40 views)
2014-04-14 15:48:38

tom_mai78101 (62 views)
2014-04-10 04:04:31

BurntPizza (121 views)
2014-04-08 23:06:04

tom_mai78101 (221 views)
2014-04-05 13:34:39

trollwarrior1 (188 views)
2014-04-04 12:06:45

CJLetsGame (196 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!