整合GLEWCore
This commit is contained in:
parent
9c0c1edc62
commit
d5450325ba
@ -1 +0,0 @@
|
||||
git clone https://github.com/nigels-com/glew.git glew
|
1
3rdpty/dl_glewcore.sh
Executable file
1
3rdpty/dl_glewcore.sh
Executable file
@ -0,0 +1 @@
|
||||
git clone https://github.com/hyzboy/GLEWCore.git GLEWCore
|
@ -15,14 +15,17 @@ set_compiler_param()
|
||||
set_output_directory()
|
||||
|
||||
include_directories(3rdpty/MathGeoLib/src)
|
||||
include_directories(3rdpty/GLEWCore/inc)
|
||||
include_directories(inc)
|
||||
|
||||
add_subdirectory(3rdpty/MathGeoLib)
|
||||
add_subdirectory(3rdpty/GLEWCore)
|
||||
add_subdirectory(src)
|
||||
|
||||
SET(ULRE ULRE.RenderDevice
|
||||
ULRE.RenderDriver
|
||||
MathGeoLib
|
||||
GLEWCore
|
||||
glfw
|
||||
GL)
|
||||
|
||||
|
@ -1,17 +1,24 @@
|
||||
#include<hgl/render/RenderDevice.h>
|
||||
#include<hgl/render/RenderWindow.h>
|
||||
#include<iostream>
|
||||
#include<GLFW/glfw3.h>
|
||||
#include<GL/glext.h>
|
||||
#include<GLEWCore/glew.h>
|
||||
|
||||
using namespace hgl;
|
||||
|
||||
constexpr GLfloat clear_color[4]=
|
||||
{
|
||||
77.f/255.f,
|
||||
78.f/255.f,
|
||||
83.f/255.f,
|
||||
1.f
|
||||
};
|
||||
|
||||
constexpr GLfloat clear_depth=1.0f;
|
||||
|
||||
void draw()
|
||||
{
|
||||
glClearColor(0,0,0,1); //设置清屏颜色
|
||||
glClear(GL_COLOR_BUFFER_BIT); //清屏
|
||||
glClearBufferfv(GL_COLOR,0,clear_color);
|
||||
glClearBufferfv(GL_DEPTH,0,&clear_depth);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
@ -32,7 +39,7 @@ int main(void)
|
||||
|
||||
WindowSetup ws;
|
||||
|
||||
ws.Name=U8_TEXT("Direct OpenGL Render");
|
||||
ws.Name=U8_TEXT("Direct use \"OpenGL Core API\" Render");
|
||||
|
||||
RenderSetup rs;
|
||||
|
||||
|
@ -2,8 +2,7 @@
|
||||
#include<hgl/render/RenderWindow.h>
|
||||
#include<iostream>
|
||||
#include<string.h>
|
||||
#include<GLFW/glfw3.h>
|
||||
#include<GL/glcorearb.h>
|
||||
#include<GLEWCore/glew.h>
|
||||
|
||||
using namespace hgl;
|
||||
|
||||
@ -19,8 +18,6 @@ void output_ogl_info()
|
||||
std::cout<<"Renderer: "<<glGetString(GL_RENDERER)<<std::endl;
|
||||
std::cout<<"Version: "<<glGetString(GL_VERSION)<<std::endl;
|
||||
|
||||
PFNGLGETSTRINGIPROC glGetStringi = (PFNGLGETSTRINGIPROC)glfwGetProcAddress("glGetStringi");
|
||||
|
||||
if(!glGetStringi)
|
||||
return;
|
||||
|
||||
@ -77,5 +74,3 @@ int main(int argc,char **argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include<hgl/render/RenderDevice.h>
|
||||
#include<GLEWCore/glew.h>
|
||||
#include<GLFW/glfw3.h>
|
||||
#include<iostream>
|
||||
|
||||
@ -8,8 +9,21 @@ namespace hgl
|
||||
|
||||
namespace
|
||||
{
|
||||
static bool init_glew=false;
|
||||
static RenderDevice *render_device_glfw=nullptr;
|
||||
|
||||
void InitGLEWCore()
|
||||
{
|
||||
if(!init_glew)
|
||||
init_glew=glewInit();
|
||||
}
|
||||
|
||||
void CloseGLEWCore()
|
||||
{
|
||||
glewTerminate();
|
||||
init_glew=false;
|
||||
}
|
||||
|
||||
void glfw_error_callback(int err,const char *desc)
|
||||
{
|
||||
std::cerr<<"glfw return error["<<err<<"] <<"<<desc<<std::endl;
|
||||
@ -131,6 +145,7 @@ namespace hgl
|
||||
|
||||
~RenderDeviceGLFW()
|
||||
{
|
||||
CloseGLEWCore();
|
||||
glfwTerminate();
|
||||
render_device_glfw=nullptr;
|
||||
}
|
||||
@ -178,6 +193,9 @@ namespace hgl
|
||||
|
||||
if(!win)return(nullptr);
|
||||
|
||||
glfwMakeContextCurrent(win);
|
||||
InitGLEWCore();
|
||||
|
||||
return(CreateRenderWindowGLFW(win,false));
|
||||
}
|
||||
|
||||
@ -198,6 +216,9 @@ namespace hgl
|
||||
|
||||
if(!win)return(nullptr);
|
||||
|
||||
glfwMakeContextCurrent(win);
|
||||
InitGLEWCore();
|
||||
|
||||
return(CreateRenderWindowGLFW(win,true));
|
||||
}
|
||||
};//class RenderDevice
|
||||
|
@ -1,4 +1,2 @@
|
||||
add_library(ULRE.RenderDriver STATIC GLCore/glew.c
|
||||
GLCore/OpenGLCoreExtensions.c
|
||||
GLCore/RenderDriverGLCore.cpp)
|
||||
add_library(ULRE.RenderDriver STATIC GLCore/RenderDriverGLCore.cpp)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user