• Content count

  • Joined

  • Last visited

Community Reputation

222 Neutral

About methinks

  • Rank

Personal Information

  • Interests
  1. I'm trying to learn how to write plugins (OSX Yosemite). Everything compiles and runs properly, the shared object is loaded, but function in the shared object doesn't execute.   All the files remain in the same directory.   The host application, compiled as follows: g++ -ldl -o Host Host.cpp // Host.cpp   #include <iostream> #include <dlfcn.h> using namespace std; int main(int argc, char* argv[]) {     void * plugin = dlopen("Plugin.mod", RTLD_NOW);     if(plugin == nullptr)     {         cout << "Error opening file" << endl;     }     else     {         cout << "File open, attempting to access function" << endl;         dlerror();         dlsym(plugin, "run"); // This is where the line "Plugin Running" should be printed to the console         char * errMsg = dlerror();         if(errMsg)         {             cout << "Unable to access function" << endl;         }         else         {             cout << "Success: " << endl;         }         dlclose(plugin);     } } The plugin that gets called g++ -fPIC -c Plugin.cpp g++ -shared -o Plugin.mod Plugin.o // Plugin.cpp #include <iostream> using namespace std; extern "C" void run() {     cout << "Plugin running" << endl; } and the output: File open, attempting to access function Success:   Is this a problem with the code, or the compilation?
  2. Thanks for the feedback. I'll look into instanceof, it looks like it will do what I need for the type, though I'll still face the same problem for other pieces of data (Such as UUID).   To be honest, I don't know quite yet, the id will probably be used as keys in a HashMap, but I haven't gotten that far yet. Partly I'm just trying to understand the language itself.   Tried this, but I got the error "Duplicate Function"   For now I'll go with this; not as clean as I'd like, but functional class ItemA extends Item {   public static final String id = "ITEM_A";      @Override   public String getId()   {     return id;   } } then call or i.getId()
  3. I'm coming from C++, trying to learn Java. The issue is that Java doesn't allow overriding of static functions.   In this case, I would like each class that inherits from a parent (let's call it the Item class) to have an identifier that get by calling getId().   class Item {   abstract String getId(); } class ItemA extends Item {   String getId()   {     return "ITEM_A";   } } The thing is that I want to be able to call getId without having to instantiate the class, so that I can do something like this:   void foo(Item i) {   if(i.getId() == ItemA.getId())   {     //Do Something   } } Java doesn't allow abstract static functions, so I'm left with defining non-abstract static functions. As a result, the above function doesn't work, because i.getId() returns the Parent object's id, not that of the child object.   Are there any ways around this, or what would be a better way of dealing with it?  
  4. It doesn't look like a namespace issue, because they are showing the same namespace (a::A::A) Could it be that the project is trying to compile the same class multiple times? (Do you have an include guard in the header?)
  5. Ok, so a more generic version of the question: what is the best way to share the data between different classes that are completely un-related?
  6. I want to add a central data manager to my project, so that different classes can share data. It will also act as a map to avoid doubling up on resources.   [attachment=15516:layout1.png]   I figure that there are 3 ways I can do this: create the manager as a global (EVIL) pass the manager to each class as it is created (UGLY) create the manager as a singleton Every post I see says to avoid singletons, but is this a situation that breaks the rule, or is there a better solution?   Also, the graphic data above is just one type of data; realistically there will be many data types. To avoid having a whole mess of singletons, I would create a central data manager that has a factory class for each type:   [attachment=15517:layout2.png]   Oh yeah, I'm doing this in C++, but the concepts should apply to most languages
  7. Is a mesh a 3d model?

    The mesh is the data describing the points that make up the object (This includes faces and edges). This is just one small part of the model.   "Model" is a generic term. It means any data related to drawing a 3d item onto the screen. Exactly what data this includes depends on the program or file format. In some case it might just be the mesh, although usually it also includes some of the following: Material - the colours, shading models, and other things that determine how to apply lights and rendering Textures - the images that are mapped onto the mesh UV - co-ordinates that determine how textures are applied to the mesh vertex groups - used to break the model into smaller chunks for special purposes bones / armatures - used to link parts of the mesh to specific parts of animations animations - how the mesh moves ... the list goes on, depending on what you're trying to do with the mesh.
  8. Making Blender files take up less space?

    The difference is what actually gets saved. The 3ds file only saves the model data itself (geometry, materials, etc) while the blender file contains structures explaining the data as well (the so-called DNA structure) that guarantees both forward and backward compatibility. Add to this the workspace setup (tool settings, layouts, preferences, etc), the blender file actually contains far more data. (To be very specific, the blender file is a direct dump of the internal data structure, while the 3ds is an optimized format to store only very specific data)
  9. I know that in directx, the 3d stereo works by shifting the camera and rendering two different images. I was wondering if there is any way to write directly to the buffer, to display different textures to each eye. This would be useful for having 3d background images, or in my case, writing a 3d image viewer. I know this can be done in opengl by accessing the quad buffer, but I haven't been able to find any documentation for directx. If it helps any, I'm working with nvidia cards. Thanks
  10. MVC pattern question

    Thanks for the reply. Just a couple of questions/comments. How is your example different from the second example I gave, where the model does the processing. Quote:Original post by Antheus I don't see all that much use between following such designs too strictly in non-CRUD applications. Each of such frameworks ends up with some fatal flaw which requires horrible hacks to work around. Thanks for the input. Right now, I'm just trying to understand the design, to see if it'll do what I need. Quote:Original post by Antheus Paint application works on Image. Just about every OS provides all the required functionality out of box, from drawing, editing to input handling. There is not much need for abstractions. Same applies to many other problems. MVC makes only sense if building some well-tiered framework where certain functionality may deliberately not be available. The paint application was just an example, but even so, I'd like to keep some separation, to make it easier to port between platforms.
  11. I'm trying to understand the MVC pattern, and I'm having difficulty figuring out where data processing takes place. Let's say I was building a paint program using MVC, which would be the better way to go? the user draws a line the line is sent to the controller the controller processes the line, turning it into an image the line image is sent to the model, which adds it to the existing image data the controller tells the view to update the view gets and displays the updated image data or the user draws a line the line is sent to the controller the controller sends the line data to the model the model processes the line, and adds it to the existing image data the controller tells the view to update the view gets and displays the updated image data Thanks
  12. I'm getting the following warning when I compile my program: ld: warning: directory '/Users/alex/Library/Frameworks' following -F not found Does anybody know what causes this error, and ideally how to fix it? I'm pretty sure that it started after I updated xCode via the automatic update (xCode 3.2.2). Normally I wouldn't worry about it too much, but I'm having a problem rendering in opengl (via SDL), and I want to make sure that it's not because of some linking error. Thank you
  13. not exactly a clean solution, but it seems to work... thanks!
  14. This is probably just some stupid mistake, but I can't find it... I'm trying to use a static variable in a class, but it keeps giving me a link error. main program #include <iostream> #include "foo.h" int main (int argc, char* argv[]) { foo a; a.set(10); std::cout<<a.get()<<std::endl; return 0; } foo.h #ifndef FOO_H #define FOO_H #include <iostream> #include <string> class foo { public: void set(int); int get(); private: static int value; }; #endif //FOO_H foo.cpp #include "foo.h" void foo::set(int in) { value = in; } int foo::get() { return value; } The output: "foo::value", referenced from: foo::set(int) in foo.o foo::get() in foo.o ld: symbol(s) not found collect2: ld returned 1 exit status Using gcc4.2.1 on osx Thanks
  15. I ran into a small problem after I upgraded to xCode 3.1 Whenever I create a new project, it automatically appends the path where I want to put it with the project's name. For example, if I project path is: /myProject/src xCode will create it in /myProject/src/myProject In the last version of xCode, I could manually change it before the project was actually created, but now it doesn't give me that chance anymore. Does anybody know if I can change that behavior, or at least how to re-set the path? Thanks