| 5300 | namespace olc |
| 5301 | { |
| 5302 | class Renderer_OGL10 : public olc::Renderer |
| 5303 | { |
| 5304 | private: |
| 5305 | #if defined(OLC_PLATFORM_GLUT) |
| 5306 | bool mFullScreen = false; |
| 5307 | #else |
| 5308 | glDeviceContext_t glDeviceContext = 0; |
| 5309 | glRenderContext_t glRenderContext = 0; |
| 5310 | #endif |
| 5311 | |
| 5312 | bool bSync = false; |
| 5313 | olc::DecalMode nDecalMode = olc::DecalMode(-1); // Thanks Gusgo & Bispoo |
| 5314 | olc::DecalStructure nDecalStructure = olc::DecalStructure(-1); |
| 5315 | std::array<float, 16> matProjection = { {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1} }; |
| 5316 | #if defined(OLC_PLATFORM_X11) |
| 5317 | X11::Display* olc_Display = nullptr; |
| 5318 | X11::Window* olc_Window = nullptr; |
| 5319 | X11::XVisualInfo* olc_VisualInfo = nullptr; |
| 5320 | #endif |
| 5321 | |
| 5322 | public: |
| 5323 | void PrepareDevice() override |
| 5324 | { |
| 5325 | #if defined(OLC_PLATFORM_GLUT) |
| 5326 | //glutInit has to be called with main() arguments, make fake ones |
| 5327 | int argc = 0; |
| 5328 | char* argv[1] = { (char*)"" }; |
| 5329 | glutInit(&argc, argv); |
| 5330 | glutInitWindowPosition(0, 0); |
| 5331 | glutInitWindowSize(512, 512); |
| 5332 | glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGBA); |
| 5333 | // Creates the window and the OpenGL context for it |
| 5334 | glutCreateWindow("OneLoneCoder.com - Pixel Game Engine"); |
| 5335 | glEnable(GL_TEXTURE_2D); // Turn on texturing |
| 5336 | glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); |
| 5337 | #endif |
| 5338 | } |
| 5339 | |
| 5340 | olc::rcode CreateDevice(std::vector<void*> params, bool bFullScreen, bool bVSYNC) override |
| 5341 | { |
| 5342 | #if defined(OLC_PLATFORM_WINAPI) |
| 5343 | // Create Device Context |
| 5344 | glDeviceContext = GetDC((HWND)(params[0])); |
| 5345 | PIXELFORMATDESCRIPTOR pfd = |
| 5346 | { |
| 5347 | sizeof(PIXELFORMATDESCRIPTOR), 1, |
| 5348 | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, |
| 5349 | PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 5350 | PFD_MAIN_PLANE, 0, 0, 0, 0 |
| 5351 | }; |
| 5352 | |
| 5353 | int pf = 0; |
| 5354 | if (!(pf = ChoosePixelFormat(glDeviceContext, &pfd))) return olc::FAIL; |
| 5355 | SetPixelFormat(glDeviceContext, pf, &pfd); |
| 5356 | |
| 5357 | if (!(glRenderContext = wglCreateContext(glDeviceContext))) return olc::FAIL; |
| 5358 | wglMakeCurrent(glDeviceContext, glRenderContext); |
| 5359 |
nothing calls this directly
no test coverage detected