![]() ![]() This is all due to Java, LWJGL, and a very interesting game concept. Now, I've sought the power of OpenGL and LWJGL because of the platform independence and the obvious success of things such as Minecraft being used in a Web, Linux, Mac, and Windows environment. The bulk of my experience lays with Java due to the exposure during my time in high school and college (of which I am currently a senior in, if any of you are wondering!) but I have used Python, C, C++, C#, and even a little Ruby and PHP for site needs. That being said, I've been drawn to 2 or 3 APIs/Engines thus far. I haven't had a lot of time to devote to the creation of systems that could possibly already exist, however, now I do. I provided the other methods' source code examples to give you an idea as to generally how most games do 3D world scene and GUI drawing order.I've been looking around the net for months now in an attempt to find the most appropriate tool for my needs. Overall you're most likely just interested in what the ready2D() method is doing. So that when we draw a line from (0,0) through (0,9) then the line will actually draw from the top-left and straight down ten pixels total in length and one pixel width. And glTranslatef() is used to correct for per-pixel accurate positioning. Such as top-left is (0,0) in (X,Y) format while bottom-right is (ViewportWidth-1, ViewportHeight-1). What is special about the ready2D() method is that gluOrtho2D() function is called with arguments that tell it when we draw the GUI primitives we draw them in the screen coordinates specified to match Windows, Mac, and other desktop screen coordinate systems. m_Setup.width and m_Setup.height are just the view port screen dimensions. read圓D() method gets the 3D world projection ready for world scene drawing and ready2D() method gets the 2D ortho scene ready for GUI drawing. ![]() So, what I am doing is I draw my 3D world scene first and then I draw my GUI last that way the GUI is always on top of the world scene. SDL_GL_SwapBuffers() // make drawn frame visible GluOrtho2D(0.0f, m_Setup.width, m_Setup.height, 0.0f) Īnd then in the main thread loop I would basically just call the methods in the following order: while(m_drawFrame) GlViewport(0, 0, m_Setup.width, m_Setup.height) Render2D() for the actual 2D GUI drawing. ![]() render3D() for the actual 3D world scene drawing.ready2D() for preparing OpenGL to render the 2D GUI. ![]() read圓D() for preparing OpenGL to render the 3D world scene.I used four primary methods within my OpenGL renderer class (OGLRender) of which are: This is from an old OpenGL-based game engine I was trying to write about seven years ago written in C++ so bare with me as I try to explain how I handled 3D world and 2D GUI rendering operations within it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |