Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (555)
Games in Android Showcase (148)
games submitted by our members
Games in WIP (601)
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] 2
1  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-02-12 12:05:50
Why not going for a real challenge? Cheesy
2  Game Development / Newbie & Debugging Questions / Re: I want to use VBO instead of depreciated immediate mode.. any senior advice? on: 2015-02-05 22:01:48
It depends what you want to do with the VBOs, you could try using legacy OpenGL with client-side capabilities.
But I would recommend to learn shader programming, even if you have a GPU that only supports OpenGL 2.1.

The list of learning resources have some modern OpenGL tutorials if you want to learn shader programming.
This one helped me a lot with writing my first shaders. You could also look into my tutorial for LWJGL3, but that is still a work-in-progress.

Hope that helps Smiley
3  Game Development / Newbie & Debugging Questions / Re: LWJGL - White box instead of texture on: 2015-01-27 19:09:49
That shouldn't make a difference if you are on Linux or another OS, did that code throw an exception?

Just saw that you are creating a vertex shader, does the code work if you comment that part out?
You may also wan't to try abandoning that legacy OpenGL and start to work with shaders.
I started writing a tutorial some weeks ago for LWJGL3, you could look at it here.
Hope that helps Smiley
4  Game Development / Newbie & Debugging Questions / Re: LWJGL - White box instead of texture on: 2015-01-27 17:36:17
After deeper examination, I noticed that the byte buffer is empty. Let me see if I can override one of the functions in the PNG decoder to make it return it's value instead.

Well in that case you could load the picture with
ImageIO
and put the data into the buffer yourself.
Here's an example code of how you could load your image Wink

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  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
BufferedImage image = null;
try {
    InputStream in = this.getClass().getResourceAsStream("textures/" + name + ".png");
    image = ImageIO.read(in);
} catch (IOException ex) {
    throw new RuntimeException("Failed to load a texture file!"
        + System.lineSeparator() + ex.getMessage());
}
if (image != null) {
    /* Get width and height of image */
    int width = image.getWidth();
    int height = image.getHeight();

    /* Get pixel data of image */
    int[] pixels = new int[width * height];
    image.getRGB(0, 0, width, height, pixels, 0, width);

    /* Put pixel data into a ByteBuffer */
    ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * 4);
    for (int y = 0; y < height; y++) {
        for (int x = 0; x < width; x++) {
            /* Pixel as RGBA: 0xAARRGGBB */
            int pixel = pixels[y * width + x];

            /* Red component 0xAARRGGBB >> 16 = 0x0000AARR */
            buffer.put((byte) ((pixel >> 16) & 0xFF));

            /* Green component 0xAARRGGBB >> 8 = 0x00AARRGG */
            buffer.put((byte) ((pixel >> 8) & 0xFF));

            /* Blue component 0xAARRGGBB >> 0 = 0xAARRGGBB */
            buffer.put((byte) (pixel & 0xFF));

            /* Alpha component 0xAARRGGBB >> 24 = 0x000000AA */
            buffer.put((byte) ((pixel >> 24) & 0xFF));
        }
    }

/* Do not forget to flip the buffer! */
buffer.flip();

} else {
    throw new RuntimeException("File extension not supported!"
        + System.lineSeparator() + "The following file extensions "
        + "are supported: "
        + Arrays.toString(ImageIO.getReaderFileSuffixes()));
}
5  Game Development / Newbie & Debugging Questions / Re: LWJGL - White box instead of texture on: 2015-01-27 16:48:59
Don't know about that PNGDecoder, if it decodes the image to the right format, so I just assume, that the ByteBuffer is filled with the right data.

In your rendering code I see, that you use
texture.getTextureHeight()
, but Texture coordinates go from 0.0 to 1.0 so change your rendering to this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
glBegin(GL_QUADS);
{
    glTexCoord2d(0, 0);
    glVertex2d(0, 0);

    glTexCoord2d(0, 1);
    glVertex2d(0, texture.getImageHeight());

    glTexCoord2d(1, 1);
    glVertex2d(texture.getImageWidth(), texture.getImageHeight());

    glTexCoord2d(1, 0);
    glVertex2d(texture.getImageWidth(), 0);
}
glEnd();


Does that solve your problem? Smiley
6  Game Development / Newbie & Debugging Questions / Re: JAR File isn't being written correctly on: 2015-01-21 10:38:29
For reading and writing *.jar files I would take a look at JarInputStream and JarOutputStream.
Did you have already tried that? Smiley
7  Game Development / Newbie & Debugging Questions / Re: Sprite Sheet Instruction Needed on: 2015-01-13 20:51:04
glTexCoord
takes the parameters
(S, T)
. As such, the bottom left is
(0, 0)
, the bottom right is
(0, 1)
, the top left is
(1, 0)
and the top right is
(1, 1)
.
I think bottom right is
(1,0)
and top left is
(0,1)
Smiley
8  Java Game APIs & Engines / OpenGL Development / Re: Lwjgl Error: Failed to load the native library: lwjgl on: 2014-12-19 17:09:13
When you get that error, then you haven't set the
org.lwjgl.librarypath
correctly.
You could copy the native folder to the folder that contains the jar. Then in your main method do this:

1  
2  
3  
4  
5  
if (System.getProperty("org.lwjgl.librarypath") == null) {
    Path path = Paths.get("native");
    String librarypath = path.toAbsolutePath().toString();
    System.setProperty("org.lwjgl.librarypath", librarypath);
}


Does this work for you? Smiley
9  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-12-19 11:27:23
Started a LWJGL3 Tutorial Smiley
Oh and also made my 40th post on JGO right now Cheesy
10  Games Center / WIP games, tools & toy projects / Re: Legends of Fore on: 2014-11-28 11:17:19
That Google German translation is horrible, it should be:

"Hallo, willkommen auf dem Titan, wir führen hier archäologische Forschungen durch."
"Danke" - "Was?"

What about a Japanese translation? Cheesy
11  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-11-26 11:15:56
Had a meeting with my Computer Graphics professor to talk about my thesis Smiley
12  Game Development / Game Play & Game Design / Re: Where can I get nice spritesheets and images? on: 2014-11-19 13:45:33
You can find a lots of links at gamedev.stackexchange.com.
Maybe you'll find something like that Smiley
13  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-11-14 17:22:42
Installed Linux Mint 17 on VirtualBox to test it out.
Seems like an alternative to Windows! Cheesy
14  Discussions / General Discussions / Re: Someone pick my license! on: 2014-11-10 08:43:54
I would look here or here.

I think this one would be your best bet!
Quote
Under the following terms:
  • Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • NonCommercial — You may not use the material for commercial purposes.
  • NoDerivatives — If you remix, transform, or build upon the material, you may not distribute the modified material.
  • No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.

Or you could write your own license of course Wink

Hope that helps a bit Smiley
15  Game Development / Newbie & Debugging Questions / Re: Best way to iterate through ArrayList? on: 2014-10-17 21:40:27
If you think that's crazy...
Didn't want to make it too complicated Cheesy
16  Game Development / Newbie & Debugging Questions / Re: Best way to iterate through ArrayList? on: 2014-10-17 21:33:41
Streams are probably my new favorite way of going through some Collection to perform operations on it. They're like LINQ for Java! Smiley

I like Streams too, so if you use Java 8 you can use them!

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
// One Operation
array.stream().forEach(val -> val.doSomething());

// Multiple Operations:
array.stream().forEach(val -> {
    val.doSomething();
    val.doSomeOtherThings();
});

// You could even make crazy things like this:
array.stream().filter(val -> val.isAThing())
              .forEach(thing -> thing.doSomething());

Just wanted to show some examples for this Wink
For some more methods you can look into the Java Doc.
17  Game Development / Game Mechanics / Re: Connected Textures? on: 2014-09-28 17:18:49
Here's another tutorial for tiling:
http://www.angryfishstudios.com/2011/04/adventures-in-bitmasking/

There's also an example for the 8-bit case Wink
18  Discussions / General Discussions / Re: Looking for a good and detailed lwjgl tutorial on: 2014-08-16 09:28:48
There is also the List of Learning Resources here on JGO!
You can find some good tutorials there Wink
19  Game Development / Newbie & Debugging Questions / Re: Levels rendered sideways? on: 2014-07-27 09:42:25
That's because OpenGL has its origin in the lower left corner.
Like trollwarrior1 said already you could flip the y Coordinate with
screenHeight - y;
or else you could just initalize OpenGL with
glOrtho(0, screenWidth, screenHeight, 0, -1, 1);
, then you have your origin in the top left.
There's nothing wrong with changing the orthographic projection Wink
20  Discussions / General Discussions / Re: New feature: Embedded PDFs on: 2014-07-19 16:48:02
Sadly this feature don't work on Opera - even though it is using the same engine as Chrome. After clicking "click this page to load the PDF" download is initalized, but nothing appears.
I'm using Opera 12.17 (64-bit) and it works fine for me Smiley
Don't know if there's a different engine with other versions.
21  Game Development / Newbie & Debugging Questions / Re: LWJGL BufferedImage white image on: 2014-07-13 11:37:32
Hmmm, still not working...
Just saw that you do
glLoadIdentity()
between
glBegin(...)
and
glEnd()
.

You'll get an OpenGL Error when doing this:
GL_INVALID_OPERATION is generated if glLoadIdentity is executed between the execution of glBegin and the corresponding execution of glEnd.

So does it work if you delete that
glLoadIdentity()
? Smiley
22  Game Development / Newbie & Debugging Questions / Re: LWJGL BufferedImage white image on: 2014-07-13 10:49:52
You haven't set your texture scaling parameters.
Try calling this between
GL11.glBindTexture(...)
and
GL11.glTexImage2D(...)
:

1  
2  
3  
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
// Alternatively you could use GL11.GL_LINEAR instead of GL11.GL_NEAREST

After that you should see your texture Wink

Also you should do
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID)
before drawing your image.
Hope that helped Smiley
23  Game Development / Newbie & Debugging Questions / Re: Rectangles not drawn after Texture is initialized on: 2014-06-12 23:23:06
Ha. But I didn't actually draw the texture yet. When I do it gets rid of the rectangle. That's the problem.
Do you bind your texture? Roll Eyes
And instead of
glRectf(x1, y1, x2, y2)
you could try this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
// Note: This method assumes that x1 < x2 and y1 < y2, and also that the texture origin is bottom left.
public void drawRect(float x1, float y1, float x2, float y2) {
    glBegin(GL_QUADS);
        glTexCoord2f(0f, 0f);
        glVertex2f(x1, y1);
        glTexCoord2f(1f, 0f);
        glVertex2f(x2, y1);
        glTexCoord2f(1f, 1f);
        glVertex2f(x2, y2);
        glTexCoord2f(0f, 1f);
        glVertex2f(x1, y2);
    glEnd();
}

Before calling
drawRect(x1, x2, y1, y2)
you should do
glBindTexture(GL_TEXTURE_2D, textureId)
.
Does that solve your problem? Smiley
24  Game Development / Newbie & Debugging Questions / Re: Should I use Java Observer? on: 2014-06-11 14:10:09
Well the benefit from using the Java Observer is, that you don't have to write it yourself Roll Eyes

The only things you would have to do:
  • Create your Entity class (extends java.util.Observable)
  • Create an EntityObserver class (implements java.util.Observer)
  • When creating a entity do
    entity.addObserver(observer)
  • When a change in your entity happens do
    setChanged()
    and
    notifyObservers()

I wouldn't bother writing your own Observer pattern Wink
25  Discussions / General Discussions / Re: [Swing] Can swing look sexy? on: 2014-05-28 17:24:06
JavaFX is supposedly the future, but so far it's a *tumbleweed* - who's making anything beyond trivial demos with it?
I'm making a WM 2014 Live Ticker for a lecture project... then again, it is a trivial application... Roll Eyes
It probably won't even be completed because my teammates are rather lazy... I neither have the will nor the time to program their parts too Emo

In the end I still prefer Swing over JavaFX.
26  Games Center / Featured Games / Re: [Slick2d] Retro-Pixels Castle Survival - Top Down Survival Mayhem! on: 2014-05-25 10:04:12
There was a good tutorial that I found (though I can't find it again) that explained how to use powers of two.

The first tutorial that comes to my mind is this one.
Is that the tutorial you had in mind? Smiley
27  Game Development / Shared Code / Re: json on: 2014-05-23 14:59:52
Now that you have a JSON Parser you could expand it to a YAML (v1.2) Parser Grin

And +1 for the recursive descent parser Smiley
28  Discussions / General Discussions / Re: [Swing] Can swing look sexy? on: 2014-05-07 17:52:27
Instead of Swing you could also use JavaFX, there you could even do some 3D Graphics an such.
And you can style your GUI like you want with Cascading Style Sheets. Wink
A easy start would be this tutorial Pointing

I actually think that Oracle wants JavaFX to replace Swing someday... in every Swing-Tutorial there's something about learning JavaFX.
29  Discussions / General Discussions / Re: [Web Games] What is the best second language? on: 2014-05-01 09:44:09
Well you could also use HTML for making games Roll Eyes
30  Game Development / Newbie & Debugging Questions / Re: Opening an inventory Screen on: 2014-04-10 21:37:57
Hey I'm trying to put in your StateStack right now and the issue I have is on line 8 where it reads " pushState(states.get("MainGame")); "
I get an error that reads
"The method pushState(String) in the type StateStack is not applicable for the arguments (State)"

however if I make it so that
the pushState Method in line 22 takes a state instead than it compiles, I cant really test it yet cause I dont have my inventory and all set up yet, but any idea on whats going on with that?

Oh... that's my bad Lips Sealed
Of course it should be like this:
1  
2  
3  
4  
5  
public StateStack() {
   addState("MainGame", new MainGameState());
   addState("InventoryState", new InventoryState());
   pushState("MainGame");
}

I messed it up when I copy&pasted the StateMachine and changed it to the StateStack Roll Eyes
Maybe I should change it in the StackMachine as well so it looks similar persecutioncomplex
I'll fix it in the code above! Thanks Wink
Pages: [1] 2
 
BurntPizza (27 views)
2015-02-27 06:09:35

BurntPizza (21 views)
2015-02-27 05:56:17

Riven (14 views)
2015-02-27 02:34:15

Riven (20 views)
2015-02-27 01:47:26

Riven (19 views)
2015-02-27 01:46:04

BurntPizza (15 views)
2015-02-27 00:52:04

BurntPizza (16 views)
2015-02-27 00:50:29

Riven (36 views)
2015-02-26 23:38:45

Riven (13 views)
2015-02-26 23:37:24

BurntPizza (31 views)
2015-02-26 21:13:04
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

Resources for WIP games
by kpars
2014-12-18 10:26:14

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
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!