mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 09:27:00 +00:00
Fix Clang warning with offsetof() macro? Added -Wall in OpenGL 3 example.
This commit is contained in:
parent
71e20680db
commit
987188d437
@ -11,7 +11,7 @@
|
|||||||
# http://www.glfw.org
|
# http://www.glfw.org
|
||||||
#
|
#
|
||||||
|
|
||||||
CXX = g++
|
#CXX = g++
|
||||||
|
|
||||||
OBJS = main.o
|
OBJS = main.o
|
||||||
OBJS += ../../imgui.o
|
OBJS += ../../imgui.o
|
||||||
@ -22,6 +22,7 @@ UNAME_S := $(shell uname -s)
|
|||||||
ifeq ($(UNAME_S), Linux) #LINUX
|
ifeq ($(UNAME_S), Linux) #LINUX
|
||||||
ECHO_MESSAGE = "Linux"
|
ECHO_MESSAGE = "Linux"
|
||||||
CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
|
CXXFLAGS = -I../../ `pkg-config --cflags glfw3`
|
||||||
|
CXXFLAGS += -Wall
|
||||||
LIBS = `pkg-config --static --libs glfw3` -lGLEW
|
LIBS = `pkg-config --static --libs glfw3` -lGLEW
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -32,11 +33,9 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
|||||||
LIBS += -L/usr/local/Cellar/glew/1.10.0/lib -L/usr/local/lib
|
LIBS += -L/usr/local/Cellar/glew/1.10.0/lib -L/usr/local/lib
|
||||||
LIBS += -lglew -lglfw3
|
LIBS += -lglew -lglfw3
|
||||||
|
|
||||||
CXXFLAGS = -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
|
CXXFLAGS = -I../../ -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
|
||||||
CXXFLAGS += -I../../
|
CXXFLAGS += -Wall
|
||||||
|
|
||||||
# CXXFLAGS += -D__APPLE__
|
# CXXFLAGS += -D__APPLE__
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.cpp.o:
|
.cpp.o:
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#define GLEW_STATIC
|
#define GLEW_STATIC
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
#define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
|
||||||
|
|
||||||
static GLFWwindow* window;
|
static GLFWwindow* window;
|
||||||
static GLuint fontTex;
|
static GLuint fontTex;
|
||||||
@ -233,9 +234,9 @@ void InitGL()
|
|||||||
glEnableVertexAttribArray(uv_location);
|
glEnableVertexAttribArray(uv_location);
|
||||||
glEnableVertexAttribArray(colour_location);
|
glEnableVertexAttribArray(colour_location);
|
||||||
|
|
||||||
glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*) offsetof(ImDrawVert, pos));
|
glVertexAttribPointer(position_location, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, pos));
|
||||||
glVertexAttribPointer(uv_location, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*) offsetof(ImDrawVert, uv));
|
glVertexAttribPointer(uv_location, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, uv));
|
||||||
glVertexAttribPointer(colour_location, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*) offsetof(ImDrawVert, col));
|
glVertexAttribPointer(colour_location, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), (GLvoid*)OFFSETOF(ImDrawVert, col));
|
||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@ ifeq ($(UNAME_S), Darwin) #APPLE
|
|||||||
|
|
||||||
CXXFLAGS = -I../../ -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
|
CXXFLAGS = -I../../ -I/usr/local/Cellar/glew/1.10.0/include -I/usr/local/include
|
||||||
CXXFLAGS += -Wall
|
CXXFLAGS += -Wall
|
||||||
|
|
||||||
# CXXFLAGS += -D__APPLE__
|
# CXXFLAGS += -D__APPLE__
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#define GLEW_STATIC
|
#define GLEW_STATIC
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
|
#define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
|
||||||
|
|
||||||
static GLFWwindow* window;
|
static GLFWwindow* window;
|
||||||
static GLuint fontTex;
|
static GLuint fontTex;
|
||||||
@ -60,9 +61,9 @@ static void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_c
|
|||||||
{
|
{
|
||||||
const ImDrawList* cmd_list = cmd_lists[n];
|
const ImDrawList* cmd_list = cmd_lists[n];
|
||||||
const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->vtx_buffer.front();
|
const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->vtx_buffer.front();
|
||||||
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + offsetof(ImDrawVert, pos)));
|
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, pos)));
|
||||||
glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + offsetof(ImDrawVert, uv)));
|
glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, uv)));
|
||||||
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + offsetof(ImDrawVert, col)));
|
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, col)));
|
||||||
|
|
||||||
int vtx_offset = 0;
|
int vtx_offset = 0;
|
||||||
for (size_t cmd_i = 0; cmd_i < cmd_list->commands.size(); cmd_i++)
|
for (size_t cmd_i = 0; cmd_i < cmd_list->commands.size(); cmd_i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user