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