WhiteChocolateMocha

Members
  • Content count

    9
  • Joined

  • Last visited

Community Reputation

376 Neutral

About WhiteChocolateMocha

  • Rank
    Newbie
  1. I haven't seen this posted anywhere on the site, so, Valve held a presentation a few months ago on porting their Source engine to Linux. It goes into detail on how to use modern OpenGL and getting the best performance out of it. It's an hour long video - a great wealth of info.   [media]http://www.youtube.com/watch?v=btNVfUygvio[/media]
  2. I have a weird phenomena where everything is rendered in the lower left corner of the window. Calling glViewport(0, 0, 1024, 768) doesn't help. Neither does calling glfwSetWindowPos or glfwSetWindowSize. Manually repositioning the window helps, but I shouldn't have to do this. I don't have anything in app that ties window repositioning to OpenGL. Is anyone familiar with this problem and know of a solution?   I made a video demonstrating the problem http://www.youtube.com/watch?v=kdwHvqSv42w&feature=youtu.be
  3. OpenGL OpenGL SuperBible, 5th vs 6th edition

    I say continue with the fifth edition. I have both, and am constantly going back to the early edition because some things are just better explained, like UBOs and PBOs (the latter is hardly mentioned at the end of the book in the 6th ed). Explanations in the newest edition are pretty terse. Also, the reference is cut out in the 6th ed; I guess it was to save some trees. I hardly ever used the reference, but it was a nice addition. Stick with the 5th version, and when you're ready to move onto atomic counters and compute shaders, the 6th version will be ready for you. Also have a look at g-trunc OpenGL reviews, if you haven't already. It'll put things into perspective of where OpenGL was back in the day, and where it is heading - especially when it come to the bind to edit model. ARB_bindless_texture anyone?
  4. Trouble transforming vertices in simple shader.

    OpenGL by default looks down the -z axis. Setting your triangle z coords to -1 should help GLfloat pos[] = { -0.5, -0.5, -1.0, 0.5, -0.5, -1.0, 0.0, 0.5, -1.0 };
  5. You can use Apple's first party tools. If you're using Xcode, then in the menu bar go to Xcode-> Open Developer Tools -> More Developer Tools -> then download the xcode graphics tools for your OS. Open the .dmg and click OpenGL Profiler. Copy the executable to the list box, then in the menu select Views->Breakpoints then check "Break on GL Error". Back in the main view, highlight the app so that "launch" is no longer grayed out, and hit that. This is how I debug my apps, and it's pretty good. 
  6. Understanding Composition

    Sorry, I was still typing my message. So composition is just combination of objects? It doesn't matter if they can be changed at run time or not. That's what the strategy pattern is for.
  7. Understanding Composition

    Thank you, jpetrie. You first paragraph definitely puts things into perspective. I definitely looking for a way to use my shiny new toy. I wrote many GL classes before. One with regular member functions and all state encapsulated. I wasn't happy with that solution. It was too immutable. I also tried inheritance. I wasn't too happy with that. There was this nagging voice saying "Don't use inheritance. Use composition." I got that from you gamedevers. But I think I got my definition of composition wrong. But are composition and the strategy pattern really different? One allows you to interchange state. The other allows you to interchange behavior. Are there any other differences besides that? If there is, then I don't have any understanding of this.
  8. Understanding Composition

    Hello, I bought the book Head First - Design Patterns. After reading about the Strategy Pattern I tried to implement it in a OpenGL Window class. namespace bj{ class GL{ private: HWND windowHandle; HDC deviceContext; HGLRC renderContext; int exitCode; /* Sets the windows class to use with the window. Returns a string containing the name of the window class*/ std::tr1::function<std::wstring(GL &)> register_class; /* Function that adjusts the size of the window and creates the window. This algorithm must set the GL's windowHandle and deviceContexts states.*/ std::tr1::function<void(GL &, const std::wstring &, int &, int&)> create_window; /* This function describes the pixel format of the renderer and sets up a rendering context. The GL's rendering context state must be set. */ std::tr1::function<void(GL &)> setup_gl; /* This function is called when the window is resized. It should reset the viewport and projection matrix. */ std::tr1::function<void(double, double)> resize; /* Do any initialization here. */ std::tr1::function<void(GL &)> initialize; // Main run loop. This functor must be set std::tr1::function<int(GL &)> run_loop; public: // Get DC HDC get_dc(){return (deviceContext);} // Set DC void set_dc(HDC dc){deviceContext = dc;} // Get RC HGLRC get_rc(){return (renderContext);} // Set RC void set_rc(HGLRC rc){renderContext = rc;} // Get Window handle HWND get_window(){return (windowHandle);} // Set Window handle void set_window(HWND window){windowHandle = window;} // Reset the register_class functor void reset_register_class( std::tr1::function<std::wstring(GL &)> register_class){ this->register_class = register_class; } // Reset the create_window functor void reset_create_window(std::tr1::function<void(GL &, const std::wstring &, int &, int&)> create_window){ this->create_window = create_window; } // Reset the setup_gl functor void reset_setup_gl(std::tr1::function<void(GL &)> setup_gl){ this->setup_gl = setup_gl; } // Reset the resize functor void reset_resize(std::tr1::function<void(double, double)> resize){ this->resize = resize; } // Reset the initialize functor void reset_initialize(std::tr1::function<void(GL &)> initialize){ this->initialize = initialize; } // Reset the run loop void reset_run_loop(std::tr1::function<int(GL &)> run_loop){ this->run_loop = run_loop; } // Returns main loop exit code int get_exit_code()const{return (exitCode);} // Constructors GL(); explicit GL(std::tr1::function<int(GL &)> run_loop); // Destructor ~GL(); // Executes everything int run(); }; // Standard function object for registering a window class class DefRegisterClass{ public: std::wstring operator()(GL &gl); DefRegisterClass(); DefRegisterClass(WNDPROC win_proc_); private: WNDPROC win_proc; }; class DefCreateWindow{ public: void operator()(GL &gl, const std::wstring &className, int& width, int &height); }; class DefSetupGL{ public: void operator()(GL &gl); }; class DefResize{ public: void operator()(double width, double height); }; class DefInitialize{ public: void operator()(GL &gl); }; // Standard class that contains a static function for handing // windows messages. class DefWinProc{ public: static LRESULT CALLBACK WinProc(HWND, UINT, WPARAM, LPARAM); }; // Converts win32 error messages to strings std::string format_message_win32(DWORD errorID); } // Namespace bj #endif GL_TEMPLATE_HPP I was wondering if this is the correct way to go about it using the strategy pattern. If anyone could point out anything I did wrong, it would be greatly appreciated. Also just to clear it up, the strategy pattern IS composition?
  9. Getting to know C++ properly

    Learning the language and learning coding standards are two different things. Bjarne Stroustrop has written then definitive guide on C++ with his The C++ Programming Language book. The problem is that it's very hard reading, and not something you would learn the language from. He's written another book which looks aimed at college students. That should be helpful. I don't remember the name of the book, but it's wouldn't be hard to find. Just search on amazon.com for his books. He's only written a handful. For coding standards, Scott Meyers Effective series are a must, pretty much. Effective C++ and Effective STL are great book on what/when/how and why to use something. These books show the dos and don'ts of the language. His other book More Effective C++ is pretty helpful too. It explains some low level details of how vtables are implemented and the overhead you get of using dynamic objects and stuff, but the book seems really more about learning neat tricks with the language - but again, this might aid you in your directx programming.