Switched from GLEW to glbinding, vcpkg is fucking amazing, cmake works on windows again

This commit is contained in:
Adrian Hedqvist 2017-12-27 21:54:11 +01:00
parent 999ea5bd71
commit 09730c4101
12 changed files with 817 additions and 31 deletions

4
.gitignore vendored
View file

@ -5,8 +5,7 @@
*.opensdf *.opensdf
*.sdf *.sdf
*.pdb *.pdb
*.sln *.user
*.vcxproj*
[Dd]ebug [Dd]ebug
[Rr]elease [Rr]elease
@ -33,3 +32,4 @@ build
imgui.ini imgui.ini
*.sublime* *.sublime*
*.dll *.dll
gitparams.h

View file

@ -12,28 +12,31 @@ execute_process(
file(WRITE "src/gitparams.h" "#define GIT_CUR_COMMIT ${GIT_COMMIT}") file(WRITE "src/gitparams.h" "#define GIT_CUR_COMMIT ${GIT_COMMIT}")
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -g -static-libgcc -static-libstdc++") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -static-libgcc -static-libstdc++")
project(dungeon LANGUAGES CXX) set(TARGET dungeon)
project(${TARGET} LANGUAGES CXX)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED) find_package(glbinding REQUIRED)
find_package(Lua REQUIRED) find_package(Lua REQUIRED)
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
include_directories( include_directories(
${OPENGL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}
${SDL2_INCLUDE_DIR} ${SDL2_INCLUDE_DIR}
${GLEW_INCLUDE_DIRS} ${GLBINDING_INCLUDE_DIRS}
${LUA_INCLUDE_DIR} ${LUA_INCLUDE_DIR}
"libs/glm"
"libs/kaguya-1.3.2/include" "libs/kaguya-1.3.2/include"
) )
message(STATUS ${GLBINDING_LIBRARIES})
link_libraries( link_libraries(
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
${SDL2_LIBRARY} ${SDL2_LIBRARY}
${GLEW_LIBRARIES}
${LUA_LIBRARIES} ${LUA_LIBRARIES}
) )
file(GLOB SOURCES "src/*.cpp" "src/*.c" "src/*.h") file(GLOB SOURCES "src/*.cpp" "src/*.c" "src/*.h")
add_executable(dungeon ${SOURCES}) add_executable(dungeon ${SOURCES})
target_link_libraries(${TARGET} PUBLIC glbinding::glbinding)

View file

@ -6,18 +6,18 @@ A work-in-progress, cross-platform roguelike written in C++ using SDL2 and OpenG
## Compiling ## Compiling
Dependencies: `SDL2`, `Lua53`, `glm`, and `glbinding`
### Linux ### Linux
* Install SDL2, Lua53 and GLEW using your distro's package manager * Install the dependencies using your distro's package manager
* Create a directory named "build" and run `cmake .. && make` inside it * Create a directory named "build" and run `cmake .. && make` inside it
* Move either the resulting binary to the root folder of the repository or copy the assets folder into the build directory * Move either the resulting binary to the root folder of the repository or copy the assets folder into the build directory
* You can now run the binary * You can now run the binary
### Windows ### Windows
I really need to fix a hassle-free way to build this shit on windows. CMake should work just fine on windows as well, but I heavily recommend you to use [vcpkg](https://github.com/Microsoft/vcpkg) to install the libraries.
Currently, you need to import the source as a new project in visual studio and set up the dependencies yourself. (SDL2, Lua53, GLEW, OpenGL)
## Future plans ## Future plans
@ -28,7 +28,8 @@ Currently, you need to import the source as a new project in visual studio and s
* [ ] Make entities and AI completely data-driven * [ ] Make entities and AI completely data-driven
* [ ] Implement Lua for item/effects/action scripting * [ ] Implement Lua for item/effects/action scripting
* Might as well use it for basic data storage as well, since I can then skip creating my own parser or adding an additional library for json/yaml/toml/whatever. * Might as well use it for basic data storage as well, since I can then skip creating my own parser or adding an additional library for json/yaml/toml/whatever.
* [x] Initial implementation * [x] Get Lua to work
* [ ] Initial implementation
* [ ] Items * [ ] Items
* [ ] Status Effects * [ ] Status Effects
* [ ] Spells * [ ] Spells

31
dungeon.sln Normal file
View file

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dungeon", "dungeon.vcxproj", "{47B30CB8-11E4-4B86-BB50-E3603FE99F9E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{47B30CB8-11E4-4B86-BB50-E3603FE99F9E}.Debug|x64.ActiveCfg = Debug|x64
{47B30CB8-11E4-4B86-BB50-E3603FE99F9E}.Debug|x64.Build.0 = Debug|x64
{47B30CB8-11E4-4B86-BB50-E3603FE99F9E}.Debug|x86.ActiveCfg = Debug|Win32
{47B30CB8-11E4-4B86-BB50-E3603FE99F9E}.Debug|x86.Build.0 = Debug|Win32
{47B30CB8-11E4-4B86-BB50-E3603FE99F9E}.Release|x64.ActiveCfg = Release|x64
{47B30CB8-11E4-4B86-BB50-E3603FE99F9E}.Release|x64.Build.0 = Release|x64
{47B30CB8-11E4-4B86-BB50-E3603FE99F9E}.Release|x86.ActiveCfg = Release|Win32
{47B30CB8-11E4-4B86-BB50-E3603FE99F9E}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FDC70A19-9B1D-420D-8411-489CEB5FF3DE}
EndGlobalSection
EndGlobal

461
dungeon.vcxproj Normal file

File diff suppressed because one or more lines are too long

282
dungeon.vcxproj.filters Normal file
View file

@ -0,0 +1,282 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Actor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\App.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\AttackEnemyNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\BehaviourTree.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\BehaviourTreeMemSelector.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\BehaviourTreeMemSequencer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\BehaviourTreeNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\BehaviourTreeSelector.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\BehaviourTreeSequencer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Config.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Entity.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\ExploreNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\FieldOfView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\FleeNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Gamestate.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Goblin.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\HealFriendNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Hero.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\IfHealthBelow.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\IfNotSeeEnemyNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\IfSeeEnemyNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\IfSeeFriendNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Input.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Mapgen.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Pathfinder.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\PlayState.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\RangedAttackNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Renderer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\RestNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Shaman.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Tilemap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\Tileset.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\WanderNode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\World.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\imgui.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\imgui_demo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\imgui_draw.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\imgui_impl_sdl_gl3.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="E:\Programmering\C++\Dungeon\src\imgui_user.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Actor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\App.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\AttackEnemyNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\BehaviourTree.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\BehaviourTreeMemSelector.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\BehaviourTreeMemSequencer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\BehaviourTreeNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\BehaviourTreeSelector.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\BehaviourTreeSequencer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Color.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Config.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Entity.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\ExploreNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\FieldOfView.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\FleeNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Gamestate.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Goblin.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\HealFriendNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Hero.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\IfHealthBelow.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\IfNotSeeEnemyNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\IfSeeEnemyNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\IfSeeFriendNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Input.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Logger.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Mapgen.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Pathfinder.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\PlayState.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\RangedAttackNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Renderer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\RestNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Shaman.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Stats.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Tilemap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\Tileset.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\WanderNode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\World.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\gitparams.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\imconfig.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\imgui.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\imgui_impl_sdl_gl3.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\imgui_internal.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\imgui_user.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\stb_rect_pack.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\stb_textedit.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\stb_truetype.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\vec2i.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="E:\Programmering\C++\Dungeon\src\wglew.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="E:\Programmering\C++\Dungeon\CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{40E65D15-5F8D-3901-96F2-47322AD2F0D7}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{FE34F69C-6EB7-3A06-A783-3BDA351EEAFE}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View file

@ -3,7 +3,7 @@
// //
#include "App.h" #include "App.h"
#include <SDL.h> #include <SDL2/SDL.h>
#include <ctime> #include <ctime>
#include <fstream> #include <fstream>
#include <string> #include <string>

View file

@ -1,5 +1,5 @@
#include "Input.h" #include "Input.h"
#include <SDL.h> #include <SDL2/SDL.h>
Input::Input() Input::Input()
{ {

View file

@ -1,6 +1,7 @@
#include <SDL2\SDL.h> #include <SDL2\SDL.h>
#include "App.h" #include "App.h"
#undef main
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
App app{}; App app{};
int err = 1; int err = 1;

View file

@ -173,6 +173,7 @@ Gamestate *PlayState::update(double delta) {
vec2i heropos = hero->get_position(); vec2i heropos = hero->get_position();
auto acts = tilemap.get_entities(heropos.x + dir.x, heropos.y + dir.y, 0, ENTITY_ACTOR); auto acts = tilemap.get_entities(heropos.x + dir.x, heropos.y + dir.y, 0, ENTITY_ACTOR);
if(acts.empty()) { if(acts.empty()) {
action = ACTION_NONE;
SDL_LogVerbose(SDL_LOG_CATEGORY_SYSTEM, "Turn aborted: invalid player action.\n"); SDL_LogVerbose(SDL_LOG_CATEGORY_SYSTEM, "Turn aborted: invalid player action.\n");
return nullptr; // unable to move and nothing to attack == abort turn return nullptr; // unable to move and nothing to attack == abort turn
} }

View file

@ -1,8 +1,8 @@
#include "Renderer.h" #include "Renderer.h"
#define GLEW_STATIC #include <glbinding\gl\gl.h>
#define GLEW_NO_GLU #include <glbinding\Binding.h>
#include <GL/glew.h> #include <glbinding\gl\types.h>
#include <fstream> #include <fstream>
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
@ -12,6 +12,8 @@
#include <glm/matrix.hpp> #include <glm/matrix.hpp>
#include <utility> #include <utility>
using namespace gl;
const GLfloat rectVertData[]{ const GLfloat rectVertData[]{
0,0,0, 1,0,0, 0,1,0, 1,1,0 0,0,0, 1,0,0, 0,1,0, 1,1,0
}; };
@ -37,7 +39,7 @@ GLuint LoadShader(const char* path, GLenum shadertype) {
return 0; return 0;
} }
GLint result = GL_FALSE; GLboolean result = GL_FALSE;
int infologlength; int infologlength;
SDL_Log("Compiling shader: %s\n", path); SDL_Log("Compiling shader: %s\n", path);
@ -63,7 +65,7 @@ GLuint CreateShaderProgram(GLuint vertshader, GLuint fragshader) {
glAttachShader(programId, fragshader); glAttachShader(programId, fragshader);
glLinkProgram(programId); glLinkProgram(programId);
GLint result = GL_FALSE; GLboolean result = GL_FALSE;
int infologlength; int infologlength;
glGetShaderiv(programId, GL_LINK_STATUS, &result); glGetShaderiv(programId, GL_LINK_STATUS, &result);
@ -128,6 +130,9 @@ bool Renderer::Init(std::string title, int width, int height) {
return false; return false;
} }
glbinding::Binding::initialize();
/*
GLenum err = glewInit(); GLenum err = glewInit();
if (err != GLEW_OK) { if (err != GLEW_OK) {
SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Failed to initialize OpenGl: %s\n", glewGetErrorString(err)); SDL_LogCritical(SDL_LOG_CATEGORY_RENDER, "Failed to initialize OpenGl: %s\n", glewGetErrorString(err));
@ -138,7 +143,7 @@ bool Renderer::Init(std::string title, int width, int height) {
SDL_LogCritical(SDL_LOG_CATEGORY_RENDER,"OpenGl 3.2 is not supported, please try updating your drivers!\n"); SDL_LogCritical(SDL_LOG_CATEGORY_RENDER,"OpenGl 3.2 is not supported, please try updating your drivers!\n");
return false; return false;
} }
*/
glClearColor(0, 0, 0, 1); glClearColor(0, 0, 0, 1);
ImGui_ImplSdlGL3_Init(window); ImGui_ImplSdlGL3_Init(window);
@ -250,7 +255,7 @@ Texture * Renderer::LoadTexture(std::string path) {
glGenTextures(1, &textureId); glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId); glBindTexture(GL_TEXTURE_2D, textureId);
int mode = GL_RGB; GLenum mode = GL_RGB;
if (surface->format->BytesPerPixel == 4) { if (surface->format->BytesPerPixel == 4) {
mode = GL_RGBA; mode = GL_RGBA;
} }

View file

@ -12,8 +12,9 @@
// SDL,GL3W // SDL,GL3W
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <SDL2/SDL_syswm.h> #include <SDL2/SDL_syswm.h>
#define GLEW_STATIC #include <glbinding\gl\gl.h>
#include <GL/glew.h> // This example is using gl3w to access OpenGL functions (because it is small). You may use glew/glad/glLoadGen/etc. whatever already works for you. #include <glbinding\gl\types.h>
using namespace gl;
// Data // Data
static double g_Time = 0.0f; static double g_Time = 0.0f;
@ -39,19 +40,19 @@ void ImGui_ImplSdlGL3_RenderDrawLists(ImDrawData* draw_data)
draw_data->ScaleClipRects(io.DisplayFramebufferScale); draw_data->ScaleClipRects(io.DisplayFramebufferScale);
// Backup GL state // Backup GL state
GLint last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, &last_active_texture); GLenum last_active_texture; glGetIntegerv(GL_ACTIVE_TEXTURE, &last_active_texture);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program); GLint last_program; glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture); GLint last_texture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer); GLint last_array_buffer; glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
GLint last_element_array_buffer; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer); GLint last_element_array_buffer; glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer);
GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array); GLint last_vertex_array; glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
GLint last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, &last_blend_src_rgb); GLenum last_blend_src_rgb; glGetIntegerv(GL_BLEND_SRC_RGB, &last_blend_src_rgb);
GLint last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, &last_blend_dst_rgb); GLenum last_blend_dst_rgb; glGetIntegerv(GL_BLEND_DST_RGB, &last_blend_dst_rgb);
GLint last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, &last_blend_src_alpha); GLenum last_blend_src_alpha; glGetIntegerv(GL_BLEND_SRC_ALPHA, &last_blend_src_alpha);
GLint last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, &last_blend_dst_alpha); GLenum last_blend_dst_alpha; glGetIntegerv(GL_BLEND_DST_ALPHA, &last_blend_dst_alpha);
GLint last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb); GLenum last_blend_equation_rgb; glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb);
GLint last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha); GLenum last_blend_equation_alpha; glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha);
GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport); GLint last_viewport[4]; glGetIntegerv(GL_VIEWPORT, last_viewport);
GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box); GLint last_scissor_box[4]; glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
GLboolean last_enable_blend = glIsEnabled(GL_BLEND); GLboolean last_enable_blend = glIsEnabled(GL_BLEND);