Search Results

Search found 2 results on 1 pages for 'malymato'.

Page 1/1 | 1 

  • OpenGL: glGetError() returns invalid enum after call to glewInit()

    - by malymato
    I use GLEW and freeglut. For some reason, after a call to glewInit(), glGetError() returns error code 1280. Reinstalling the drivers didn't help. I tried to disable glewExperimental, it had no effect. Code worked before, but I am not aware of any changes I could possibly make. Here's my code: int main(int argc, char* argv[]) { GLenum GlewInitResult, res; InitWindow(argc, argv); res = glGetError(); // res = 0 glewExperimental = GL_TRUE; GlewInitResult = glewInit(); res = glGetError(); // res = 1280 glutMainLoop(); exit(EXIT_SUCCESS); } void InitWindow(int argc, char* argv[]) { glutInit(&argc, argv); glutInitContextVersion(4, 0); glutInitContextFlags(GLUT_FORWARD_COMPATIBLE); glutInitContextProfile(GLUT_CORE_PROFILE); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); glutInitWindowPosition(0, 0); glutInitWindowSize(CurrentWidth, CurrentHeight); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); WindowHandle = glutCreateWindow(WINDOW_TITLE); GLenum errorCheckValue = glGetError(); if (WindowHandle < 1) { fprintf(stderr, "ERROR: Could not create new rendering window.\n"); exit(EXIT_FAILURE); } glutReshapeFunc(ResizeFunction); glutDisplayFunc(RenderFunction); glutIdleFunc(IdleFunction); glutTimerFunc(0, TimerFunction, 0); glutCloseFunc(Cleanup); glutKeyboardFunc(KeyboardFunction); } Could someone tell me what I am doing wrong? Thanks.

    Read the article

  • Polymorphism problem: How to check type of derived class?

    - by malymato
    Hi, this is my first question here :) I know that I should not check for object type but instead use dynamic_cast, but that would not solve my problem. I have class called Extension and interfaces called IExtendable and IInitializable, IUpdatable, ILoadable, IDrawable (the last four are basicly the same). If Extension implements IExtendable interface, it can extend itself with different Extension objects. The problem is that I want to allow the Extension which implements IExtendable to extend only with Extension that implements the same interfaces as the original Extension. You probably don't unerstand that mess so I try to explain it with code: class IExtendable { public: IExtendable(void); void AddExtension(Extension*); void RemoveExtensionByID(unsigned int); vector<Extension*>* GetExtensionPtr(){return &extensions;}; private: vector<Extension*> extensions; }; class IUpdatable { public: IUpdatable(void); ~IUpdatable(void); virtual void Update(); }; class Extension { public: Extension(void); virtual ~Extension(void); void Enable(){enabled=true;}; void Disable(){enabled=false;}; unsigned int GetIndex(){return ID;}; private: bool enabled; unsigned int ID; static unsigned int _indexID; }; Now imagine the case that I create Extension like this: class MyExtension : public Extension, public IExtendable, public IUpdatable, public IDrawable { public: MyExtension(void); virtual ~MyExtension(void); virtual void AddExtension(Extension*); virtual void Update(); virtual void Draw(); }; And I want to allow this class to extend itself only with Extensions that implements the same interfaces (or less). For example I want it to be able to take Extension which implements IUpdatable; or both IUpdatable and IDrawable; but e.g. not Extension which implements ILoadable. I want to do this because when e.g. Update() will be called on some Extension which implements IExtendable and IUpdateable, it will be also called on these Extensions which extends this Extension. So when I'm adding some Extension to Extension which implements IExtendable and some of the IUpdatable, ILoadable... I'm forced to check if Extension that is going to be add implements these interfaces too. So In the IExtendable::AddExtension(Extension*) I would need to do something like this: void IExtendable::AddExtension(Extension* pEx) { bool ok = true; // check wheather this extension can take pEx // do this with every interface if ((*pEx is IUpdatable) && (*this is_not IUpdatable)) ok = false; if (ok) this->extensions.push_back(pEx); } But how? Any ideas what would be the best solution? I don't want to use dynamic_cast and see if it returns null... thanks

    Read the article

1