Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (529)
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 3 ... 11
1  Discussions / General Discussions / Re: Java Swing GUI Creator on: 2014-07-17 21:44:55
I agree the 3D is fairly poor. It's still very new and I don't doubt it will be improved in time. I was just trying to give an example of the extra features in JavaFX. I also agree that the charting API is a better example.
2  Discussions / General Discussions / Re: Java Swing GUI Creator on: 2014-07-17 11:53:48
JavaFX isn't the panacea even though now what you can do with Swing has become doable with JavaFX but there is not yet any dialog API.

Originally I thought this was a major problem, but then I threw together my own dialog api in a few minutes. It's not the most feature heavy thing (basically just takes a scene and puts it into a dialog box) but it was the simplest thing in the world to make and it works perfectly. And then there are some really good dialog libraries out there.

But as I said in my last post, the great advantage of JavaFX over Swing (for me) is that it is just so much nicer to work with. The API is similar enough to Swing that it is easy to pick up, but with far greater usability and a whole load of features stuck in. JavaFX even has 3D graphics and I'm not talking about beveled buttons.

But I digress.
3  Game Development / Newbie & Debugging Questions / Using the Java ServiceLoader to load from a Jar inside another Jar. on: 2014-07-16 20:43:38
I am using the java.util.ServiceLoader to load plugins/extensions (call them what you want) from a series of Jar files which I store as resources inside my main executable Jar file. I generate an array of URLs which list the locations of the Jar files. I create an URLClassLoader and create a ServiceLoader around this class loader, and then the ServiceLoader does its stuff. Running this from my IDE (NetBeans if it makes a difference) but as soon as I build the project, the ServiceLoader fails to recognize any implementations.

To give an example (they don't add any info but perhaps state it more clearly than I did), here is the log output after running from NetBeans:
Quote
d | PRE_INIT | URL passed to URLClassLoader[0] = file:/.../ARBShaderServiceImpl.jar
d | PRE_INIT | URL passed to URLClassLoader[1] = file:/.../DefaultFramebufferServiceImpl.jar
d | PRE_INIT | URL passed to URLClassLoader[2] = file:/.../DefaultShaderServiceImpl.jar
d | PRE_INIT | URL passed to URLClassLoader[3] = file:/.../EXTFramebufferServiceImpl.jar
v | PRE_INIT | Loader: java.util.ServiceLoader[com.quew8.gutils.desktop.opengl.services.ShaderServiceImpl]
v | PRE_INIT | Loader Found: class com.quew8.gutils.desktop.opengl.services.arb.ARBShaderServiceImpl
v | PRE_INIT | Loader Found: class com.quew8.gutils.desktop.opengl.services.def.DefaultShaderServiceImpl
v | PRE_INIT | Looking At: class com.quew8.gutils.desktop.opengl.services.arb.ARBShaderServiceImpl
v | PRE_INIT |     Is Applicable: true
v | PRE_INIT |     Precedence: 2
v | PRE_INIT |     Setting As Top Implementation
v | PRE_INIT | Looking At: class com.quew8.gutils.desktop.opengl.services.def.DefaultShaderServiceImpl
v | PRE_INIT |     Is Applicable: true
v | PRE_INIT |     Precedence: 1
v | PRE_INIT |     Setting As Top Implementation
v | PRE_INIT | Looking At: class com.quew8.gutils.desktop.opengl.services.NoShaderServiceImpl
v | PRE_INIT |     Is Applicable: true
v | PRE_INIT |     Precedence: -1

And then from running it from the Jar.

Quote
v | PRE_INIT | URL passed to URLClassLoader[0] = jar:file:/.../StellarColony.jar!/.../ARBShaderServiceImpl.jar
v | PRE_INIT | URL passed to URLClassLoader[1] = jar:file:/.../StellarColony.jar!/.../DefaultFramebufferServiceImpl.jar
v | PRE_INIT | URL passed to URLClassLoader[2] = jar:file:/.../StellarColony.jar!/.../DefaultShaderServiceImpl.jar
v | PRE_INIT | URL passed to URLClassLoader[3] = jar:file:/.../StellarColony.jar!/.../EXTFramebufferServiceImpl.jar
v | PRE_INIT | Loader: java.util.ServiceLoader[com.quew8.gutils.desktop.opengl.services.ShaderServiceImpl]
v | PRE_INIT | Looking At: class com.quew8.gutils.desktop.opengl.services.NoShaderServiceImpl
v | PRE_INIT |     Is Applicable: true
v | PRE_INIT |     Precedence: -1
v | PRE_INIT |     Setting As Top Implementation

Obviously the difference between these is the URLs and the fact that the loader doesn't find any services (the NoShaderServiceImpl is loaded outside of the ServiceLoader in my own code)

So my question is: has anyone else experienced this and can anyone shed some light on why it is happening?

Thank you in advance.
4  Discussions / General Discussions / Re: Java Swing GUI Creator on: 2014-07-16 15:40:46
JavaFX I think is a pretty decent way to go. Tons of features, a lot of which are purely "make the coders life easier" features like the whole properties library. But the important thing here is that it has an XML format called FXML like Android's, with Java controllers (but you can access elements straight from in-class fields you define rather than looking them up from ids, so one up on Android) and there is a very decent FXML editor (coded with JavaFX of course) which I think is easier to use than any other GUI editor I've used.

I'm not particularly sure why JavaFX is having such a slow adoption but if there is a reason then that reason is the downside.
5  Game Development / Game Mechanics / Re: 2D Rigid Body Rope Physics on: 2014-07-15 22:26:57
There certainly is.

vx = w * cos(theta)
vy = -w * sin(theta)


Where w is angular velocity and v is tangential velocity. You may notice that position and angle share the same relationship as angular velocity and velocity. Just a little aside because it makes me smile to see maths work.
6  Game Development / Game Mechanics / Re: 2D Rigid Body Rope Physics on: 2014-07-13 14:11:01
OK, I just felt like trying this out for myself; really there is something very satisfying at watching a ball swing back and forth on a string. So here: http://pastebin.java-gaming.org/d0bb2981a0e14 (I don't know how to embed JGO pastebins). I made it using LWJGL so if you don't use LWJGL, then you won't have the libraries and natives to run it and you probably won't understand the rendering parts of it. But the simulation bits should still help.

Now as soon as I had it, I realized that the thing just kept swinging infinitely so I had to add in a little (very) simplistic friction. That is the " - ( av * FRICTION_COEFFICIENT / mass )" term in the SwingingBody.update() method. That friction bit is the only reason the mass of the body affects the motion.

One last thing - it is very crude in places. I was trying to do it quickly, and shortly whilst making it self-contained. Sorry.
7  Game Development / Game Mechanics / Re: 2D Rigid Body Rope Physics on: 2014-07-13 12:48:02
Sure, so you use angular acceleration and velocity to calculate the angle as in my code snippet, then you can use trig to work out the actual position.

Essentially

px = cx + r * cos(theta)
py = cy - r * sin(theta)

Where p is the position of the swinging body, c is the centre of the swing where the rope is attached, r is the length of the rope and theta is the angle.

Edit: Fixed, because stuff falls down, not up.
8  Game Development / Game Mechanics / Re: 2D Rigid Body Rope Physics on: 2014-07-11 11:28:06
Great.

In answer, no I would keep things in terms of position and linear velocity and make this a special case scenario. I have an in-progress 3D space sim where I have to work with linear and angular (about the centre of mass) motion to model forces properly, but that is really the only time you would have to work with angular motion under "normal" circumstances. There is certainly no sense in you doing it here.

One more thing I would say is that make sure the angle in this code is either always clockwise or always anti-clockwise. I can't work it out in my head but I'm 80% sure that you could end up with someone swinging to the top instead of the bottom.

Edit: No I'm wrong. cos(theta) == cos(360 - theta) since cos() is symmetrical about x = 180. So it doesn't matter whether it's clockwise sometimes and not others.
9  Games Center / Showcase / Re: Craft King - sandbox/mining game on: 2014-07-10 15:31:52
Ah right, well if you want more people to buy the full version, I suggest making it more clear what people in the free version are missing out on because last I checked the descriptions if the full and free version on Google Play were exactly the same. No mention in game either.

The only thing I am not liking so much is the combat. It doesn't feel like you are hitting something; the knock back helped but enemies were jumping all over the place anyway; so my other suggestion is some combat particle effects like blood spilling or something. If you don't want to go too gory then a hit animation would probably work as well but I understand that is more work, especially if your "art-creator" is tired.

And thanks for the screen orientation thing. Much appreciated. Keep up the good work.
10  Game Development / Game Mechanics / Re: 2D Rigid Body Rope Physics on: 2014-07-10 12:00:11
OK, I will give you a quick example, but I will also explain myself a bit which I think will help more. And sorry, I forget that pretty basic mechanics generally aren't taught in schools (in England I had to do an A-Level in physics to be taught about angular velocity and even then it was only very basic).

Angular velocity is a bit of a hard thing to get your head around if you aren't used to it. So you can think of velocity as the speed and direction in which position is changing (rate of change of position if you're big on calculus) and angular velocity is the speed and direction (in this context clockwise or anticlockwise) in which an angle is changing. That angle can be that of a body rotating on its centre of mass, or that of a body in circular motion about a point (as we have here). So what velocity is to position, angular velocity is to angle and what acceleration is to velocity, angular acceleration is to angular velocity.

So a "normal" to a line is a direction which is perpendicular to that line. (In 3D you can also get a normal to a face, which is a direction perpendicular to that face). Example:



So if we have a rope with a guy on the end, then the normal to the rope is the tangent to the circular path the guy is going to swing in. Ie it is the direction he will travel in at that moment in time which we call the tangential velocity. (aT in the previous post stood for tangential acceleration).



In that diagram, v is the tangential velocity. Ignore the centripetal force thing.

So now, my code example. I'm going to write a SwingingBody class with an update() method which takes the delta time for the current frame as a parameter. It uses euler integration to compute the current angle of swing. Things I'm leaving out are a way to render it and any collision detection/handling.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public class SwingingBody {
    public static final float g = 9.81; //Constant for average gravitational acceleration at the surface of the Earth.

    private float angle = 0; //The angle between the rope and the horizontal.
   private float av = 0; //angular velocity
   private float r; //The radius of the swing - the length of the rope.

    public void update(float delta) {
        float aa = g * GMath.cos(angle) / r;
        av += ( aa * delta );
        angle += ( av * delta );
    }
}


Three notes about this code:
1) I have used a function called GMath.cos(), this is meant to be a regular cos function accept that it takes a float as a parameter and returns a float as well. I don't know what framework you're using so I just used my own framework.

2) Generally we work with delta in milliseconds, however the constant for g I have given is in metres per second squared. So you must either divide delta by 1000 to get it in seconds or divide g by 1000,000 to get it in metres per millisecond squared.

3) Sorry about the fancy definition for g, I'm a physicist at heart.

Hope this helps.
Quew8
11  Discussions / Miscellaneous Topics / Re: Naming things on: 2014-07-09 20:24:14
Personally I'm always renaming huge swathes of my code because I come up with better names. The joy of working on your own with an IDE is that you can do stuff like that.
12  Java Game APIs & Engines / OpenGL Development / Re: Somehow using GL_REPEAT on a sub-texture in a sprite-sheet? on: 2014-07-09 20:18:12
I agree with @Riven, the only problem (that I can see) is that the uMin, uMax etc variables would have to be passed as uniforms. This means that you could only batch together draws of the same sub-image rather than of the same texture, which I think is quite a big part of the bonus from using texture atlases. Still better than individual textures though.

The only way around this (that I can see) is to use texture atlases but as @wessles says, they are only so useful.
13  Games Center / Showcase / Re: Craft King - sandbox/mining game on: 2014-07-09 16:15:00
I've played for a little bit and it is beautifully polished.  The one question I have is: what is the difference between the free and paid versions? Obviously there is the 1 character \ 1 world limit and I guess no adverts on the paid version but is there anything else?
14  Game Development / Game Mechanics / Re: 2D Rigid Body Rope Physics on: 2014-07-09 14:24:38
Well I have no idea about simulating a fluid rope, but a rigid strut type thing is simple enough. Here is a little I worked out scribbling on paper (which means it ain't my fault if something is wrong, it is the paper's fault).

So as with most angular motion questions, the maths is easier if you work in terms of angles. This might make the simulation harder or it might not, but it is what I am doing here.

So taking theta to be the angle between the horizontal and the rope, then the angle between the vertical and the rope is 90 - theta, and hence the angle between the normal and the vertical is also theta.

Then we can say that the magnitude of the resultant acceleration on the body, at = g * cos(theta)

Then a simple matter of using the formula for angular acceleration to give angular acceleration, alpha = g * cos(theta) / r where r is the length of the rope.

Not sure how helpful this will be. If you are using euler integration in your simulation then you're sorted (apart from maybe converting it into a more linear thing. If that is the case I'd be happy to help).
15  Games Center / Showcase / Re: Craft King - sandbox/mining game on: 2014-07-08 15:03:14
Please, please, please, set the orientation to "sensor landscape" instead of "landscape." It isn't your fault (the Google sdk/Eclipse plugin does not make it clear and I think different devices respond differently) and you are by no means the only one who does this (big devs do it too; example: a recent update to the 4od app means you have to browse programs in fixed orientation but you can watch them in either. WTF?) but it really annoys me. I don't know why non-sensor landscape even exists.

Sorry to rant without even mentioning your game (I can't try it now because sitting at my desk with my tablet charging, the cable isn't long enough to flip it so your game is upside down).
16  Game Development / Newbie & Debugging Questions / Re: Minimal Translation Distance too short? on: 2014-07-08 00:56:51
So just scale up the minimum translation distance by 1.1. Or 1.01. or 1.001. Large enough that it works, small enough that it isn't too noticeable.
17  Games Center / Cube World Projects / Re: Texturing a VBO? on: 2014-06-11 21:42:33
Just to let you know @NegativeZero

Quote
When an error occurs, the error flag is set to the appropriate error code value. No other errors are recorded until glGetError is called, the error code is returned, and the flag is reset to GL_NO_ERROR.
18  Game Development / Networking & Multiplayer / Re: Patching/Updating games - How would it work? on: 2014-06-11 21:35:44
For overwriting individual files in a zip archive (such as a .jar file) you can use ZipOutputStream and there is even a JarOutputStream especially for jar files. So there isn't even the requirement to download whole jar files.
19  Game Development / Shared Code / Re: Color object on: 2014-06-11 21:09:56
My Color class is called "Colour." This is because I am English (and I don't expect others to use my code) but it actually turns out to be very useful in terms of avoiding naming conflicts because everything in Java uses the American spellings.

Since we are just talking about colours.
20  Game Development / Newbie & Debugging Questions / Re: Loading .smb 3D model on: 2014-06-11 20:57:42
I don't know anything about .smb (or is it .sbm ?) but I highly doubt that wavefront (.obj) will be insufficient. The wavefront format supports position, tex-coords, normal and material data (via the .mtl format). And more importantly for a beginner it is probably the simplest format you will find to parse 3D model info. The big thing it doesn't do is any animation stuff so if that's what you need then bad idea. But I think what it has is more than enough for a beginner to get their teeth into.

Edit: According to @trollwarrior1 (all credit there) it does vertex colour info as well. Did not know that.
21  Discussions / General Discussions / Re: Design advice for a library I'm working on. on: 2014-06-06 20:30:41
My opinion, for what it's worth:

It sounds like your problem is feature drift. You need to sit down and decide who this library is aimed at, a typical use case and therefore what features the library needs. When you've done that, have a good hard think of how you would like to be able to use the library and I find that the structure of the implementation tends to come quite easily. But only if I have thought it through thoroughly.

We could give you answers (well I would leave that to a better man anyway) but it's your library and you are the one who has to be happy with it.
22  Java Game APIs & Engines / OpenGL Development / Re: Instancing, Passing Changing Data to be Instanced on: 2014-06-03 20:54:05
Withdrawn - I was talking about completely the wrong thing. Sorry for wasting peoples time. 

 
23  Game Development / Newbie & Debugging Questions / Re: [lwjgl] glFrustum difficulty on: 2014-06-02 20:47:21
If you're interested the reason is that glFrustum() specifies a projection transform. If we are using the camera analogy, the projection transform is the lens of the camera. So being a projection transform, it doesn't have any impact on the direction the camera is facing.
24  Java Game APIs & Engines / OpenGL Development / Re: interleaved VBO and textures (Problem) on: 2014-06-01 19:46:53
Don't worry about it. I made far worse mistakes when I was learning OpenGL and a black screen is the hardest to debug. And yeah I wouldn't mind hearing how you get on.
25  Java Game APIs & Engines / OpenGL Development / Re: interleaved VBO and textures (Problem) on: 2014-06-01 16:21:36
So firstly, you are absolutely right - the triangle is behind the camera. I go the triangle rendering by changing the z coordinates to "-3" instead of "+3." The reason for this is going to sound a little idiotic but I will try to explain it. In OpenGL, by default, the positive z direction is coming out of the screen towards you, which means that going into the screen (which is the forward direction of the camera) is actually the negative z.

The reason for this. You don't need to know but it might be interesting
The reason for this is that OpenGL uses a right handed coordinate system. Imagine your hand is 3 coordinate axis. Your thumb is the x axis, your first finger (index finger) is the y axis and your second finger (middle finger). (I gave both names of fingers not to patronize you but because I know that the French have a different system for naming fingers. I don't know enough to name them but I know it is different). So in OpenGL, the origin is the bottom left corner of the screen with the y axis going up and the x axis to the right. So take your right hand and put it at the bottom left corner with your thumb pointing to the right and your first finger pointing up. You will notice that your middle finger is pointing towards you. If you were using DirectX, it is a left handed coordinate system and with your left hand, the middle finger would be pointing into the screen.
Reason over. You can start reading again.

If I had done a proper job of reading through your code to begin with I would have noticed this and saved you the trouble. So probably not a good idea to name your first born after me - firstly he might be bullied a little (Quew8 is a weird name) and secondly he'd probably grow up to be the kind of person who does half-arsed jobs like me.

In the interest of completeness, I did notice two more things about your new render method.

-You are now binding the texture twice. Once with Slick's Texture class's bind() method and once with the direct OpenGL glBindTexture() method. There is no reason to.

-(This one is just an FYI so you don't have to bother reading this either) I notice you using the glClientActiveTexture() function. Now I didn't actually know how this differed from glActiveTexture() so I looked it up and thought I would share my findings.

OpenGL works with "texture units." You can have a different texture bound to each texture unit which allows rendering different textures at the same time. What glActiveTexture() does is to change the current texture unit. I.e it changes which texture unit glBindTexture() binds the texture to. By default it is "GL_TEXTURE0."

Now here is the bit I didn't know. Each texture unit can also have it's own texture coordinate pointer, so two different textures don't have to share the same texture coordinates. So what glClientActiveTexture() does is to define which texture unit subsequent calls to glEnableClientState(GL_TEXTURE_COORD_ARRAY) and glTexCoordPointer() affect. Which is neat. Superfluous if you are using the programmable pipeline but still neat.

Hope I've helped.
26  Java Game APIs & Engines / OpenGL Development / Re: interleaved VBO and textures (Problem) on: 2014-05-31 22:36:31
I noticed three problems, but nothing with your use of VBOs or interleaving so you're getting better.

1) You make your texture, but then you don't bind it when you draw the triangle. Also you should bind it before changing any texture parameters. The getTexture() method probably leaves the texture bound but you can't garuntee that and should always do it yourself. Also you make a FloatBuffer in that method which you then don't do anything with.

2) You did enable the GL_VERTEX_ARRAY but you have commented out that code. This is why I think you're getting black screen. You are using vertex arrays so you do need them enabled.

3) When you call glDrawArrays() you specify it to draw 6 vertices when you only need 3 and have only given 3.
27  Java Game APIs & Engines / OpenGL Development / [LWJGL] An EXCEPTION_ACCESS_VIOLATION on glDrawElements that really has me. on: 2014-05-31 20:01:57
Background
Before I get into the nitty gritty, I think I need to give a little background. I have written an API which among other things provides an interface to OpenGL and windowing utils for which I have backends for both Android and Desktop (through LWJGL) the purpose of which is obviously to use the same code on Android and Desktop. I also have my own rendering library which uses this OpenGL / windowing interface.

So this game I was originally writing on Android where it was working fine, but this error appeared when I ported it to Desktop. Now I have two other games on Desktop that use the same rendering library and OpenGL interface so it cannot be a fundamental problem with either of those things.

The Error
So here is a pastebin of the native stack trace http://pastebin.com/0fWKe8x7 but long story short it is, as per the thread title, an EXCEPTION_ACCESS_VIOLATION after calling glDrawElements(). My experience is you get this when the indices and pointers you have supplied point to data that doesn't exist but I can't see how that is the case. Also my system specs are all there if needed.

Rather than posting reams of code (and it would be a hell of a lot) I'm going to post a list of calls of OpenGL functions (not all of them, only the pertinent ones + a few more - if you think any others are pertinent then ask and I'll post them too). Don't worry, the contents of the buffers are below this in a more readable format.

Quote
d | 1215971556 | glEnableVertexAttribArray_P() {index = 0}
d | 1215971595 | glEnableVertexAttribArray_P() {index = 1}
d | 1215971596 | glEnableVertexAttribArray_P() {index = 2}
d | 1215971656 | glAttachShader_P() {program = 1, shader = 2}
d | 1215971659 | glAttachShader_P() {program = 1, shader = 3}
d | 1215971660 | glBindAttribLocation_P() {program = 1, index = 0, name = position}
d | 1215971662 | glBindAttribLocation_P() {program = 1, index = 1, name = normal}
d | 1215971663 | glBindAttribLocation_P() {program = 1, index = 2, name = texCoords}
d | 1215972507 | glBindBuffer_P() {target = GL_ARRAY_BUFFER, buffer = 1}
d | 1215972514 | glBufferData_P() {target = GL_ARRAY_BUFFER, data = BB{pos = 0, lim = 128, cap = 128}[0, 0, -96, -64, 0, 0, -96, -64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -128, -65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -96, 64, 0, 0, -96, -64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -128, -65, 0, 0, -128, 63, 0, 0, 0, 0, 0, 0, -96, 64, 0, 0, -96, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -128, -65, 0, 0, -128, 63, 0, 0, -128, 63, 0, 0, -96, -64, 0, 0, -96, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -128, -65, 0, 0, 0, 0, 0, 0, -128, 63], usage = GL_STATIC_DRAW}
d | 1215972517 | glBindBuffer_P() {target = GL_ARRAY_BUFFER, buffer = 0}
d | 1215972658 | glBindBuffer_P() {target = GL_ELEMENT_ARRAY_BUFFER, buffer = 2}
d | 1215972660 | glBufferData_P() {target = GL_ELEMENT_ARRAY_BUFFER, data = BB{pos = 0, lim = 24, cap = 24}[0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0], usage = GL_STATIC_DRAW}
d | 1215972679 | glBindBuffer_P() {target = GL_ELEMENT_ARRAY_BUFFER, buffer = 0}
d | 1215972913 | glEnable_P() {cap = GL_DEPTH_TEST}
d | 1215972915 | glEnable_P() {cap = GL_STENCIL_TEST}
d | 1215973067 | glBindBuffer_P() {target = GL_ARRAY_BUFFER, buffer = 1}
d | 1215973068 | glBindBuffer_P() {target = GL_ELEMENT_ARRAY_BUFFER, buffer = 2}
d | 1215973070 | glEnableVertexAttribArray_P() {index = 1}
d | 1215973071 | glEnableVertexAttribArray_P() {index = 2}
d | 1215973074 | glEnableVertexAttribArray_P() {index = 3}
d | 1215973076 | glVertexAttribPointer_P() {index = 0, size = 3, type = GL_FLOAT, normalized = false, stride = 32, bufferOffset = 0}
d | 1215973078 | glVertexAttribPointer_P() {index = 1, size = 3, type = GL_FLOAT, normalized = false, stride = 32, bufferOffset = 12}
d | 1215973080 | glVertexAttribPointer_P() {index = 2, size = 2, type = GL_FLOAT, normalized = false, stride = 32, bufferOffset = 24}
d | 1215973083 | glDrawElements_P() {mode = GL_TRIANGLES, count = 6, type = GL_UNSIGNED_INT, bufferOffset = 0}

Since the BufferData is given in bytes rather than ints or floats, I've converted them (and formatted a little) below and I wrote a whole new program to do that so there is no human error.

ARRAY_BUFFER id 1 as floats, divided into vertices and vertex components.
[-5.0 -5.0 0.0] | [0.0 0.0 -1.0] | [0.0 0.0]
[5.0 -5.0 0.0] | [0.0 0.0 -1.0] | [1.0 0.0]
[5.0 5.0 0.0] | [0.0 0.0 -1.0] | [1.0 1.0]
[-5.0 5.0 0.0] | [0.0 0.0 -1.0] | [0.0 1.0]

ELEMENT_ARRAY_BUFFER id 2 as ints.
0 1 2 0 2 3

As you might have guessed, it's a square I'm trying to draw.

My intention for the interleaving of the vertex data: PPPNNNTT where P = position, N = normal, T = texture coord.

Finally
If you have any ideas at all, or if I have missed out some information then please don't hesitate to post. I've been trying to solve this intermittently for many, many weeks. I'm so frustrated with this that today I found myself grinding my teeth and shouting at the computer when it took longer that a second to load up the JavaDoc which held the answer to another bug entirely.

Thank you for reading and thank you in advance for any help rendered.

Q8.
28  Java Game APIs & Engines / OpenGL Development / Re: Getting introduced to VBO on: 2014-05-30 13:37:38
(Just presenting some other good tutorials in case they are desired)

@SHC's LWJGL specific OpenGL tutorial series: http://goharsha.com/lwjgl-tutorial-series/

The arcsythesis tutorials http://www.arcsynthesis.org/gltut/
the wonderful @ra4king has ported the code examples to LWJGL here: https://github.com/ra4king/LWJGL-OpenGL-Tutorials

@trollwarrior1 ... which generally results in faster rendering.
29  Java Game APIs & Engines / OpenGL Development / Re: interleaved VBO and textures (Problem) on: 2014-05-29 19:09:00
The way you translate depends on how you're doing things, but using VBOs doesn't change anything. You can translate things exactly the way you were before. I expect you are using the fixed function pipeline (ie not shaders) so glTranslatef().

As a side note. Trust me when i say you will have to learn about shaders eventually and once you have you will find most things a lot easier. Better sooner rather than later.
30  Java Game APIs & Engines / OpenGL Development / Re: interleaved VBO and textures (Problem) on: 2014-05-28 18:53:27
I'm going to give you an example to help you understand what @SHC is trying to get across. Imagine that you have a Stripey Yellow block at position A, a Dotted Green block at position B and a Checkered Black and White block at position C. Here is the order your rendering should take.

  • Bind VBO (and IBO if you're using it)
  • Bind Stripey Yellow Texture.
  • Translate to Position A.
  • Draw VBO.
  • Bind Dotted Green Texture.
  • Translate to Position B.
  • Draw VBO.
  • Bind Checkered Black and White Texture.
  • Translate to Position C.
  • Draw VBO.
  • Unbind VBO.

So you use the same VBO, which is bound the whole time during your rendering, but you change the texture and transformation matrix in between drawing. One set of geometric data, infinite number of cubes.

NB: Looking at your first post, I think you've misunderstood what interleaving is. The technique we're talking about here is called "instancing." Which involves having one set of data which you draw several times. "Interleaving" is where you store all of the information about an object (position, normal, texture-coords etc) in the same VBO. If you are unsure about these things I recommend reading up on them once more just to get it clear in your head.
Pages: [1] 2 3 ... 11
 

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

The first screenshot will be displayed as a thumbnail.

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

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

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

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

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

Riven (41 views)
2014-07-14 18:02:53

OpenGLShaders (28 views)
2014-07-14 16:23:47

Riven (28 views)
2014-07-14 11:51:35

quew8 (25 views)
2014-07-13 13:57:52

SHC (61 views)
2014-07-12 17:50:04
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!