Browse Source

gcc5.4/linux shadow/cast fixes

master
Odilitime 5 years ago
parent
commit
192863ffce
  1. 3
      src/Murmur3.cpp
  2. 1
      src/interfaces/components/MultiComponent.cpp
  3. 69
      src/interfaces/graphical/renderers/glfw/opengl.cpp
  4. 1
      src/interfaces/graphical/renderers/glfw/opengl.h
  5. 3
      src/main.cpp

3
src/Murmur3.cpp

@ -1,5 +1,3 @@ @@ -1,5 +1,3 @@
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#pragma GCC diagnostic push
//-----------------------------------------------------------------------------
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
@ -337,4 +335,3 @@ void MurmurHash3_x64_128 ( const void * key, const int len, @@ -337,4 +335,3 @@ void MurmurHash3_x64_128 ( const void * key, const int len,
}
//-----------------------------------------------------------------------------
#pragma GCC diagnostic pop

1
src/interfaces/components/MultiComponent.cpp

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
#include "../graphical/renderers/glfw/Shader.h"
#include "../../browser.h"
#include <ctime>
extern std::unique_ptr<Browser> browser;

69
src/interfaces/graphical/renderers/glfw/opengl.cpp

@ -18,9 +18,9 @@ inline void checkGLState(std::string whereWhat) { @@ -18,9 +18,9 @@ inline void checkGLState(std::string whereWhat) {
// maybe change to return std::pair<GLuint, GLuint>
// with the renderer and version?
bool initGL() {
const GLubyte *renderer = glGetString(GL_RENDERER);
const GLubyte *brenderer = glGetString(GL_RENDERER);
const GLubyte *version = glGetString(GL_VERSION);
std::cout << "Renderer: " << renderer << std::endl;
std::cout << "Renderer: " << brenderer << std::endl;
std::cout << "Version: " << version << std::endl;
checkGLState("opengl::initGL - start");
@ -80,11 +80,11 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns @@ -80,11 +80,11 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
int windowWidth = position->w;
int windowHeight = position->h;
OpenGLWindowHandle *win = new OpenGLWindowHandle();
win->width = position->w;
win->height = position->h;
OpenGLWindowHandle *twin = new OpenGLWindowHandle();
twin->width = position->w;
twin->height = position->h;
GLFWwindow *window = glfwCreateWindow(windowWidth, windowHeight, title.c_str(), nullptr, nullptr);
win->window = window;
twin->window = window;
// replace first parameter of all these callbacks with our window object instead of a GLFWwindow
glfwSetWindowUserPointer(window, this);
@ -104,9 +104,9 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns @@ -104,9 +104,9 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
initGL();
// load the shaders
win->textureShader = win->shaderLoader.getShader(VertexShader("TextureShader.vert"),
twin->textureShader = twin->shaderLoader.getShader(VertexShader("TextureShader.vert"),
FragmentShader("TextureShader.frag"));
win->fontShader = win->shaderLoader.getShader(VertexShader("FontShader.vert"),
twin->fontShader = twin->shaderLoader.getShader(VertexShader("FontShader.vert"),
FragmentShader("FontShader.frag"));
@ -115,24 +115,24 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns @@ -115,24 +115,24 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
glViewport(0, 0, static_cast<GLsizei>(position->w), static_cast<GLsizei>(position->h)); checkGLState("OpenGL::createWindow - glViewport");
// replace first parameter of all these callbacks with our window object instead of a GLFWwindow
glfwSetWindowUserPointer(win->window, win);
glfwSetWindowUserPointer(twin->window, twin);
// set up event callbacks
// window events
glfwSetFramebufferSizeCallback(window, [](GLFWwindow *win, int width, int height) {
glfwSetFramebufferSizeCallback(window, [](GLFWwindow *glfwwin, int width, int height) {
glViewport(0, 0, width, height);
});
glfwSetWindowSizeCallback(window, [](GLFWwindow *win, int width, int height) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(win));
glfwSetWindowSizeCallback(window, [](GLFWwindow *glfwwin, int width, int height) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(glfwwin));
if (thiz->onResize) {
thiz->onResize(width, height);
}
});
// mouse events
glfwSetCursorPosCallback(window, [](GLFWwindow *win, double xPos, double yPos) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(win));
glfwSetCursorPosCallback(window, [](GLFWwindow *glfwwin, double xPos, double yPos) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(glfwwin));
//std::cout << "Window::Window:onMousemove - at " << static_cast<int>(xPos) << "," << static_cast<int>(yPos) << std::endl;
thiz->cursorX = xPos;
thiz->cursorY = yPos;
@ -154,15 +154,15 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns @@ -154,15 +154,15 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
thiz->onMouseMove(xPos, yPos);
}
});
glfwSetScrollCallback(window, [](GLFWwindow *win, double xOffset, double yOffset) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(win));
glfwSetScrollCallback(window, [](GLFWwindow *glfwwin, double xOffset, double yOffset) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(glfwwin));
//std::cout << "glfwSetScrollCallback " << yOffset << " int" << (int)(yOffset * 10) << std::endl;
if (thiz->onWheel) {
thiz->onWheel(xOffset * 10, yOffset * 10);
}
});
glfwSetMouseButtonCallback(window, [](GLFWwindow *win, int button, int action, int mods) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(win));
glfwSetMouseButtonCallback(window, [](GLFWwindow *glfwwin, int button, int action, int mods) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(glfwwin));
if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) {
//std::cout << "left press" << std::endl;
if (thiz->onMouseUp) {
@ -180,8 +180,8 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns @@ -180,8 +180,8 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
// keyboard events
// works with utf-32 and os keyboard layout but we'll lkeep the low level for now
glfwSetCharCallback(window, [](GLFWwindow* win, unsigned int codepoint) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(win));
glfwSetCharCallback(window, [](GLFWwindow* glfwwin, unsigned int codepoint) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(glfwwin));
//std::cout << "OpenGL::glfwSetCharCallback - codepoint: " << codepoint << std::endl;
// should be used for inputComponent
@ -190,8 +190,8 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns @@ -190,8 +190,8 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
}
});
glfwSetKeyCallback(window, [](GLFWwindow *win, int key, int scancode, int action, int mods) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(win));
glfwSetKeyCallback(window, [](GLFWwindow *glfwwin, int key, int scancode, int action, int mods) {
OpenGLWindowHandle *thiz = reinterpret_cast<OpenGLWindowHandle*>(glfwGetWindowUserPointer(glfwwin));
if (action == GLFW_RELEASE) {
if (thiz->onKeyUp) {
thiz->onKeyUp(key, scancode, mods);
@ -235,12 +235,12 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns @@ -235,12 +235,12 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
// set up box shader
GLuint elementBufferObject = 0;
glGenVertexArrays(1, &win->vertexArrayObjectBox); checkGLState("OpenGL::createWindow - genVAOBox");
glBindVertexArray(win->vertexArrayObjectBox); checkGLState("OpenGL::createWindow - bindVAOBox");
glGenVertexArrays(1, &twin->vertexArrayObjectBox); checkGLState("OpenGL::createWindow - genVAOBox");
glBindVertexArray(twin->vertexArrayObjectBox); checkGLState("OpenGL::createWindow - bindVAOBox");
glGenBuffers(1, &elementBufferObject); checkGLState("OpenGL::createWindow - genEBO");
// we may need the VBO here...
glGenBuffers(1, &win->vertexBufferObjectBox); checkGLState("OpenGL::createWindow - genVBOBox");
glGenBuffers(1, &twin->vertexBufferObjectBox); checkGLState("OpenGL::createWindow - genVBOBox");
float vertices[20] = {
0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 0.0f, 1.0f, 1.0f,
@ -249,7 +249,7 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns @@ -249,7 +249,7 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
};
// select buffer
glBindBuffer(GL_ARRAY_BUFFER, win->vertexBufferObjectBox); checkGLState("OpenGL::createWindow - bindVBO");
glBindBuffer(GL_ARRAY_BUFFER, twin->vertexBufferObjectBox); checkGLState("OpenGL::createWindow - bindVBO");
// write buffer
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); checkGLState("OpenGL::createWindow - bufVBO");
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBufferObject); checkGLState("OpenGL::createWindow - bindEBO");
@ -266,12 +266,12 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns @@ -266,12 +266,12 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
//glBindVertexArray(0);
// set up text shader
glGenVertexArrays(1, &win->vertexArrayObjectText); checkGLState("OpenGL::createWindow - genVAOText");
glBindVertexArray(win->vertexArrayObjectText); checkGLState("OpenGL::createWindow - bindVBOText");
glGenVertexArrays(1, &twin->vertexArrayObjectText); checkGLState("OpenGL::createWindow - genVAOText");
glBindVertexArray(twin->vertexArrayObjectText); checkGLState("OpenGL::createWindow - bindVBOText");
// vBO
glGenBuffers(1, &win->vertexBufferObjectText); checkGLState("OpenGL::createWindow - genVBOText");
glBindBuffer(GL_ARRAY_BUFFER, win->vertexBufferObjectText); checkGLState("OpenGL::createWindow - bindVBOText");
glGenBuffers(1, &twin->vertexBufferObjectText); checkGLState("OpenGL::createWindow - genVBOText");
glBindBuffer(GL_ARRAY_BUFFER, twin->vertexBufferObjectText); checkGLState("OpenGL::createWindow - bindVBOText");
std::unique_ptr<float[]> vertices2 = std::make_unique<float[]>(36); // upload garbage for now
glBufferData(GL_ARRAY_BUFFER, ((3 + 4 + 2) * 4) * sizeof(float), vertices2.get(), GL_STATIC_DRAW); checkGLState("OpenGL::createWindow - buffVBOText");
@ -290,7 +290,7 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns @@ -290,7 +290,7 @@ OpenGLWindowHandle * OpenGL::createWindow(std::string title, Rect *position, uns
glBindVertexArray(0);
return win;
return twin;
}
void OpenGLWindowHandle::clear() {
@ -311,7 +311,7 @@ OpenGLTexture* OpenGLWindowHandle::createSprite(unsigned char* texture, GLsizei @@ -311,7 +311,7 @@ OpenGLTexture* OpenGLWindowHandle::createSprite(unsigned char* texture, GLsizei
// FIXME: need to dynamically allocate for c++
//unsigned char data[16384][16384][4];
//unsigned char ***image = allocate_dynamic_bitmap(poth, potw, 4);
unsigned char *data = (unsigned char *)malloc(sizeof(unsigned char) * poth * potw * 4);
unsigned char *data = reinterpret_cast<unsigned char *>(malloc(sizeof(unsigned char) * poth * potw * 4));
//memset(data, 0, poth * potw * 4);
//memset(image, 0, poth * potw * 4);
// unflip texture
@ -397,6 +397,7 @@ void pointToViewport(float &rawX, float &rawY, size_t windowWidth, size_t window @@ -397,6 +397,7 @@ void pointToViewport(float &rawX, float &rawY, size_t windowWidth, size_t window
//std::cout << "Component::pointToViewport - BoundToPage converted to " << rawX << "," << rawY << std::endl;
}
void pointToViewportText(float &rawX, float &rawY, size_t windowWidth, size_t windowHeight);
void pointToViewportText(float &rawX, float &rawY, size_t windowWidth, size_t windowHeight) {
//std::cout << "notBoundToPage using " << screenWidth << "x" << screenHeight << std::endl;
//std::cout << "Component::pointToViewport - notBoundToPage converting from " << static_cast<int>(rawX) << "," << static_cast<int>(rawY) << std::endl;
@ -495,9 +496,9 @@ inline void setVerticesColor(std::unique_ptr<float[]> &vertices, int p, unsigned @@ -495,9 +496,9 @@ inline void setVerticesColor(std::unique_ptr<float[]> &vertices, int p, unsigned
void OpenGLWindowHandle::drawSpriteText(OpenGLTexture *texture, unsigned int hexColor, Rect *position) {
float vx0 = position->x;
float vy0 = this->height - position->y + position->h;
float vy0 = static_cast<int>(this->height) - position->y + position->h;
float vx1 = position->x + position->w;
float vy1 = this->height - position->y;
float vy1 = static_cast<int>(this->height) - position->y;
pointToViewportText(vx0, vy0, this->width, this->height);
pointToViewportText(vx1, vy1, this->width, this->height);

1
src/interfaces/graphical/renderers/glfw/opengl.h

@ -77,6 +77,7 @@ public: @@ -77,6 +77,7 @@ public:
OpenGLTexture* createSpriteFromColor(const unsigned int hexColor);
using WindowHandle::drawSpriteBox;
void drawSpriteBox(OpenGLTexture *texture, Rect *position);
using WindowHandle::drawSpriteText;
void drawSpriteText(OpenGLTexture *texture, unsigned int hexColor, Rect *position);
// property
GLFWwindow *window;

3
src/main.cpp

@ -86,6 +86,9 @@ int main(int argc, char *argv[]) { @@ -86,6 +86,9 @@ int main(int argc, char *argv[]) {
Environment::init();
CFGFileParser *parser = new CFGFileParser("res/netrunner.cfg");
BrowserConfiguration *config = new BrowserConfiguration();
if (!parser) {
std::cout << "no parser!" << std::endl;
}
if (parser->ParseText()){
parser->WriteConfig(*config);
}

Loading…
Cancel
Save