• Advertisement

Mike nl

  • Content count

  • Joined

  • Last visited

Community Reputation

390 Neutral

About Mike nl

  • Rank
  1. Quote:Original post by nlraley Would you recommend doing with a loadtexturefromfile and drawing the texture or using a sprite? Even with a sprite (ID3DXSprite, I assume), you still have to provide the texture. So you have to load it from a file anyway. You can either use ID3DXSprite or roll your own, which isn't *that* hard. Just two triangles with texture coordinates. The former is a bit easier, but the latter gives you more flexability, which may be helpful later on.
  2. No problem here. Both MainData and the IPlugin class would be defined in some header that gets included by both the main.dll source files as well as the plugin source files. Then both know about the data structures used. By the way, you'll probably want to use GetProcAddress to get a function from the plugin.dll which creates and returns an instance of the plugin class. Example: (it's been a while since I used LoadLibrary, etc, so treat this as some quickly-written pseudo-code) custom_plugin.cpp: #include "plugin_defs.h" class MyCustomPlugin : public IPlugin { void DeleteThis() { delete this; } void do(MainData& d) {}; }; IPlugin* EXPORT CreatePlugin() { return new MyCustomPlugin(); } main.cpp: #include "plugin_def.h" void EXPORT DoWorkWithPlugin(String path, const MainData& data) { // Load library and get function HANDLE hLib = LoadLibrary(path); IPlugin* (*plugin_creator)() = GetProcAddress(hLib, "CreatePlugin"); // Create plugin IPlugin* plugin = plugin_creator(); plugin->do(data); } Keep in mind that it's good practice that objects created in a DLL should be deleted in that DLL. This can be tricky when you're passing out pointers across DLL boundaries. This is why I defined the DeleteThis member in the example.
  3. With DrawPrimitive you're telling it to draw only ONE primitive (triangle). Try making that 2.
  4. How are you using your template class? I would wager (from the error code) that you're using it as, for instance: CSectorMap<T> map; In which case you need to put an actual type there like 'int' instead of T. Edit: or it seems you're putting member functions in a source file, e.g.,: void CSectorMap<T>::foo() { } This doesn't work. All template member functions must be in the header file.
  5. 3) Depending on the compiler and/or underlying memory implementation, the write may never show up for the reader. 4) The reader may read a value that was never written. If the write isn't atomic, for instance (half-write, read, half-write; the reader now has half new data, half old data). This also applies to groups of variables. Your scenario 1 can be a valid use case; chaotic relaxation when searching for stable states, for instance. I don't think scenario 2 will ever occur in practice, though.
  6. get local ip

    Your "192 and 10 ip addresses" are not good enough. RFC 1918 defines the private IP ranges. They are - (10/8 prefix), - (172.16/12 prefix) and - (192.168/16 prefix). I believe that what you need to do is get the local addresses for the host with gethostname/gethostbyname (the in_addr list). If all of those addresses are in one of the three private domains, display the message (since the host has no public address). Otherwise, you can use the public address for incoming communication. And don't use string compares. in_addr is an IPv4 address, you should just mask and compare the bits directly (don't forget, the contents is in network byte order; use ntohl() first). Also, you may want to check if the hostent's h_addrtype member is AF_INET (IPv4) of AF_INET6 (IPv6) and interpret it's h_addr_list member as either a list of in_addr's or in6_addr's. RFC 4193 defines the private addresses for IPv6.
  7. The question is lacking some constraints... As stated, an acceptable solution would be a random point (say, (0,0)) with appropriate radius (O(n) to find the radius). But 'finding' the center is O(1). I think you need to specify some condition which has to be balanced. Maybe minimize the radius? But then what's 'many points'? Edit: disregard, misread. The radius is fixed...
  8. Maybe the back buffer that you're rendering to is not of the same size as the viewport it's displayed in. So it's resampled, causing these artifacts.
  9. *bump* Also, I found out today that this doesn't happen for files which are included from the main file. Then it shows the path as specified in the include directive. Doesn't anyone have an idea about this?
  10. Hello everyone, I hope someone can help with this lest I use the ugly solution. In my game engine, I'm loading effects from my VFS via D3DXCreateEffectFromFile with a custom ID3DXInclude handler, using the fact that the include handler is also called (albeit twice) for the specified path. Now, this works fine; my problem is one of aesthetics. If there is an error, DirectX seems to prefix the specified path with the current working directory. For instance, when I pass "DX9\Brush" (which includes a non-existant Globals.fxh) to D3DXCreateEffectFromFile with my custom include handler, I expect this error message: DX9\Brush(4,10): error X1507: failed to open source file: 'Globals.fxh' However, I get this: D:\Project\MapEditor\bin\Debug\DX9\Brush(4,10): error X1507: failed to open source file: 'Globals.fxh' The same occurs when I use D3DXCreateEffect after loading the file into memory beforehand: D:\Project\MapEditor\bin\Debug\memory(4,10): error X1507: failed to open source file: 'Globals.fxh' Which is even weirder, IMO. I can see why D3DXCreateEffectFromFile might think that it's an path relative to the CWD. But for memory files as well? That does not compute for me. So I hope someone has a solution to this problem, otherwise I'll have to do some ugly string replaces. Thanks in advance, Mike PS: for completeness, my situation is that I'm writing the engine in a statically linked C++ lib and am using that lib in this C# tool via C++/CLI. I'm using the August 2009 SDK. Debug runtime gives no error or related warning. Google searches gave me nothing relevant.
  11. Recommend me a 24" Monitor

    I'm using two 24" Samsung Syncmaster 2443BW screens (like this guy). It's max (and ideal) resolution is 1920x1200 (16:10). Tends to cost around €250 a piece here. It's a matte screen, has a thin border (~1.6cm), touch-sensitive buttons and a single blue power LED. I use them at home for coding, gaming and anything else and I can't say I have any problems with them. But then again, I'm not a videophile :)
  12. rvalue reference question

    Quote:Original post by kohdar i am not really fussed about the template issues at the moment. just trying for a solution for a single type. Well, if both parameters are of the same type, how about simply: template <typename T> const T& min(const T& a, const T& b) { return (a < b) ? a : b; } template <typename T> T& min(T& a, T& b) { return (a < b) ? a : b; } Works for me on your test cases, with the desired amount of constructors. Unfortunately it also accepts const X& a = min(X(), X()); which you wouldn't really want. I guess some programmer care is required.
  13. Quote:Original post by Zahlman To be honest, I was always disappointed that Boost's solution wasn't along these lines (it's just a huge set of typedefs for every common compiler with ifdef logic - bletcherous). And what guarantee is there that char, short, int, long or long long will be exactly 8, 16, 32 or 64 bits? If anything, this is a nice last resort I'd say, if you don't have stdint.h, or can't determine the compiler.
  14. Quote:Original post by Defend I want to stop using the array and start using a vector. Here's what doesn't work: Why? In this case I'd say stick with the array. The static const array is simply placed in the read-only section of the executable. The alternative is dynamic memory allocation with the vector. And actually, you do it in a rather stupid manner. If you *really* want a vector, consider the following instead: vector <TEXTDVERTEX> verts; verts.push_back(TEXTDVERTEX(-0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f)); verts.push_back(TEXTDVERTEX(511.5f, -0.5f, 0.0f, 1.0f, 1.0f, 0.0f)); verts.push_back(TEXTDVERTEX(-0.5f, 511.5f, 0.0f, 1.0f, 0.0f, 1.0f)); verts.push_back(TEXTDVERTEX(511.5f, -0.5f, 0.0f, 1.0f, 1.0f, 0.0f)); verts.push_back(TEXTDVERTEX(511.5f, 511.5f, 0.0f, 1.0f, 1.0f, 1.0f)); verts.push_back(TEXTDVERTEX(-0.5f, 511.5f, 0.0f, 1.0f, 0.0f, 1.0f)); But for anything which is a fixed size, just use an array, IMO.
  15. C++ Templates Question

    For the second question, try: template<typename TT> A<T> operator*(A<TT>& rhs) { return A<T>(this->data * rhs.data); } Also, some style/performance points. Constructors should use initialization lists, and pass stuff that you don't modify as const reference. Both in the constructors (new_data) and operators (rhs).
  • Advertisement