Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


syskrank

Member Since 31 Mar 2014
Offline Last Active Nov 21 2014 07:18 AM

Topics I've Started

libgdx unwanted gaps btw tiles/objects

04 September 2014 - 09:59 AM

Hey, everyone.

I've got a problem with using libgdx. I've packed all my images into POT atlas texture with 1024x1024 dimensions and loading it with the NEAREST filtering for mag and min.

 

From there I'm creating TextureRegions with NPOT-sizes ( which is OK, according to official libgdx wiki and OpenGL logics ) with sizes like 17x5, 69x69 and so on.

 

The actual problem is that when I move some graphical objects ( or tiles, if you will ), sometimes I see gaps between them, where no gaps should appear at all. Furthermore, the size of the gap differs through the time - it's seems to be frame-dependent or something.

 

I'm using standart libgdx' Screen class render( float delta ) method to organize my main cycle which is giving me 60FPS everytime. VirtualVM profiler says I'm doing pretty good with CPU and RAM - 10-20% on one core and 25Mb of RAM is used. So there's no possible lag, I suppose.

 

I really need help, because this thing is driving me crazy smile.png


uniforms optimized-out

14 August 2014 - 03:09 AM

Hi.

I'm facing the problem that GLSL optimizer eliminates my uniforms, that are actually used.

Here's my vertex shader:

#version 120
#ifdef GL_ES
precision mediump float
#endif

attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_texCoord0;

attribute vec2 a_boneWeight0;
attribute vec2 a_boneWeight1;
attribute vec2 a_boneWeight2;
attribute vec2 a_boneWeight3;
attribute vec2 a_boneWeight4;
attribute vec2 a_boneWeight5;
attribute vec2 a_boneWeight6;
attribute vec2 a_boneWeight7;

// uniforms
uniform mat4 MVP;
uniform mat4 shadowMVP;
uniform int useBoneWeight[8]; // use numbered bone or not
uniform mat4 boneTransform[8];
uniform int useSkinning;
 
//// outputs
#ifdef GL_ES
    varying medium vec3 normal;
    varying medium vec3 worldPos;
    varying medium vec2 textureCoord;
    varying medium vec4 shadowCoord;
#else
    varying vec3 normal;
    varying vec3 worldPos;
    varying vec2 textureCoord;
    varying vec4 shadowCoord;
#endif

void main() {
    shadowCoord = shadowMVP * vec4( a_position, 1.0f );
    textureCoord = a_texCoord0;
    mat4 skinning = mat4( 0.0 );
    if ( 1 == useSkinning )  {
        skinning += ( ( a_boneWeight0.y ) * boneTransform[ int( a_boneWeight0.x ) ] * useBoneWeight[ 0 ] );
        skinning += ( ( a_boneWeight1.y ) * boneTransform[ int( a_boneWeight1.x ) ] * useBoneWeight[ 1 ] );
        skinning += ( ( a_boneWeight2.y ) * boneTransform[ int( a_boneWeight2.x ) ] * useBoneWeight[ 2 ] );
        skinning += ( a_boneWeight3.y ) * boneTransform[ int( a_boneWeight3.x ) ] * useBoneWeight[ 3 ];
        skinning += ( a_boneWeight4.y ) * boneTransform[ int( a_boneWeight4.x ) ] * useBoneWeight[ 4 ];
        skinning += ( a_boneWeight5.y ) * boneTransform[ int( a_boneWeight5.x ) ] * useBoneWeight[ 5 ];
        skinning += ( a_boneWeight6.y ) * boneTransform[ int( a_boneWeight6.x ) ] * useBoneWeight[ 6 ];
        skinning += ( a_boneWeight7.y ) * boneTransform[ int( a_boneWeight7.x ) ] * useBoneWeight[ 7 ];
        gl_Position = MVP * skinning * vec4( a_position, 1.0f );
        normal = ( MVP * skinning * vec4( a_normal, 0.0f ) ).xyz;
        worldPos = ( MVP * skinning * vec4( a_position, 1.0f ) ).xyz;
    } else {
        gl_Position = MVP * vec4( a_position, 1.0f );
        normal = ( MVP * vec4( a_normal, 0.0f ) ).xyz;
        worldPos = ( MVP * vec4( a_position, 1.0f ) ).xyz;
    }
}

Uniforms 'useBoneWeights' and 'boneTransform' are erased during optimization.

I've tried to get their location with glGetUniformLocation() querying them by array name and array indexed elements.

All other parts of the shader are working fine.

 

I'm using Java and libgdx1.2.0 ( thus - opengl es 2.0 ) and my semi-custom shader system ( incapsulated libgdx' Shader class to give it more 'native' C/C++ interface ).


libgdx, 3d models, fbx and coordinate system mess

10 August 2014 - 06:06 AM

Hello everyone.

I hope  someone could help me, because I'm completely stuck.

 

So here's the plot:

I'm using libgdx and it's 3d rendering capabilities ( but custom  GLSL shaders ) along with Blender to create 3d content. The thing that pisses me off completely is when I'm exporting model from Blender to FBX format and then using fbx-conv utility to transfer everything to G3DB, I'm getting the same freaking model orientation in the output, e.g. all my models appears to be turned 90 degrees around Ox, despite my attempts to set another 'up' or 'forward' axes when I'm exporting from Blender.

 

Libgdx documentation says that I should use 'Z up' setting most of the time, but this isn't working for me at all - all models are dropped to their left side on the ground.

 

Blender version - 2.70a;

FBX framework - 2014 version from Autodesk, as it's recommended by fbx-conv documentation;

fbx-conv - lasted snapshot from their repository, compiled against FBX framework;

 

Halp!

Thanks in advance.

 

P.S.

Maybe libgdx supports some other 3d formats with skeletal animation?

 


Meet the Rocket Nerd! ( Android )

31 July 2014 - 11:05 PM

Hello everyone.
Just finished work on my very first Android game written in Java.
And yes, this is another tappy-flappy-bird clone made mainly in educational purposes.
However, I hope I made it quite well, so you can try & tell, if you please smile.png
 
Title: Rocket Nerd!
Engine: custom code in Java and libgdx
Version: does it matters?
Description: Clone of a popular casual arcade game with classic rules in a new setting. Use all your skill to drive the little rocket-mounted guy through the maze of random-generated vicious pipes to see how far he could get.
Be sure to check that you have your PhD in rocket science before you dare to start.
 
 
Get it on to the Google Play.
 
Screenshots:
 

Spoiler


glDrawElements invalid operation

07 June 2014 - 01:10 AM

Hello everyone. Need your help, because I'm already out of ideas.

 

While rendering my 3D scene, I'm getting the following error within my logging system:

OpenGL error in 'glDrawElements ( GL_TRIANGLES, numIndices, GL_UNSIGNED_INT, 0 )' - 'Mesh.cpp:27' - invalid operation

Where Mesh.cpp:27 is the call to glDrawElements:

    void Mesh::Draw() {
        GL_CHECK ( glBindVertexArray ( vao ) );
        GL_CHECK ( glDrawElements ( GL_TRIANGLES, numIndices, GL_UNSIGNED_INT, 0 ) );
        GL_CHECK ( glBindVertexArray ( 0 ) );
    }

GL_CHECK is a macro for digging all the OpenGL errors ( if any ).

 

VAO, VBO and IBO are created like that:

   void Mesh::PopulateBuffers () {
// --- create buffers
        if ( vao )
            GL_CHECK ( glDeleteVertexArrays ( 1, &vao ) );
        if ( vbo )
            GL_CHECK ( glDeleteBuffers ( 1, &vbo ) );
        if ( ibo )
            GL_CHECK ( glDeleteBuffers ( 1, & ibo ) );

        GL_CHECK ( glGenVertexArrays ( 1, &vao ) );
        GL_CHECK ( glBindVertexArray ( vao ) );
        GL_CHECK ( glGenBuffers ( 1, &vbo ) );
        GL_CHECK ( glGenBuffers ( 1, &ibo ) );
// --- layout setup BEGIN
        GL_CHECK ( glEnableVertexAttribArray ( 0 ) ); // vertices
        GL_CHECK ( glEnableVertexAttribArray ( 1 ) ); // texture coords
        GL_CHECK ( glEnableVertexAttribArray ( 2 ) ); // normals
        GL_CHECK ( glEnableVertexAttribArray ( 3 ) ); // tangents
        GL_CHECK ( glEnableVertexAttribArray ( 4 ) ); // bitangents
// --- layout setup END
        GL_CHECK ( glBindBuffer ( GL_ARRAY_BUFFER, vbo ) );

        GL_CHECK ( glVertexAttribPointer ( 0, 3, GL_FLOAT, GL_FALSE,
                                           VERTEX_ELEMENTS_COUNT * sizeof ( float ), 0 ) ); // vert coords
        GL_CHECK ( glVertexAttribPointer ( 1, 2, GL_FLOAT, GL_FALSE,
                                           VERTEX_ELEMENTS_COUNT * sizeof ( float ), ( GLvoid* ) ( 3 * sizeof ( float ) ) ) ); // tex coords
        GL_CHECK ( glVertexAttribPointer ( 2, 3, GL_FLOAT, GL_FALSE,
                                           VERTEX_ELEMENTS_COUNT * sizeof ( float ), ( GLvoid* ) ( ( 3 + 2 ) * sizeof ( float ) ) ) ); // normals
        GL_CHECK ( glVertexAttribPointer ( 3, 3, GL_FLOAT, GL_FALSE,
                                           VERTEX_ELEMENTS_COUNT * sizeof ( float ), ( GLvoid* ) ( ( 3 + 2 + 3 ) * sizeof ( float ) ) ) ); // tangents
        GL_CHECK ( glVertexAttribPointer ( 4, 3, GL_FLOAT, GL_FALSE,
                                           VERTEX_ELEMENTS_COUNT * sizeof ( float ), ( GLvoid* ) ( ( 3 + 2 + 3 + 3 ) * sizeof ( float ) ) ) ); // bitangents
// ---- populate buffer with vertices
        GL_CHECK ( glBufferData ( GL_ARRAY_BUFFER,
                                  core::VERTEX_ELEMENTS_COUNT * vertices.size() * sizeof ( float ),
                                  &bufferData[ 0 ],
                                  GL_STATIC_DRAW ) );
// ---- populate another buffer with indices
        GL_CHECK ( glBindBuffer ( GL_ELEMENT_ARRAY_BUFFER, ibo ) );
        GL_CHECK ( glBufferData ( GL_ELEMENT_ARRAY_BUFFER,
                                  indices.size() * sizeof ( GLuint ),
                                  &indices[ 0 ],
                                  GL_STATIC_DRAW ) );
// ---- unbind VAO
        GL_CHECK ( glBindVertexArray ( 0 ) );
// ---- recalculate box
        RecalcAABB();
    }

I'm working with 3.3 core profile, all shaders are OK ( as for it could be one of the reasons for such errors ).

Must mention that everything is being rendered just fine, but in the same time I'm getting the storm of errors, and each one is pointing to the code above ( the glDrawElements call ).

 

Could anybody help? Or should I just ignore these error messages ?

 


PARTNERS