Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


Dekowta

Member Since 19 Sep 2011
Offline Last Active Nov 26 2014 12:42 PM

Topics I've Started

FFMPEG and Windows messages causing OpenAL to stop

12 October 2014 - 11:32 AM

Hi,

I've got openAL and FFMPEG set up both with streaming and pre loading of audio data however I have a few issues with the streaming side which seems to set the openAL source to stop without implicitly calling the alSourceStop command.

 

The commands from FFMPEG that I know trigger it are av_q2d (no idea why this does it) and av_read_frame. I havent read in full detail the FFMPEG API but I have a feeling that av_read_frame may unload the any other streams currently loaded (though I hope im wrong on this) but this still doesnt really explain why it would cause any openAL sources to stop.

The other trigger to stopping the buffered openAL source is moving or scaling the window no idea why this is happening.

If anyone has any details on what could be triggering this it would be a great help otherwise going to try and dig deep into FFMPEG and OpenAL to see if I can find the problem.

Thanks

Dekowta


Signed Distance Field issues

29 March 2014 - 12:52 PM

Hi,

I've been experimenting with singed distance fields in OpenGL for a bit now and I've come across a few issues I need some help to solve.

 

I have put all the images here http://imgur.com/DxGdGe9,1qXKq0d,8rYcS3J,U4VI01S,yYal9yV#0 as they are rather large

The first is that I have the basic fragment shader for performing the alpha testing
 

in vec2 VTexCoord;
in vec4 VColour;


uniform sampler2D Tex1;

out vec4 FragColour;

void main() {

	float distance = texture( Tex1, VTexCoord ).a;
	float smoothWidth = fwidth(distance);
	float alpha = smoothstep(0.5 - smoothWidth, 0.5 + smoothWidth, distance);
	FragColour = vec4(VColour.rgb, alpha);   
	
}

I use it on the following singed distance field generated via the tool that comes with libgtx (https://github.com/libgdx/libgdx/wiki/Distance-field-fonts) which is the first image. The result gained from using the first image can be seen in the third image which looks ok but jagged around the edges and when zoomed in (second image) its doesn't seem to be working as i expected since i thought it would retain a smooth curve rather than pixelated edges.

I don't know if there are any opengl states that need to be set before applying the shader or if the texture needs have different parameters.

I cant really post all the code for rendering since its rather large but its all here: https://bitbucket.org/Chris_Millin/moonlight-engine/src/87ccdb3302c5082a1ab065ec3da37923205f7197/Moonlight/Moonlight/?at=master and the implementation at the moment is

 

#include <MoonLight.h>

using namespace std;

int main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
    MLWindows::MLWindowsContext* WindowContext;

    WindowContext = new MLWindows::MLWindowsContext(hInstance, hPrevInstance, lpCmdLine, nShowCmd);
    WindowContext->Create(L"MoonLight Test Bed", 1280, 720, 32, true);
    //set up the openGL stuff
    MLRenderer::MLGLContext* GLContext = new MLRenderer::MLGLContext();
    WindowContext->BindGLContext(GLContext);
    GLContext->Initalise();
    GLContext->SetClearColour(Vector4f(0.0f,0.5f,0.0f,1.0f));

    

    MLInput::MLInputManager::Initalise();
    MLInput::MLInputManager::CreateRawKeyboard();
    MLRenderer::MLText::MLFontCore::Initalise();
    MLRenderer::MLCameraManager::Initalise();
    MLAudio::MLAudioManager::InitaliseAudio(false, 0);
    WindowContext->SetResizeCallBack(&MLRenderer::ResizeGL);
    WindowContext->SetInputCallBack(&MLInput::MLInputManager::InputMSGHandler);

    MLGraphics::Initalise(5000);

    MLRenderer::MLText::MLFontCore::Initalise();
    MLTrueTypeFont font;
    font.LoadFont("TestFont.ttf", 256);
    font.SetPaddingX(15);
    font.SetPaddingY(15);
    font.SetTextureWidth(4096);
    font.SetTextureHeight(4096);
    font.LoadDefaultGlyps();


    MLTexture* sdfTest = new MLTexture();
    sdfTest->LoadTexture("TEST.png");


    MLSprite newSprite;
    MLTexture* text = font.GetFontTexture(0);
    /*text->StartEditing();
    text->ExportImage("TestBefore.png");
    text->ConverttoGrayScale();
    text->ExportImage("Test2.png");
    text->ConverttoSignDistanceField(1, 4);
    text->ExportImage("Test.png");
    text->EndEditing();*/

    newSprite.Texture = sdfTest;
    newSprite.SetSizeFromTexture();
    newSprite.SetSourceFromTexture();
    newSprite.Colour = Vector4f(1.0f);


    MLShader* sdfShader = new MLShader();
    sdfShader->LoadShaderFile("shaders\\SignedDistanceField", GL_VERTEX_SHADER);
    sdfShader->LoadShaderFile("shaders\\SignedDistanceField", GL_FRAGMENT_SHADER);
    sdfShader->Lock();
    sdfShader->BindAtt(MLRenderer::MLAttID::ML_ATT_VERTEXPOS,    BASE_SHADER_VERT_POS);
    sdfShader->BindAtt(MLRenderer::MLAttID::ML_ATT_VERTEXCOL,    BASE_SHADER_VERT_COL);
    sdfShader->BindAtt(MLRenderer::MLAttID::ML_ATT_TEXTURE0,    BASE_SHADER_VERT_UV);
    sdfShader->LinkShaders();
    sdfShader->Unlock();

    while(1)
    {

        if(MLInput::MLInputManager::IsKeyPressed(MLKeys::Up))
        {
            newSprite.Scale.x += 0.02f;
            newSprite.Scale.y += 0.02f;
        }
        if(MLInput::MLInputManager::IsKeyPressed(MLKeys::Down))
        {
            newSprite.Scale.x -= 0.02f;
            newSprite.Scale.y -= 0.02f;
        }
        GLContext->StartFrame();
        MLAudio::MLAudioManager::UpdateAudio();
        WindowContext->Update();
        MLGraphics::Begin();

        newSprite.Position = Vector2f(0.0f, 0.0f);
        newSprite.Shader = sdfShader;
        newSprite.Effect = MLSpriteEffect::None;
        MLGraphics::Draw(&newSprite);
        
        MLGraphics::End();

        GLContext->EndFrame();
        

        
    }

}


The second problem Im having is that I have implemented the Dead Reckoning method to create a signed distance field but I have no idea how to limit the spread of the distance values and I end up with a mess (images four and five). The code im using for calcualting the values are the same as (http://people.sju.edu/~ggrevera/software/distance/html/class_dead_reckoning__3x3.html). My maths isn't amazing but I do understand the concept just dont really have a clue on how to limit the spread.

Thanks


Open Source Scene Graph

16 January 2014 - 07:56 AM

Hi,

I'm not 100% sure if this is the right place to post this so please let me know so I can remove it and move it to the correct board.

I am a student at The University of Portsmouth and as part of my final year project I am focusing on the development of an open source scene graph editor which is in theory designed to help work with custom built engines and is aimed at independent developers and students.

Since this project focuses on development for independent developers and students I need to find out what requirements they are after to allow the software to be designed around them. This is where I need some help I have created a very small (hopefully 3-5min) survey that would aid me in completing this task.

The survey can be taken online here https://www.surveymonkey.com/s/HGRMYRX.

Thank you

Chris


Custom 2D geometry from a list of points.

22 August 2013 - 01:39 PM

Hi,

I expect this has been asked before but I honestly don't really know how to go about finding the information since most of my searches don't contain the information I expect.

My problem at the moment is that I am trying to create a list of indices from a set of points. The points have to work in clockwise direction to create the custom 2D geometry.

I have draw out some images to hopefully explain what I want to do and the way I am currently thinking about going about it.

KzHulKi.png

In Shape A (0) I have my 6 points which make up my shape and in Shape A (1) you can see what shape it should create if the points are connected one after the other starting at 1 and ending at 1. To Draw the shape I ideally would like to segment the shape into triangles and have the points of each triangle as shown in Shape A (2).

Now the way I am currently thinking about doing this is to actually start with breaking the shape into as many quads as possible since I feel they are easier to work with and once all the quads have been found its just a matter of cutting them in half to create all the triangles for the shape. So in Shape A (3) I would start with points 1, 2, 3, 4 and check to see if they can create a valid quad which does not have any sides intersecting each other and that the quad does not have any of the other points of the shape inside of it. In Shape A (3) 1, 2, 3, 4 is valid and points 2 and 3 can now be ignored since they wont ever have anything else connect to them. Since there are now only 4 points left the next quad should be 4, 5, 6, 1.

I haven't tried it with too many shapes on paper but I believe that system should work and in Shape B it also works but unlike shape A points 1, 2, 3, 4 don't create a valid quad as can be seen in Shape B (0). So points 2, 3, 4, 5 are then checked and again they wont make a valid quad. 3, 4, 5, 6 do how ever and 4 and 5 are now take out. 6, 7, 1, 2 should also not make a valid quad but 7, 1, 2, 3 will (1 and 2 are then take out). That then leaves 3, 6, 7 left to create a triangle.

The only issue I have though is when it comes to concave shapes as can be seen in Shape C (0). 1, 2, 3, 4 is valid as well as 4, 5, 6, 7. As you can see though 4, 5, 6, 7 does not correctly create the shape and also means 5 and 6 are ignored leaving 8, 9, 1, 4 to be valid even though 5 and 6 are inside of the quad. If the concave section is spotted and is ignored correctly then Shape C (1) should be the result.

Sorry if I have explained this really poorly. It all make sense in my head but I sometimes struggle explaining it.

If there are any simpler method of doing this of anything that you think will help that would be good enough.

Thanks

Chris


A Project Idea

16 July 2013 - 10:56 AM

Hi,

I'm soon going to starting my dissertation for my final year of Uni and would like to see if anyone would want or use the Application that I am proposing to design.

A big part of my project is going to scripting and is what I will mainly focus on.

The project I propose is to build upon the existing box2D testbed application (that comes with the C++ sdk) and add Angel Script to the framework. It will work exactly the same as it currently does but rather than having to create a new C++ class and inherit from the framework to add a test a Angel Script file can be loaded and the test can be run and modified while the application is running.

What this will allow is for anyone to prototype new physics within box2D without having to wait and compile the project each time. It will also allow for scripts to be linked via #include so generic pre build scripts (such as a player hit box and movement) can be added to the simulation with ease.

I know there are similar things out there but I would aim to keep box2D registered the same in Angel Script as it is in C++ so the current tests could be remade quickly in the new application.

If anyone would be interested in something like this or want to make any suggestions feel free to do so.

Thank you very much.

- Chris


PARTNERS