Show Posts
|
|
Pages: [1] 2
|
|
2
|
Java Game APIs & Engines / OpenGL Development / Experiencing random colours when rendering GL_QUADS and Slick's UnicodeFont
|
on: 2012-08-18 16:22:01
|
I accidentally made this paste upside down. If you can, start reading at ln59, then read from the top. http://pastebin.com/g2fpTzkABasically, if I don't use UnicodeFont at all; there are no issues. The colours are as intended, in the correct order. But of course there's no text. There are links to the screenies towards the bottom of the paste. Is there anything obvious that I'm doing wrong? My initial thought was some sort of mismatch in the getters and setters from my Colour class (which I handcoded). But i've checked them a half dozen times now. Theres no issue there. (was imagining something stupid like returning _g in getB() or something - no such luck)
|
|
|
|
|
4
|
Java Game APIs & Engines / Engines, Libraries and Tools / Re: Creating a cross-platform launcher
|
on: 2012-08-15 09:36:14
|
For Linux and Mac OS X, the user.home + ".<name>" is all you need.
The point isn't "all you need", the point is trying to follow the standards for whatever OS your program is running on. You could put your save in C:\Users\ZMan\GameName\player1.sv and call it good, but instead we put it in %AppData%\GameName\player1.sv because it's cleaner and is what is expected on Windows. If you don't care about that then ya, user.home + gameName works just fine. I was just looking for an AppData equivalent on Linux/OSX. While we're on the topic of standards, and expected behaviour; there's one that I *hate*. <rant> When games/applications put binary data (usually some sort of save file) in the designated documents folder. My Documents on XP, Documents on Vista/7/8, user.home/Documents on linux. And you can't even relocate the data half the time without breaking the associated app. Its a super irritating habit that too many devs have. Thats what the %appdata% folder is *for* !!! </rant>
|
|
|
|
|
5
|
Java Game APIs & Engines / Engines, Libraries and Tools / Re: Creating a cross-platform launcher
|
on: 2012-08-14 04:42:33
|
user.home on Linux returns "/home/<username/". On Linux, all folders that start with '.' are automatically hidden. On Windows they are not, and this leads to cluttering of the home directory. It is best to put it in Application Data because then it's in its proper place in Windows and out of sight. EDIT: In no way does AppData need administrative privileges. I have UAC enabled and new File(System.getProperty("user.home") + "/Application Data/My Test Folder/").mkdir() successfully creates the folder: "C:\Users\<username>\AppData\Roaming\My Test Folder\" EDIT: UAC in Windows 7 is actually quite good now. It only prompts me for system-wide changes, like installations. It's now a good second line of defense against viruses, with your AV being the first. I recommend you turn it on  Awesome. That's really good to hear. That should be all the information I need to make this launcher work now. :-) Thanks for everything today and yesterday Ra4king.
|
|
|
|
|
6
|
Java Game APIs & Engines / Engines, Libraries and Tools / Re: Creating a cross-platform launcher
|
on: 2012-08-14 04:31:13
|
This is good enough:
..snip..
EDIT: Apparently "Application Data" also works on Vista and 7 for backwards compatibility purposes.
Thanks again Ra4king. Everything I've been reading has been saying that you require administrator rights to write to appdata on windows. I haven't experienced this issue myself because I have UAC disabled completely. But if 90% of people playing my game will be children without admin rights on their parents' PC; and as a result they cant play the game; then I want to avoid appdata at all costs. The idea that admin rights are required only came from a couple of stackexchange answers. So I'm not sure about the authenticity of the claim. ;-) At this point I think I'll roll with the appdata directories like in your code anyway; if its good enough for Ra4king and Minecraft, then its good enough for me. :-)
|
|
|
|
|
8
|
Java Game APIs & Engines / Engines, Libraries and Tools / Re: Creating a cross-platform launcher
|
on: 2012-08-14 03:08:01
|
That code is looking really good so far! Good job  For updating, it's not that hard to implement your own updater. Just have it test against a version file on the server for each file, with the launcher downloading the new version of each file. It's not that hard if you know how to properly use the java.net and java.io packages. Thanks for the input. :-) Thats exactly what I have planned to do. (Spent a few hours in bed last night reading up on exactly those; java.net and java.io packages). The challenges that I'm going to face next though; detecting the OS group, and based on the result I want to put the downloaded files in specific directories. I'm thinking %appdata% works for Minecraft on windows, so it may as well work for me too. I'm thinking along the lines of a .hidden directory in the user's home folder on linux, and I have no idea how mac's work - never used one. So I have no idea what directory is appropriate with those. I'm not sure yet on how to detect the OS, but if I can't do it in code, then I suppose I'll just have to have three different launchers. It would be silly to download the windows natives onto a linux box, and vice versa. EDIT: So I've found System.getProperty("os.name"); To be used like this: 1 2
| String os = System.getProperty("os.name").toLowerCase(); return (os.indexOf("win") >= 0); |
Will return true if the OS is windows. Cascading if-statements with "win" switched out for "nux", "nix", "mac" or "sunos" will detect which of the popular OSes we're using. So now I'm back to choosing an appropriate directory for game files for each OS. EDIT 2:I've been a minecraft player for a couple of years now - its what made me switch from XNA/C# to LWJGL/Java. I don't know if there is a specific reason of benefit of using appdata or the application support folders. But my research just now suggests that the user.home property is available on all OSes, and doesn't require administrator rights to write to. Sounds almost ideal, unless there's a reason not to? Just out of curiosity, can someone on linux and or mac give me the output of: 1
| System.out.println("user.home: " + System.getProperty("user.home")); |
Output (for me): 1
| user.home: C:\Users\Scott |
If there are no real caveats, I'm thinking of using this as my universal game-data directory: 1
| System.getProperty("user.home") + /.dtp/gamename |
|
|
|
|
|
12
|
Java Game APIs & Engines / Engines, Libraries and Tools / Re: Creating a cross-platform launcher
|
on: 2012-08-13 08:31:10
|
|
Yeah ZMan, I understand that. They use a tumblr blog with a super minimal theme. I've just set up a similar system today. The launcher now pulls a tumblr blog with a custom html-only theme I've made. (tumblr throws a random quantserv script in though - weird). At this point I'm looking at writing a program that'll run locally and pull all the data I want from various sources manually, then write them to a html file.
|
|
|
|
|
14
|
Java Game APIs & Engines / Engines, Libraries and Tools / Re: Creating a cross-platform launcher
|
on: 2012-08-13 05:09:40
|
|
Hey, its not so much an installer, as it is a launcher. It will act as an installer, but any time the user wants to run they game, they'll do it via the launcher. This will feed them any news related to the game, and automatically download any updates to the game before allowing them to launch it directly.
I use IntelliJ IDEA, but I'll look into that jmart. Thanks! :-)
gouessej, I agree that packaging the whole game in a jar file is a bad idea. Which is why I'm opting for the launcher in the fist place.
|
|
|
|
|
16
|
Java Game APIs & Engines / Engines, Libraries and Tools / Creating a cross-platform launcher
|
on: 2012-08-12 04:32:05
|
I've been using LWJGL for a couple of years now. I'm fairly comfortable with it. I've gotten to the deployment stage with one of my projects. So far I've experimented with packaging it as a zip file and letting people extract it and run the executable jar manually, that's a bit messy. I used JarSplice to create a single cross platform executable jar, that was less messy; but cramming 100mb of game files into a single jar and having people re-download the whole thing every time there's an update is not appealing to me. I'm looking for suggestions on how to get started with creating a Minecraft style launcher application. I want to: - Embed a twitter feed
- Check for newer versions and update changed files
- Use the "home" directory of the user, %appdata% on windows, the actual home directory on Linux variants
- Provide some click-able links in a sidebar
I'm confident that I can learn how to provide all of the features described on my own; but I don't know where to start. Should I be using C++, Java, C#, Mono or something else? How do I create a cross platform native application? I'm a game developer; I don't know the first thing about regular applications. What is my best option to create something like this? What other options that promote user convenience are there?
|
|
|
|
|
18
|
Java Game APIs & Engines / OpenGL Development / Crash during java error reporting, happens at "J org.lwjgl.opengl.GL11.nglBind"
|
on: 2012-03-05 05:35:12
|
Log is here: http://pastebin.com/4sgBXZheI cant seem to stop this crash from occurring. The code that binds the texture looks like this: 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
| public void render() { glPushMatrix(); glTranslatef(_position.getX(), _position.getY(), _position.getZ()); glRotatef(_rotation.getX(), 1.0f, 0.0f, 0.0f); glRotatef(_rotation.getY(), 0.0f, 1.0f, 0.0f); glRotatef(_rotation.getZ(), 0.0f, 0.0f, 1.0f); glScalef(_scale, _scale, _scale); _texture.bind(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glCallList(_listID); for(Object3D model : _children) { model.render(); } glPopMatrix(); } |
|
|
|
|
|
19
|
Discussions / General Discussions / Re: Eclipse introduces Xtend - syntax sugar for Java
|
on: 2011-11-16 04:51:09
|
yeah I'm going to write code that only works in eclipse and nobody else will even understand - good idea.
This. I find the bastardised code example in the landing video to be terribly unreadable. If I came part way into someone else's project and all the code looked like this, I would be politely stepping back out the way I came in. ;-) The types, returns, visibility modifiers all add a level of detail with no ambiguity. Its nice to see "void" and know exactly what you get out of that method, etc.
|
|
|
|
|
22
|
Game Development / Newbie & Debugging Questions / Notch making Prelude of the Chambered - IDE question
|
on: 2011-11-16 00:33:48
|
From about 15 seconds into the video (link below) Notch starts apparently coding while the game is running - and having it magically reflect his changes. I tried to stop/start the video in a sort of frame by frame manner. I notice just before he starts doing it, a properties window of some sort pops up but I'm too slow to catch it. I can see that he's using Eclipse and I understand that he uses LWJGL for his games, right? The make-up of the game seems to be an applet (I have limited experience with applets). Does anyone know how he does that? Is the application actually updating to reflect code changes without having to go through the close/build/run sequence? http://www.youtube.com/watch?v=KcfFJ6pNEZk
|
|
|
|
|
23
|
Game Development / Game Mechanics / Re: Line of sight math
|
on: 2011-11-14 12:25:26
|
|
Thanks for the responses. I made the post a couple of minutes before I had to leave for work.
Moogie: that method won't work (it was the first that I sketched on my piece of paper) because it can skip over grid spaces along the line.
counterp: I haven't read the thread yet, but thanks. That opening diagram looks very promising.
lhkbob: I'll read that too :-)
theagentdd: thanks, much appreciated - again. :-)
I think I have the solution in mind, I just need to sketch it out and code it to see if it works.
|
|
|
|
|
24
|
Game Development / Game Mechanics / Line of sight math
|
on: 2011-11-14 05:48:06
|
I've been staring at this problem for a few days now. I rigged up this graphic to help me visualise the issue:  (from the graph, we know that the line intersects [1, 1], [1, 2], [2, 2], [2, 3], ending in [3,3]) I want to step along the line to each grid space and check to see if the material of the grid space is solid. I feel like I already know the math involved, but I haven't been able to string it together yet. I'm using this to test line of sight and eliminate nodes after a path is found via my pathfinding algorithms - my agents cant see through a solid block, therefore they cant move through one, therefore the node is not eliminated from the path because it is required to navigate a corner. So, I need an algorithm that will step along the line to each grid space that it intersects. Any ideas? I've been thinking along the lines of gradients, using floor and ceiling to isolate / determine spaces, or simply stepping along the line's direction vector by a fixed amount.
|
|
|
|
|
26
|
Game Development / Newbie & Debugging Questions / [Solved] What am I missing? (2D sprite being drawn strangely)
|
on: 2011-10-28 11:14:05
|
I've got this simple sprite class: 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| public class Sprite { Texture _texture; Vector2 _position; Point2 _size; public void load(String path) { _position = new Vector2(0); try { _texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(path + ".png"));
} catch (IOException e) { } _size = new Point2(_texture.getImageWidth(), _texture.getImageHeight()); } public void draw() { Camera.enterOrtho(GameSettings.SCREEN_WIDTH, GameSettings.SCREEN_HEIGHT); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); _texture.bind(); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(getX() - getWidth(), getY() + getHeight(), 0); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(getX() - getWidth(), getY() - getHeight(), 0); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(getX() + getWidth(), getY() + getHeight(), 0); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(getX() + getWidth(), getY() - getHeight(), 0); GL11.glEnd(); Camera.leaveOrtho(); } public void setTexture(Texture texture) { _texture = texture; } public void setPosition(Vector2 position) { _position = position; } public void setX(float x) { _position.setX(x); } public void setY(float y) { _position.setY(y); } public float getX() { return _position.getX(); } public float getY() { return _position.getY(); } public Vector2 getPosition() { return _position; } public int getWidth() { return _size.getX(); } public int getHeight() { return _size.getY(); } public Point2 getSize() { return _size; } } |
Camera enter and exit ortho, for comprehensiveness: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public static void enterOrtho(int sizeX, int sizeY) { GL11.glPushAttrib(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_ENABLE_BIT); GL11.glPushMatrix(); GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix();
GL11.glLoadIdentity(); GL11.glOrtho(0, sizeX, sizeY, 0, -1, 1); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_LIGHTING); }
public static void leaveOrtho() { GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); GL11.glPopAttrib(); } |
It takes this png file:  And produces this (centre):  Its been eluding me for a fair while now - I feel like I'm missing something fairly simple. Can anyone spot it?
|
|
|
|
|
27
|
Games Center / Cube World Projects / Re: Logic behind texturing a VBO cube
|
on: 2011-10-18 17:45:22
|
Cheers. I worked out what I was doing wrong. Just for discussion purposes; Wouldn't duplicating vertices create tessellation issues? Especially with floating point accuracy taken into account with vertices that are generated algorithmically?
As I fully expected, I just ran into this.  Taking particular note of the white and magenta dotted lines on the corners of blocks. :-/
|
|
|
|
|
28
|
Games Center / Cube World Projects / Re: Logic behind texturing a VBO cube
|
on: 2011-10-18 17:22:05
|
I've rewritten most of my world-handling code to use 24 vertices per cube (six faces, four verts each). I get roughly the same framerate now as I had before, which is always good. All I'm wondering now is, what's the equivalent to this: 1 2
| glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
for use with VBOs?
|
|
|
|
|
29
|
Games Center / Cube World Projects / Re: Logic behind texturing a VBO cube
|
on: 2011-10-18 02:30:42
|
It's really hard to get texturing working on cubes that share vertices between surfaces as you'll need multiple texture coordinates for each point. The easiest way to get texturing working is to just stop reusing the vertices and have 24 vertices (3 duplicates of them all) and you won't have a problem with it. If you want to get working normals, it's impossible to share vertices, as you simply need 3 different normals for each vertex. If you were to share vertices, you'd end up with a cube that is lit like a sphere! xD I see you also want to reuse vertices between blocks connected to each others. This has the same problem. Consider a dirt block being next to a stone block. The vertices bordering between the two blocks would have to have 2 texture coordinates, one for dirt and one for stone. I seriously doubt any horrible hack would be able to outperform just duplicating those vertices. This is basically the same problem of drawing an old SNES style tile map. Preferably one would want to draw it line by line using quad-strips, but that doesn't really work due to the same problem as you're having. Now that I think about it, it would be possible to accomplish it by having a texture of mapWidth X mapHeight size with the tile index of each tile, and then in a shader first lookup what tile you should draw, then generate the tile texture coordinates from this index and the supplied (0 to 1) texture coordinates to do another "dependent" texture lookup. Yeah, doable, but once again, I seriously doubt it will be faster. Theoretically, you could do the same with a 3D texture for a block. However all I see in such a case is a shader full of if-statements, a ridiculously huge 3D texture and slideshow-like performance.
In short: You're overdoing it. Just go with a basic approach with duplicate vertices, and optimize it if needed later (but probably not by sharing vertices =P). "Premature optimization root of all evil" after all, and I'm the biggest hypocrite on Earth for telling you that. xD
Thanks for that response. I've been doing a lot of googling on the matter since I made my post. I was actually working towards implementing a shader to do it. :-) Duplicating vertices like that just seems too inefficient and too simple to implement. ;-) I actually already had that working a week ago - but I was trying to increase performance by eliminating as many vertices as possible. Just for discussion purposes; Wouldn't duplicating vertices create tessellation issues? Especially with floating point accuracy taken into account with vertices that are generated algorithmically?
|
|
|
|
|
30
|
Games Center / Cube World Projects / Re: Logic behind texturing a VBO cube
|
on: 2011-10-17 02:42:47
|
Oh, sorry. I meant 8 vertices. I'm just so used to looking at them labelled 0-7. (edited the original post) I don't actually have code to construct a cube at this point. I have code that draws thousands of them in a minecraft-styled world, with only faces that are exposed being added to the index buffer. I'm just trying to figure out the logic behind texturing them. It was vexing me, but I think I see it now.  This uses a random intensity of a green colour element. But it appears to be per physical vertex. So two cubes next to each other would have a total of 12 vertices. 48 indices - but then I would remove the adjoining face from each cube, leaving 40 indices. I just need to work out how to define texcoords per index-element rather than per vertex. The whole idea of using an Index Buffer full of indices, is that you only need to define each vertex (point in space) once, then reference to their position in the Vertex buffer with your indices. [EDIT: Code that builds the indices and texcoords is below] This code: The draw method is called every frame. buildIndices is called when the current chunk is edited (perhaps once every ten seconds). buildColours is called instead when I'm debugging. When using buildColours, the colours are defined per vertex in physical space. This is the result:  This is the texture being bound:  This is the code: 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
| public void draw() { GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, _verticesID); GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);
_texture.bind(); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, _texcoordsID); GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0); ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, _indicesID); GL12.glDrawRangeElements(GL11.GL_QUADS, 0, _indices.limit(), _indices.limit(), GL11.GL_UNSIGNED_INT, 0); } public void buildIndices(Block[][][] in) { int sy = _size.getY() + 1; int sx = _size.getX() + 1; int sz = _size.getZ() + 1; _indices = BufferUtils.createIntBuffer(sy * sz * sx * 24); _texcoords = BufferUtils.createFloatBuffer(sy * sz * sx * 24); for(int y = 0; y < _size.getY(); y++) { for(int z = 0; z < _size.getZ(); z++) { for(int x = 0; x < _size.getX(); x++) { if(in[x][y][z].getMaterial() != Material.Air) { int w = sx; int d = sz; int h = sy;
int zw = z * w; int ywd = y * w * d; int wd = w * d;
int v0 = x + zw + ywd; int v1 = v0 + 1; int v2 = x + w + zw + ywd; int v3 = v2 + 1; int v4 = x + wd + zw + ywd; int v5 = v4 + 1; int v6 = x + w + wd + zw + ywd; int v7 = v6 + 1;
float[] tl = new float[] {0.0f, 0.0f}; float[] tr = new float[] {1.0f, 0.0f}; float[] bl = new float[] {0.0f, 1.0f}; float[] br = new float[] {1.0f, 1.0f}; if(!in[x][y][z].getConnectivity().getFaceState(Face.Front)) { addIndices(new int[] { v0, v1, v5, v4}); addTexcoords(new float[][] {tl, tr, bl, br}); }
if(!in[x][y][z].getConnectivity().getFaceState(Face.Right)) { addIndices(new int[] { v1, v3, v7, v5}); addTexcoords(new float[][] {tl, tr, bl, br}); }
if(!in[x][y][z].getConnectivity().getFaceState(Face.Back)) { addIndices(new int[] { v3, v2, v6, v7}); addTexcoords(new float[][] {tl, tr, bl, br}); }
if(!in[x][y][z].getConnectivity().getFaceState(Face.Left)) { addIndices(new int[] { v2, v0, v4, v6}); addTexcoords(new float[][] {tl, tr, bl, br}); }
if(!in[x][y][z].getConnectivity().getFaceState(Face.Bottom)) { addIndices(new int[] { v2, v3, v1, v0}); addTexcoords(new float[][] {tl, tr, bl, br}); }
if(!in[x][y][z].getConnectivity().getFaceState(Face.Top)) { addIndices(new int[] { v4, v5, v7, v6}); addTexcoords(new float[][] {tl, tr, bl, br}); } } } } } _indices.flip(); _texcoords.flip(); VBOHandler.bufferElementData(_indicesID, _indices); VBOHandler.bufferData(_texcoordsID, _texcoords); } public void buildColours() { int vl = _vertices.limit() / 3; _colours = BufferUtils.createFloatBuffer(vl * 4); Random rand = new Random(System.currentTimeMillis()); for(int x = 0; x < vl; x++) { addColour(new float[] {0.0f, 0.8f + (rand.nextFloat() / 5), 0.0f, 0.0f} ); } _colours.flip(); } |
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|