Elevate Engine 1
Loading...
Searching...
No Matches
Elevate::OpenGLContext Class Reference

#include <OpenGLContext.h>

Inheritance diagram for Elevate::OpenGLContext:
Elevate::GraphicsContext

Public Member Functions

 OpenGLContext (GLFWwindow *windowHandle)
 
virtual void Init () override
 
virtual void SwapBuffers () override
 
- Public Member Functions inherited from Elevate::GraphicsContext
 GraphicsContext ()
 
 ~GraphicsContext ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Elevate::GraphicsContext
static GraphicsContextGet ()
 
static bool Valid ()
 
static bool CanUseContext ()
 

Detailed Description

Definition at line 9 of file OpenGLContext.h.

Constructor & Destructor Documentation

◆ OpenGLContext()

Elevate::OpenGLContext::OpenGLContext ( GLFWwindow *  windowHandle)

Definition at line 10 of file OpenGLContext.cpp.

11 : m_WindowHandle(windowHandle)
12{
13 EE_CORE_ASSERT(windowHandle, "Window handle is null");
14}

Member Function Documentation

◆ Init()

void Elevate::OpenGLContext::Init ( )
overridevirtual

Reimplemented from Elevate::GraphicsContext.

Definition at line 16 of file OpenGLContext.cpp.

17{
18 glfwMakeContextCurrent(m_WindowHandle);
19
20#ifndef EE_PLATFORM_WEB
21 int status = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
22 EE_CORE_ASSERT(status, "Failed to initialize Glad.");
23
24 int profile = 0;
25 glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profile);
26#endif
27
28 glCullFace(GL_BACK);
29 glFrontFace(GL_CCW);
30
31 glEnable(GL_BLEND);
32 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
33
34 const char* version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
35 const char* vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
36 const char* renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
37
38 EE_CORE_TRACE("OpenGL version : {}", version ? version : "Unknown");
39 EE_CORE_INFO("OpenGL Renderer Initialized: {}, {}",
40 vendor ? vendor : "Unknown",
41 renderer ? renderer : "Unknown");
42}

◆ SwapBuffers()

void Elevate::OpenGLContext::SwapBuffers ( )
overridevirtual

Implements Elevate::GraphicsContext.

Definition at line 44 of file OpenGLContext.cpp.

45{
46 glfwSwapBuffers(m_WindowHandle);
47}

The documentation for this class was generated from the following files: