Jump to content

  • Log In with Google      Sign In   
  • Create Account

L. Spiro

Member Since 29 Oct 2003
Offline Last Active Today, 08:54 PM

Topics I've Started

MIT License in PlayStation Vita Game

09 July 2014 - 03:43 PM

The language of the MIT license isn’t the clearest in the world: http://opensource.org/licenses/mit-license.php
 

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.


At first I thought this meant that I just had to keep the copyright notice inside the source files, but apparently it means I have to include their notice somewhere as a separate file along with my game(s).

But our game is for PlayStation Vita, so that is obviously impossible.
It is also impossible to show their MIT copyright text inside the game anywhere.

Do I simply have to not use the MIT-licensed code or are there other options etc.?


L. Spiro

My Kingdom for a Link to a Past Post

24 June 2014 - 09:40 PM

Search-after-search I can’t find a past post I really need right now.

 

A long time ago someone did some tests on the best ways to update vertex buffers and he shared his results, but when I try the few key words I remember (which I won’t list here in order not to pass on a possibly mistaken key word to others) I just get results of people asking questions.  I even searched replies for a link to the post for which I am searching and nothing.

 

So the guy benchmarked at least 3 ways to update vertex buffers.

He did client arrays and VBO’s with DYNAMIC_DRAW and different updating strategies.

One of the strategies was orphaning.

It was about 2 years ago.

 

My kingdom for anyone who can find that post.  It may have been OpenGL ES 2.0.

 

 

L. Spiro


Direct3D 11 Swap-Chain Madness

23 June 2014 - 09:41 AM

Hi I am L. Spiro, long-time lurker first-time poster.
So one day I was walking along and Direct3D 11 jumped out and bitch-slapped me, then it stepped on my hair, and it told me I was fat.

I am trying to swap between windowed and full-screen and “for reasons” I am not going the standard route by calling IDXGISwapChain->SetFullscreenState() etc. My way is to destroy the window, make a new one, and make a new swap chain for it. I have reasons relating to my engine’s tools and also complicity with the way my other targeted platforms work. Simply put, it is necessary for me to be able to create and destroy multiple windows. And my system works fine except for 1 very strange bug.

If I start in windowed mode, I get an unhandled exception when I go to full-screen.
If I start in full-screen, I can switch to windowed, then if I switch back to full-screen I get an unhandled exception.
I normally get it here:
	LSE_INLINE LSVOID LSE_FCALL CDirectX11::Clear( LSG_RENDER_TARGET * _prtRenderTarget ) {
		GetDirectX11Context()->ClearRenderTargetView( _prtRenderTarget, m_rsCurRenderState.fClearColor );
	}
_prtRenderTarget will be the address of the newly created color buffer. The address is valid and the buffer does exist. Also, the Direct3D context is untouched and valid throughout.
The error is this:
First-chance exception at 0x000007fefd1e940d in LSTest.exe: 0x0000087A: 0x87a.
 
You want to say, “Are you sure all the involved pointers/objects are valid?”.
I am glad you asked that.  Let me show you.


When the window mode changes, 4 objects are destroyed and then recreated with the new window:
/** Our swap chain. */
IDXGISwapChain *		m_pscSwapChain;

/** View to the back color buffer. */
ID3D11RenderTargetView *	m_prtvRenderTargetView;

/** The depth-stencil texture. */
ID3D11Texture2D *		m_pt2dDepthStencilBuffer;

/** View to the back depth/stencil buffer. */
ID3D11DepthStencilView *	m_pdsvDepthStencilView;
(_prtRenderTarget matches m_prtvRenderTargetView when the exception happens.)

So I logged the creation and deletion of m_prtvRenderTargetView since that is the object being passed to Clear().
 
RELEASED 00000000
CREATED 0BD66A88
RELEASED 0BD66A88
RELEASED 00000000
CREATED 0BD63708
First-chance exception at 0x000007fefd1e940d in LSTest.exe: 0x0000087A: 0x87a.
* Debugger shows _prtRenderTarget = 0x0BD63708 inside Clear().
 
 
 
Now let me show you why this is strange.
I changed my code to this:
	LSE_INLINE LSVOID LSE_FCALL CDirectX11::Clear( LSG_RENDER_TARGET * _prtRenderTarget ) {
		static LSBOOL bFailedLast = false;
		try {
			if ( bFailedLast ) {
				LSCHAR szBuffer[43];
				CStd::SPrintF( szBuffer, 43, "PASS 2 %.8X\r\n", _prtRenderTarget );
				CStd::DebugPrintA( szBuffer );
			}
			GetDirectX11Context()->ClearRenderTargetView( _prtRenderTarget, m_rsCurRenderState.fClearColor );
			bFailedLast = false;
		}
		catch ( ... ) {
			bFailedLast = true;
			LSCHAR szBuffer[43];
			CStd::SPrintF( szBuffer, 43, "DIE %.8X\r\n", _prtRenderTarget );
			CStd::DebugPrintA( szBuffer );
		}
	}
This basically means if it fails I will print “DIE” and then on the next call I will print “PASS 2”.
Here is the log now:
RELEASED 00000000
CREATED 000F5588
RELEASED 000F5588
RELEASED 00000000
CREATED 0BD669C8
RELEASED 0BD669C8
RELEASED 00000000
CREATED 0BD63708
First-chance exception at 0x000007fefd1e940d in LSTest.exe: 0x0000087A: 0x87a.
DIE 0BD63708
PASS 2 0BD63708
RELEASED 0BD63708
RELEASED 00000000
CREATED 0BDBA808
RELEASED 0BDBA808
RELEASED 00000000
CREATED 0BDBA808
RELEASED 0BDBA808
RELEASED 00000000
CREATED 0BEB9908
RELEASED 0BEB9908
RELEASED 00000000
CREATED 0BEBB508
RELEASED 0BEBB508
RELEASED 00000000
CREATED 0BD67748
RELEASED 0BD67748
RELEASED 00000000
CREATED 0BEB9248
RELEASED 0BEB9248
RELEASED 00000000
CREATED 0BEB9248
RELEASED 0BEB9248
RELEASED 00000000
CREATED 0DD4F7C8
RELEASED 0DD4F7C8
RELEASED 00000000
CREATED 0BD66688
RELEASED 0BD66688
RELEASED 00000000
CREATED 0BDBA808
RELEASED 0BDBA808
RELEASED 00000000
CREATED 0DD47708
RELEASED 0DD47708
RELEASED 00000000
CREATED 0DD47708
RELEASED 0DD47708
RELEASED 00000000
CREATED 0DD56A88
RELEASED 0DD56A88
RELEASED 00000000
CREATED 0BD66688
RELEASED 0BD66688
RELEASED 00000000
CREATED 0BD67748
RELEASED 0BD67748
RELEASED 00000000
CREATED 0BD98888
RELEASED 0BD98888
RELEASED 00000000
CREATED 0DD47708
RELEASED 0DD47708
RELEASED 00000000
CREATED 0BD59EC8
Changing state.
*==
RELEASED 0BD59EC8
RELEASED 00000000
RELEASED 00000000
 
Go home Direct3D 11, you’re drunk.

Start in full-screen:
RELEASED 00000000
CREATED 000F5588

Full-screen to windowed:
RELEASED 000F5588
RELEASED 00000000
CREATED 0BD669C8

Windowed to full-screen:
RELEASED 0BD669C8
RELEASED 00000000
CREATED 0BD63708
First-chance exception at 0x000007fefd1e940d in LSTest.exe: 0x0000087A: 0x87a.
DIE 0BD63708
PASS 2 0BD63708

* Draws fine for a while, no bugs. *
Full-screen to windowed:
RELEASED 0BD63708
RELEASED 00000000
CREATED 0BDBA808

* Draws fine, many mode switches follow, never throws the exception again. *
 
 
So, yes, I am positive that all objects are valid.
It creates object 0BD63708, fails to clear it once, but then has no problem clearing it after that.
After it throws 1 (one) exception it can not only continue working with the exact object that caused the exception but the exception never happens again no matter how many times I destroy the window and swap chain and recreate them both.
 
 
 
Here is the code for destroying and recreating the swap chain and back buffers (minus the debug prints) with a new window:
	LSE_INLINE LSVOID LSE_CALL CDirectX11::SetWindowParms( LSBOOL _bWindowed, HWND _hWnd ) {
		// Get the width and height of the window.
		RECT rClient;
		::GetClientRect( _hWnd, &rClient );
		m_dscdSwapChainDesc.BufferDesc.Width	= rClient.right - rClient.left;
		m_dscdSwapChainDesc.BufferDesc.Height	= rClient.bottom - rClient.top;
		m_dscdSwapChainDesc.OutputWindow	= _hWnd;
		m_dscdSwapChainDesc.Windowed		= _bWindowed;

		ReleaseBackBuffers();
		SafeRelease( m_pscSwapChain );
		IDXGIFactory * pfFactory;
		if ( SUCCEEDED( ::CreateDXGIFactory( __uuidof( IDXGIFactory ), reinterpret_cast<void **>(&pfFactory) ) ) ) {
			pfFactory->CreateSwapChain( m_pdDevice, &m_dscdSwapChainDesc,
				&m_pscSwapChain );
			SafeRelease( pfFactory );
		}
		CreateSwapChainBackBuffers( _hWnd );
	}

	LSVOID LSE_CALL CDirectX11::ReleaseBackBuffers() {
		SafeRelease( m_pdsvDepthStencilView );
		SafeRelease( m_pt2dDepthStencilBuffer );
		SafeRelease( m_prtvRenderTargetView );
	}

	LSBOOL LSE_CALL CDirectX11::CreateSwapChainBackBuffers( HWND /*_hWnd*/ ) {
		ReleaseBackBuffers();


		// Create the color buffer.
		ID3D11Texture2D * ptBuffer = NULL;
		if ( FAILED( m_pscSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ),
			reinterpret_cast<void **>(&ptBuffer) ) ) ) {
			CStd::DebugPrintA( "Failed to access front buffer.\r\n" );
			ReleaseBackBuffers();
			return false;
		}
		if ( FAILED( m_pdDevice->CreateRenderTargetView( ptBuffer, NULL, &m_prtvRenderTargetView ) ) ) {
			CStd::DebugPrintA( "Failed to create the main render target.\r\n" );
			ReleaseBackBuffers();
			SafeRelease( ptBuffer );
			return false;
		}
		SafeRelease( ptBuffer );


		// Make the depth/stencil buffer.
		D3D11_TEXTURE2D_DESC tdDepthStencilDesc = { 0 };
		[SET ALL THE PARAMETERS]
		if ( FAILED( m_pdDevice->CreateTexture2D( &tdDepthStencilDesc, NULL, &m_pt2dDepthStencilBuffer ) ) ) {
			CStd::DebugPrintA( "Failed to create the main depth/stencil buffer.\r\n" );
			ReleaseBackBuffers();
			return false;
		}

		// And now the view.
		D3D11_DEPTH_STENCIL_VIEW_DESC dsvdDesc = { tdDepthStencilDesc.Format };
		dsvdDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
		dsvdDesc.Texture2D.MipSlice = 0;
		if ( FAILED( m_pdDevice->CreateDepthStencilView( m_pt2dDepthStencilBuffer, &dsvdDesc, &m_pdsvDepthStencilView ) ) ) {
			CStd::DebugPrintA( "Failed to create the depth/stencil view.\r\n" );
			ReleaseBackBuffers();
			return false;
		}

		return true;
	}
I get no failure debug outputs and all the objects are created successfully.
I have enabled DirectX 11 Debug Mode in the control panel. It prints nothing.
The first time and only the first time it goes into full-screen mode from windowed mode it throws this exception.
It can also throw it here:
	LSE_INLINE LSVOID LSE_FCALL CDirectX11::Present() {
		m_pscSwapChain->Present( 0, 0 );
	}
In either case it throws only one time and then works perfectly fine after that.


The double RELEASE lines in the log are because ReleaseBackBuffers() is being called twice, but SafeRelease() sets the pointers to NULL.
I have no errors with my reference counters etc.
My window code (creating and destroying, windowed mode and full-screen mode) is the same on all platforms and is not the problem.
This is all single-threaded.



Is there something I need to do when switching from windowed to full-screen the first time? It always works after the first time, so the concept and my implementation should be sound. Honestly this is looking like a driver bug.
Any ideas?


L. Spiro

FreeImage Linker Error in Visual Studio 2008

05 June 2014 - 04:00 PM

I am trying to add FreeImage to LSEngine and have encountered linker errors.
I have posted the details here:
http://sourceforge.net/p/freeimage/discussion/36110/thread/fcf4b8a9/?limit=25#ff6a/a668
 
What you can take away from it:

  • The FreeImage static library is built with no errors and copied to a certain location as a post-build event.
  • I am correctly linking to that library, in 2 ways (and this is verified).
    • As an additional dependency.
    • As a project reference.
  • FreeImage_Initialise and FreeImage_DeInitialise are part of the library.  They are declared in FreeImage.h, defined in Plugin.cpp, and both files are part of the FreeImage static library project.
  • As per the second post there, I have copied the pre-defined macros from the FreeImage project to LSImageLib so that both projects see the headers exactly the same way.  This changed the error from __imp__FreeImage_Initialise@4 to _FreeImage_Initialise@4.
  • _FreeImage_Initialise is inside FreeImage.lib, _FreeImage_Initialise@4 is not.

Based on #4 and #5, it is simply a matter of decorations, but it was past my bedtime and I ran out of ideas to try.
Of note: In FreeImage.h, the functions are inside and extern "C" {} block but the definitions inside Plugin.cpp are compiled as C++.
What I have tried from there:

  • Made a file called Plugin.c and moved those function definitions into it (and added it to the project).
    • It never compiled the file for some reason.  I would click the file and tell it compile Plugin.c, but it would say, “Compiling Plugin.cpp…”.
    • The functions use new and delete, so they couldn’t compile to C anyway, even if Visual Studio did recognize it.
  • I moved the declarations out of the extern "C" {} block.
    • I got the same linker error but with a different mangling of the name.
  • I set FreeImage’s project settings to fully match those of LSImageLib’s, particularly including the default calling convention (which was set to __cdecl but LSImageLib has it set to __stdcall).
    • No change to the error.

I was simply too tired to continue and I couldn’t think of any more ideas to try.
It is clearly a name-mangling/decoration issue with a very tricky solution.
Any ideas appreciated.


L. Spiro


Mars-One Round 3

26 February 2014 - 03:23 AM

Previous topic here: http://www.gamedev.net/topic/651714-mars-one/

To pass to round 3 you need to have have a medical exam they provided signed by a doctor who performed all the checks to ensure your good health.
The results of a drug test came back so soon I only had time to take the eye exam (passed with greater than 20/20 (American system for 100% vision)) before the doctor pulled me into the room to explain he was not willing to sign the document, asking if I was on any medication or drugs.

I denied and he pushed a failed drug test in front of me and asked me to explain why there was benzodiazepine (BZO) in my system. With no idea what that meant I said I had taken a laxative that day and he replied that would not cause this. “So what would?”
It is a muscle-relaxant. I had taken a sleeping pill the previous week. Seems they stay in your system for up to 6 weeks, and even though it wouldn’t be a problem for me to just not use them for 5 more weeks, by then the deadline would be over.

He also asked how I got them. Naturally, you can only get them by being diagnosed with insomnia, which classifies as a psychiatric disorder. The Mars-One exam also forbids any psychiatric disorders so he considered that to be strike 2.


I explained that that was years ago and I only keep the pills around for rare cases in which I need to change my schedule, due to jet lag, weird acting schedules, etc., and that I could easily get undiagnosed by the same doctor if I simply took the time to do it.

He still refused to sign off because that counts as a “history” of a psychiatric disorder. He said they spend millions on these projects and he wanted to stick to the letter on their exam. I pointed out that the word “history” is not on the exam at all, so there is no reason getting undiagnosed would leave me anything but to-the-letter.

He still refused and said that perhaps another doctor would be willing to sign off but he would not.


I have never failed a test before, and I was not willing to accept this under any circumstances; not when it was such a stupid reason. If I understood the concept of “giving up” I’d not be making games in Japan.
I thought carefully on the train home and even watched a movie to give myself 2 more hours to come up with the best wording for an e-mail to Mars-One on this issue.

I explained the whole situation to Mars-One, that I only had insomnia shortly after moving to Japan (which is a reasonable time to have insomnia), and that I had no dependency on the pills, and I also explained failing the BZO test.

They replied rather quickly and reasonably. Not only does their doctor use pills for the same reason (long plane rides, jet-lag, etc.), he said the main point of the test was a lack of dependency. As long I have none, I would not have a problem going to round 3, and I did not need to retake the test.



The doctor then agreed to continue the remaining tests.
The rest I passed with colors that fly, the doctor signed the exam which I then submitted to Mars-One.
I also requested to be in the Japanese or Asian region for round 3, with America as a backup.

In his (the Mars-One doctor’s) reply, he didn’t mention what region I would enter but he did leave no doubt as to my validity for round 3, to some degree implying that the interview for round 3 will just be a formality. As long as I don’t go there and my head spins while I yell satanic worship I should be fine.

It seems as though out of the 1,058 round-2 members, only a few hundred passed the exam, some being eliminated simply for having had eye laser surgery within the last year, others for one disease or another.


In short, let’s get ready for round 3! Passing round 3 is the last step; once you pass that you are officially scheduled to go to Mars.


L. Spiro

PARTNERS