Member Avatar

Hi Answerers, **Background:** I just figured out how to solve my unresolved external symbols by just dragging the project files from explorer (contained in exe's directory) and plonking them in the dll project, under thier own filter! **Original Situation:** I was getting 'unresolved external symbols' errors because I was #include-ing files that my dll needed that resided in the exe's project folder. Guessing I would figure that the .obj files would get built and the .dll would not know where they were to link to them. **My Question:** * Will this cause any problems in the future? - having two …

Member Avatar
+0 forum 2
Member Avatar

Hi 'Wise & Wonderful Daniwebbers', Why do I keep loosing my project settings when I add a new project to an existing solution? I have to go to every project, in the solution and re-configure each project's: * Include Directories; * Library Directories; * Linker Settings; etc., Which of the solution files, if any, can I backup then restore when it happens? * *.vcxproj? * *.vcxproj.user? * *.vcxproj.filters? other? Thanks in advance :)

+0 forum 0
Member Avatar

Hi, The problem I am having is that the returned object, from a dll factory, is not lasting for more than the function scope that recieves it. Despite reading [How to prevent the static initialisation order fiasco](http://www.parashift.com/c++-faq/static-init-order-on-first-use.html) I fail to see how it even applies to my code. `g_spEngineLog` is the global that is in question. I have declared it as extern in CEngine header and defined it in the implementation. I Hope this is right! // This is the factory function inside a dll: extern "C" IMPEXP void* CreateClassInstance(bool bBinary) { if (bBinary) return (static_cast<void*>(new CLog<CFileBinary>)); else return (static_cast<void*>(new …

Member Avatar
+0 forum 1
Member Avatar

Hi, When I initialise then access the `g_spMyLog` shared pointer, from within the `CSingleton::CreateLog` member function, it works ok. Accessing the SP from the static member function of `CSingleton::Create()` causes an `access violation` in the original project and an abort in this sample project displayed below. In the original project I think the object is going out of scope somewhere but I don't know where. The factory function is created within a DLL as `return (static_cast<void*>(new CMyLog));` which is then `static_cast` to a `CMylog*` straight into a shared_ptr like this: `g_spMyLog.reset(static_cast<CMyLog*>(CreateVoidObj(is_Binary)));` but that's not included here. // File: CSingleton.h #pragma …

Member Avatar
+0 forum 2
Member Avatar

Hi Kind-DaniWebbers, How do you initialise a boost::archive:binary_oarchive in a different place to where you declare it? So: class CBase { std::ofstream m_ofs; boost::archive:binary_oarchive m_binOA(); // <== default constructor virtual void Open(std::string& s) = delete; }; class CDerived : CBase { void Open(std::string& s) override { CBase::m_ofs("filename.bin", std::ios::binary); CBase::m_binOA(CBase::m_ofs, /*flags*/); // <== says error C2660: '...'::m_binOA' : // function does not take 2 arguments } }; I am trying to create different interfaces for XML, TXT and BIN. So I just derive from the one I want. Is this the way to do it? I struggling to design this. Please …

Member Avatar
+0 forum 1
Member Avatar

Dear Kind DaniWebbers, I am trying to overload the fstream operators (ofstream/ifstream), so that I can save a class to a 'Binary' file and also display it with cout. But the ways in which each need to be implemented is different. Please can you show me how to define different operators for each. Here is my test class: class CBase { public: //CBase(void) {}; CBase(int i = 0, float f = float(0.0), double d = double(0.0), char c = 'A') : iMyInt(i), fMyFloat(f), dMyDouble(d), cMyChar(c) {} ~CBase(void) {} int iMyInt; float fMyFloat; double dMyDouble; char cMyChar; friend std::ostream& operator<<(std::ostream& os, …

Member Avatar
+0 forum 4
Member Avatar

I have read tutorials using my google-fu on how to set up Pre-Compiled Headers, and now I wanted to clear up a few questions: If all the 'to be pre-compiled' headers go in one file - "stdafx.h" then how do you say you only want 1 of those files in your 'unstable' class headers/implementations? If the said PCH header only goes at the top of your implementation (.cpp) file then how is your class in the header (.h) file supposed to know about objects? Does the compiler know because it is included before the implementation includes its own header? Arrrh …

Member Avatar
+0 forum 6
Member Avatar

Dear Kind-Coders, I am trying to learn to use boost::shared_ptr to manage the lifetime of a DLL, but I am having a type conversion problem whilst setting it up. Please see the following code: #include <boost/make_shared.hpp> int main() { { class CMyClass { public: CMyClass() {} ~CMyClass() {} int MyInt; }; typedef void* (*fpFunct1)(); fpFunct1 CreateFoo; /*********************************************** Build error because cannot convert from 'HINSTANCE__ *' to 'HINSTANCE__ **' ************************************************/ boost::shared_ptr<HMODULE> spHDL (LoadLibrary("DllMain.dll"), FreeLibrary); // get the function pointer CreateFoo = (fpFunct1)(GetProcAddress(*spHDL, "CreateFooClassInstance")); // get pointer to object auto pMyClass = boost::make_shared<CMyClass*> (static_cast<CMyClass*> (CreateFoo())); (*pMyClass)->MyInt = 9; } // See destructor/custom_deleter …

Member Avatar
+0 forum 5
Member Avatar

Hi I'm trying to create an array of function pointers contained within a class, the C++11 way. Can I have some help with this as I'm getting a bit mixed up. Here's what I have done so far. They are made up classes to define the problem. #include <iostream> #include <functional> #include <vector> using namespace std; class CPerson; class CAle { public: CAle(void) {}; ~CAle(void) {}; bool Sip1(CPerson* pPerson1, CPerson* pPerson2) { cout << "Sip 1" << endl; }; bool Sip2(CPerson* pPerson1, CPerson* pPerson2) { cout << "Sip 2" << endl; }; bool Sip3(CPerson* pPerson1, CPerson* pPerson2) { cout << …

Member Avatar
+0 forum 4
Member Avatar

Hi, Please may I have your help on this one. The error is: 1>------ Build started: Project: DXTB 17, Configuration: Debug Win32 ------ 1> Main.cpp 1> _MyDebug Defined... 1> _Main Defined... 1> _CApplication Defined... 1> _CSpriteManager Defined... 1> _CSprite Defined... 1> __CStats Called... 1> _CStats Defined... 1> _CVector3F Defined... 1> _CText Defined... 1> _CFile Defined... 1> _CMap Defined... 1> _CTile Defined... 1> _CCollisionManager Defined... 1> _CEntity Defined... 1> _CCamera2D Defined... 1> _TPhysics Defined... 1> __CStats Called... 1>d:\code\dx tuts\projects\dxtb_curr\dxtb 17_2\dxtb 17\ccamera2d.h(28): error C2504: 'CStats' : base class undefined I have header gaurds and pertinent forward declarations where neccassary. I am defining …

Member Avatar
+0 forum 2
Member Avatar

Hi , Please can anyone help. I have a window(1280x768) that contains a resolution(1920x1080). I am trying to use ScreenToClient to obtain the mouse coordinates while in windowed format. I am drawing a line from a subject to the mouse cursor which works fine in fullscreen but not in windowed. The ScreenToClient function doesn't quite work because (I speculate) of the resolution. Does anyone know of a way to correct this...? Thank in advance

Member Avatar
+0 forum 3
Member Avatar

Hi, Im using DX9c and learning from Frank Luna's book to try and handle OnLostDevice and OnResetDevice, when switching to fullscreen and back (and alt+tabbing). If I dont draw anything I am able to go from windowed to fullscreen, and back, with no trouble. But adding a draw and flush then pressing the fullscreen key causes the following msgbox error: (at the m_pSprite->flush();) > Unhandled exception at 0x56E5B1FC (D3DX9_43.dll) in DXTB 14.exe: 0xC0000005: Access violation writing location 0xCCD020CC. Although I do enjoy getting stuck on problems I have been rearranging my code and typing like a monkey for 1 week …

Member Avatar
+0 forum 1
Member Avatar

Everything was running fine, then I made a simple change. Like adding a class or two and bang!!! C2995. Can you spot where I have obviously gone blind and cannot see the error. I have header gaurds throughout the solution, so I dont understand why this is happening. Here are two of the classes which were working before. I tried a clean rebuild also. Question: Is my coding of the template TPhysics.h ok (btw)? Compile it and see...! 1>------ Build started: Project: DXTB 12, Configuration: Debug Win32 ------ 1> Main.cpp 1>d:\code\dx tuts\projects\dxtb 12\dxtb 12\tphysics.h(76): error C2995: 'TPhysics<T>::TPhysics(void)' : function template …

Member Avatar
+0 forum 2
Member Avatar

I have written a working templated linked list that can hold a number of Types. Each of which are created with new before sending them to the InsertNode function. in Main: CMyType* pMyType1 = new CMyType; // Create a new MyType* pMyType1->m_iData = 5; // Hold a value LLMyTypes.InsertAtEnd(pMyType1); in CLinkedList::InsertAtEnd(...) CNode<T>* pNewNode = new CNode<T>(pData); ... m_uNodeCount++; Should I delete just the node? or the data then the node or what? I have run some tests and the following runs fine within CLinkedList::DeleteNode(...) delete pNode->GetData(); // inline just returns m_pData (calls destructor of MyType) delete pNode; // (calls destructor) …

Member Avatar
+0 forum 2
Member Avatar

Hi I am allocating memory space and adding nodes like this: CSprite* pNewSprite = new CSprite; // Create new sprite pNewSprite->iData = iChoice; // Attach data EnemyList->AddNode(pNewSprite); // Send to AddNode and also in the ::AddNode: void CLinkedList::AddNode(VOID* pData) { CNode* pNewNode = new CNode; // Create the Node pNewNode->pData = pData; // Assign the Sprite data ... m_iNumberOfNodes++; } And then (trying) to delete them like this: // Clear up and delete resources CurrentNode = EnemyList->m_pHeadNode->pNext; // Point to first in list while (CurrentNode != EnemyList->m_pEndNode) { delete CurrentNode->pData; // <======= Second time around access violation ======== delete CurrentNode; …

Member Avatar
+0 forum 9
Member Avatar

Hi, Using Visual Studio 2012. Why does the syntax highlighting turn off periodically. Then unexpectedly it turns back on again, unreproducably, and rather annoyingly. A chocolate eclair for anyone who knows...?

Member Avatar
+0 forum 4
Member Avatar

Hi I am getting some strange results from my framerate calculation. It seems to have a mind of its own. It wants to stay at about 60 fps even if I set it to 80fps. It does run though if I set it to 50fps. I am getting smooth movement at 60fps but at 50fps the waiting part kicks in and starts to jitter the movement. I have given the entire while loop. it works I've tested it but I dont know why it stays at 60 fps and not go crazy. Please help. MSG msg; DWORD ticks = GetTickCount() …

+0 forum 0
Member Avatar

**Simple Question:** What is the best way to set the framerate. Is it with GetTickCount() or QueryPerformanceCounter()...? Please can you give me a coded example of how to use whichever one within the 'Game Loop' ? **Advanced Question:** Is it possible to do something in the 'Waiting' part of the framerate calculation. Can you give me some examples of how this time could be utilised (theoretically) ? Thanks...! Elixir

Member Avatar
+0 forum 1
Member Avatar

I have a function to detect if the mouse is over a mesh but what if I had a hard coded square. I am using D3DXIntersectTri() and pluggin my vertices into it. but they (obviously) dont update when I move the square. My question is how do you get the vertex data from the vertex buffer. So I could potentially change a vertex on the fly. Am I doing this the right way?

+0 forum 0
Member Avatar

I have searched on the internet for a 'working' double to char* does anyone have any idea? I need to pass the string to a function that takes a char* as an argument.

Member Avatar
+0 forum 6
Member Avatar

Hi I am setting the sampler states initially then setting them on the fly with keypresses that I know runs but I dont see anything changing. Am I missing something. Can I just call SetSamplerState(...) anytime or do I need to call something after? static bool bToggleH = false; static int iNum = 0; if(KEY_DOWN(VKY_H)) if (bToggleH) { bToggleH = false; // run once switch (iNum) { case 0: g_Text->SetRow(TXT_MINFILTER, "D3DSAMP_MINFILTER = D3DTEXF_POINT"); m_pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT); // minification break; case 1: g_Text->SetRow(TXT_MINFILTER, "D3DSAMP_MINFILTER = D3DTEXF_LINEAR"); m_pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); // minification break; case 2: g_Text->SetRow(TXT_MINFILTER, "D3DSAMP_MINFILTER = D3DTEXF_ANISOTROPIC"); m_pD3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_ANISOTROPIC); …

Member Avatar
+0 forum 4
Member Avatar

Hi I can't seem to adjust the D3DXFONT_DESC properties. Sometimes it breaks at getDesc(...). I want to be able to have **each text row have their own font description and be able to change it**. Why is it not working??? Maybe I setting it in the wrong place or maybe it is not being 'set'. **(See ::Add)** My great thanks to you who solves it!!! Here is the class header and implementation: CText.h #ifndef CText_h #define CText_h #include <d3dx9.h> #define MAX_TEXT_ROWS 20 class CText { public: CText(void); ~CText(void); void Create(void); int Add(char* cText); void Remove(void); void SetRow(int iRow, char* cText); …

Member Avatar
+0 forum 3
Member Avatar

Hi I dont understand why this int keeps corrupting ::Draw works fine but the variable m_EndRow ends up as a funny number. The class is supposed to print debug info to my screen. ::AddText adds a row of text which is then printed in DrawTable. Simple problem if you already know - but I don't!! CText.h #ifndef CText_h #define CText_h #include <d3dx9.h> #define MAX_TEXT_ROWS 10 class CText { public: CText(void); ~CText(void); void Create(void); int AddText(char* cText); void Draw(void); void DrawTable(void); private: LPD3DXFONT m_DXFontMaster; // pointer to the font object RECT m_TextBoxMaster; // rect to contain the text struct TEXTROW_TYPE { …

Member Avatar
+0 forum 2
Member Avatar

Hi sorry for yet another circular inclusion problem but I need help understanding why I cant add a new class CSprite to my project that inherits CShape. I get an error C2504 base class is undefined. I've tried so many permutations of including files. Also can anyone suggest a neater/efficient/correct way of how my includes should be set up. (include-graph) Here are the header files with the functions snipped: Main.h --> #ifndef main_h #define main_h // Windows and DirectX includes #define STRICT #include "windows.h" #include <d3d9.h> #include <d3dx9.h> //#include <vector> #pragma comment (lib, "d3d9.lib") #pragma comment (lib, "d3dx9.lib") // Application …

Member Avatar
+0 forum 3

The End.