Jump to content

  • Log In with Google      Sign In   
  • Create Account


methinks

Member Since 21 Mar 2004
Offline Last Active May 12 2013 10:54 PM
-----

Topics I've Started

Alternatives to singletons for data manager?

03 May 2013 - 01:07 PM

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.

 

Attached File  layout1.png   20.1KB   31 downloads

 

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:

 

Attached File  layout2.png   25.37KB   32 downloads

 

Oh yeah, I'm doing this in C++, but the concepts should apply to most languages


write texture to stereo buffer

14 April 2012 - 10:59 AM

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

MVC pattern question

22 September 2010 - 11:13 AM

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

problems with xCode... Directory not found

27 April 2010 - 03:28 PM

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

problems compiling with static variables

17 December 2009 - 01:44 PM

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

PARTNERS