Jump to content

  • Log In with Google      Sign In   
  • Create Account

incertia

Member Since 25 Nov 2011
Offline Last Active Oct 06 2014 01:00 PM

Topics I've Started

Problems with reversing a sublist of a linked list

29 September 2014 - 01:25 PM

So I'm trying to implement a doubly linked list again after horribly failing the last time I tried a few years ago, and I was remined again why I disliked reversing the list through pointer exchange.
// assume ListNode is a valid type
// and head/tail are initialized properly somewhere and filled with data
ListNode *head;
ListNode *tail;

void reverse(ListNode&* start, ListNode&* end){
    ListNode *c = start;
    while(c && c != end->next){
        std::swap(c->next, c->prev);
        c = c->prev;
    }
    // some extra logic goes here, i'm not sure what
}

// reverse(head, tail), reverse(head->next->next, tail->prev) should all be
// valid function calls on the dll
I can never seem to figure out what that extra bit of logic is to correctly update the references and pointers from other nodes.
std::swap(startPoint->next, endPoint->prev);
std::swap(startPoint, endPoint);
does not seem to be enough to correct the pointers.

Can't pass enumerated adapter in D3D11CreateDeviceAndSwapChain

16 October 2013 - 03:37 PM

So I have a pretty standard initialization call of D3D11
if(FAILED(hr = D3D11CreateDeviceAndSwapChain(this->m_pAdapter, pArgs->DriverType, pArgs->Software, pArgs->Flags, pArgs->pFeatureLevels, pArgs->numFeatureLevels,
	D3D11_SDK_VERSION, pArgs->pSwapChainDesc, &pSwapChain, &pDevice, pArgs->pFeatureLevel, &pContext))){
		return hr;
}
where pArgs->stuff is passed to the function via a structure to decrease the complexity of the function call. I got m_pAdapter via an IDXGIFactory (m_pFactory) like this:
this->m_pFactory->EnumAdapters(0, &this->m_pAdapter);
This is odd, because the first argument is supposed to be the the adapter to use and if null, the first enumerated adapter, which is the one I have, and it fails. However, passing NULL does not cause it to fail.

Any ideas on what could be causing my call to fail?

CreateWindowExW not setting window title

19 August 2013 - 06:46 PM

This is a really odd problem I have never experienced.

This is how I initialize my window:
 
CWindow::CWindow(WNDCLASSEXW *pWndClass, Infinity::INFINITY_WND_DESC *pWnd_Desc)
: m_refCount(1UL), m_hWnd(nullptr) {
	//Set m_wc
	memcpy(&this->m_wc, pWndClass, sizeof(this->m_wc));

	//Register the class provided
	RegisterClassExW(&this->m_wc);

	//Create the window
	this->m_hWnd = CreateWindowExW(pWnd_Desc->dwExStyle, pWnd_Desc->lpClassName, pWnd_Desc->lpWindowName, pWnd_Desc->dwStyle, pWnd_Desc->x, pWnd_Desc->y, pWnd_Desc->nWidth, pWnd_Desc->nHeight, pWnd_Desc->hWndParent, pWnd_Desc->hMenu, pWnd_Desc->hInstance, pWnd_Desc->lpParam);
}
and I pass L"blargh" as lpWindowName. However, when the window pops up, it has no text in the title bar. Has anyone else had the same problem before?

Using both D3D9 and D3D11

19 August 2013 - 05:56 PM

So in my own personal renderer, I want it to be able to support D3D9 and D3D11. To do this, I thought about having a master renderer interface that two classes will derive from. One will implement the D3D9 renderer and the other will implement the D3D11 renderer. However, this requires that I statically link to both D3D9 and D3D11, which will (I think) require that both dlls be present at run time. Is there any way I can avoid this?


Odd unresolved external symbol to nonexistent constructor

17 August 2013 - 02:16 PM

So once upon a time I wrote an interface
 
struct IC_API Infinity::IEventManager {
	virtual INFINITY_VOID	INFINITY_CALL	AttachEventListener(INFINITY_GUID EventID, EventCallback_t f) = 0;
	virtual INFINITY_VOID	INFINITY_CALL	DetachEventListener(INFINITY_GUID EventID, EventCallback_t f) = 0;			//maybe with std::find?
	virtual INFINITY_VOID	INFINITY_CALL	TriggerEvent(IEvent *e) = 0;
};
and something that implemented that interface in another project
class CEventManager : public Infinity::IEventManager {
public:
	CEventManager() {}
	~CEventManager() {}

	//GUID comparison functor
	typedef struct {
		bool operator()(const INFINITY_GUID &left, const INFINITY_GUID &right){
			if(left.Data1 < right.Data1) return true;
			if(left.Data2 < right.Data2) return true;
			if(left.Data3 < right.Data3) return true;
			for(register size_t i = 0; i < 8; i++)
				if(left.Data4[i] < right.Data4[i]) return true;
			return false;
		}
	} GUIDComparer;

	virtual INFINITY_VOID		INFINITY_CALL	AttachEventListener(INFINITY_GUID EventType, Infinity::EventCallback_t f){
		//Just insert it
		event_map[EventType].insert(f);
	}

	virtual INFINITY_VOID		INFINITY_CALL	DetachEventListener(INFINITY_GUID EventType, Infinity::EventCallback_t f){
		//See if the event type has any listeners
		auto it = event_map.find(EventType);
		if(it != event_map.end()){
			//If so, see if it has our listener function
			auto func_it = it->second.find(f);
			if(func_it != it->second.end()){
				//Then remove it
				it->second.erase(func_it);
			}
		}
	}

	virtual INFINITY_VOID		INFINITY_CALL	TriggerEvent(Infinity::IEvent *e){
		//Launch listeners
		INFINITY_GUID magic = e->GetEventType();
		std::for_each(event_map[magic].begin(), event_map[magic].end(), [&] (Infinity::EventCallback_t f) -> INFINITY_VOID { f(e); });

		delete e;		//Because it's called with something like TriggerEvent(new IEvent(...));
	}
private:
	//Global event listener storage for each event
	//Maps (GUID EventType) -> set of listener functions
	std::map<INFINITY_GUID, std::set<Infinity::EventCallback_t>, GUIDComparer> event_map;
};
except I'm getting an unresolved external symbol to an undefined constructor:
 
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Infinity::IEventManager::IEventManager(void)" (__imp_??0IEventManager@Infinity@@QAE@XZ) referenced in function "public: __thiscall CEventManager::CEventManager(void)" (??0CEventManager@@QAE@XZ)
 

Any ideas on what could be causing this problem?

PARTNERS