Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dbox & examples to work with current compilers #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
],

"dependencies": {
"glad-drey": ">=0.0.2",
"dimgui": ">=0.1.7-alpha",
"dimgui": ">=1.0.0"
},

"subPackages": [
Expand Down
6 changes: 2 additions & 4 deletions examples/demo/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"sourceFiles": ["demo.d"],

"sourcePaths": [
".", "framework", "tests"
"framework", "tests"
],

"mainSourceFile": "demo.d",
Expand All @@ -41,8 +41,6 @@

"dependencies": {
"dbox": {"path": "../../", "version": "~master"},
"glfw-drey": ">=0.0.2",
"glwtf-drey": ">=0.0.1",
"dimgui": ">=0.1.4-alpha",
"dimgui": ">=1.0.0"
},
}
94 changes: 47 additions & 47 deletions examples/demo/framework/debug_draw.d
Original file line number Diff line number Diff line change
Expand Up @@ -447,26 +447,26 @@ struct GLRenderPoints
void Create()
{
string vs =
"#version 400\n"
"uniform mat4 projectionMatrix;\n"
"layout(location = 0) in vec2 v_position;\n"
"layout(location = 1) in vec4 v_color;\n"
"layout(location = 2) in float v_size;\n"
"out vec4 f_color;\n"
"void main(void)\n"
"{\n"
" f_color = v_color;\n"
" gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);\n"
" gl_PointSize = v_size;\n"
"#version 400\n" ~
"uniform mat4 projectionMatrix;\n" ~
"layout(location = 0) in vec2 v_position;\n" ~
"layout(location = 1) in vec4 v_color;\n" ~
"layout(location = 2) in float v_size;\n" ~
"out vec4 f_color;\n" ~
"void main(void)\n" ~
"{\n" ~
" f_color = v_color;\n" ~
" gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);\n" ~
" gl_PointSize = v_size;\n" ~
"}\n";

string fs =
"#version 400\n"
"in vec4 f_color;\n"
"out vec4 color;\n"
"void main(void)\n"
"{\n"
" color = f_color;\n"
"#version 400\n" ~
"in vec4 f_color;\n" ~
"out vec4 color;\n" ~
"void main(void)\n" ~
"{\n" ~
" color = f_color;\n" ~
"}\n";

m_programId = sCreateShaderProgram(vs, fs);
Expand Down Expand Up @@ -591,24 +591,24 @@ struct GLRenderLines
void Create()
{
string vs =
"#version 400\n"
"uniform mat4 projectionMatrix;\n"
"layout(location = 0) in vec2 v_position;\n"
"layout(location = 1) in vec4 v_color;\n"
"out vec4 f_color;\n"
"void main(void)\n"
"{\n"
" f_color = v_color;\n"
" gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);\n"
"#version 400\n" ~
"uniform mat4 projectionMatrix;\n" ~
"layout(location = 0) in vec2 v_position;\n" ~
"layout(location = 1) in vec4 v_color;\n" ~
"out vec4 f_color;\n" ~
"void main(void)\n" ~
"{\n" ~
" f_color = v_color;\n" ~
" gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);\n" ~
"}\n";

string fs =
"#version 400\n"
"in vec4 f_color;\n"
"out vec4 color;\n"
"void main(void)\n"
"{\n"
" color = f_color;\n"
"#version 400\n" ~
"in vec4 f_color;\n" ~
"out vec4 color;\n" ~
"void main(void)\n" ~
"{\n" ~
" color = f_color;\n" ~
"}\n";

m_programId = sCreateShaderProgram(vs, fs);
Expand Down Expand Up @@ -719,24 +719,24 @@ struct GLRenderTriangles
void Create()
{
string vs =
"#version 400\n"
"uniform mat4 projectionMatrix;\n"
"layout(location = 0) in vec2 v_position;\n"
"layout(location = 1) in vec4 v_color;\n"
"out vec4 f_color;\n"
"void main(void)\n"
"{\n"
" f_color = v_color;\n"
" gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);\n"
"#version 400\n" ~
"uniform mat4 projectionMatrix;\n" ~
"layout(location = 0) in vec2 v_position;\n" ~
"layout(location = 1) in vec4 v_color;\n" ~
"out vec4 f_color;\n" ~
"void main(void)\n" ~
"{\n" ~
" f_color = v_color;\n" ~
" gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);\n" ~
"}\n";

string fs =
"#version 400\n"
"in vec4 f_color;\n"
"out vec4 color;\n"
"void main(void)\n"
"{\n"
" color = f_color;\n"
"#version 400\n" ~
"in vec4 f_color;\n" ~
"out vec4 color;\n" ~
"void main(void)\n" ~
"{\n" ~
" color = f_color;\n" ~
"}\n";

m_programId = sCreateShaderProgram(vs, fs);
Expand Down
21 changes: 20 additions & 1 deletion examples/demo/framework/main.d
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ Test test;
Settings settings;
bool moveCamera;
b2Vec2 lastp;
// Scaling for high-resolution displays.
double mouseXToWindowFactor = 0, mouseYToWindowFactor = 0;

//
void sCreateUI()
Expand Down Expand Up @@ -113,6 +115,8 @@ extern(C) void sResizeWindow(GLFWwindow*, int width, int height)
{
g_camera.m_width = width;
g_camera.m_height = height;
mouseXToWindowFactor = 0;
mouseYToWindowFactor = 0;
}

//
Expand Down Expand Up @@ -561,7 +565,7 @@ void runTests()

while (!glfwWindowShouldClose(mainWindow))
{
glfwGetWindowSize(mainWindow, &g_camera.m_width, &g_camera.m_height);
glfwGetFramebufferSize(mainWindow, &g_camera.m_width, &g_camera.m_height);
glViewport(0, 0, g_camera.m_width, g_camera.m_height);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
Expand All @@ -572,6 +576,21 @@ void runTests()

double xd, yd;
glfwGetCursorPos(mainWindow, &xd, &yd);
// Scale the cursor position for high-resolution displays.
if (mouseXToWindowFactor == 0) // need to initialize
{
int virtualWindowWidth, virtualWindowHeight;
glfwGetWindowSize(mainWindow, &virtualWindowWidth, &virtualWindowHeight);
if (virtualWindowWidth != 0 && virtualWindowHeight != 0)
{
int frameBufferWidth, frameBufferHeight;
glfwGetFramebufferSize(mainWindow, &frameBufferWidth, &frameBufferHeight);
mouseXToWindowFactor = double(frameBufferWidth) / virtualWindowWidth;
mouseYToWindowFactor = double(frameBufferHeight) / virtualWindowHeight;
}
}
xd *= mouseXToWindowFactor;
yd *= mouseYToWindowFactor;
int mousex = cast(int)xd;
int mousey = cast(int)yd;

Expand Down
6 changes: 4 additions & 2 deletions examples/demo/tests/dynamictreetest.d
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ private:

void Query()
{
m_tree.Query(this, m_queryAABB);
auto callback = this;
m_tree.Query(callback, m_queryAABB);

for (int32 i = 0; i < e_actorCount; ++i)
{
Expand All @@ -341,7 +342,8 @@ private:
b2RayCastInput input = m_rayCastInput;

// Ray cast against the dynamic tree.
m_tree.RayCast(this, input);
auto callback = this;
m_tree.RayCast(callback, input);

// Brute force ray cast.
Actor* bruteActor = null;
Expand Down
4 changes: 1 addition & 3 deletions examples/hello_world/dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
"mainSourceFile": "hello_world.d",

"dependencies": {
"dbox": {"path": "../../", "version": "~master"},
"glfw-drey": ">=0.0.2",
"glwtf-drey": ">=0.0.1",
"dbox": {"path": "../../", "version": "~master"}
},
}
23 changes: 15 additions & 8 deletions src/dbox/common/b2settings.d
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,23 @@ void b2Log(const(char)* str, ...)
{
va_list args;

version (X86)
va_start(args, str);
static if (__VERSION__ <= 2071)
{
version (X86)
va_start(args, str);
else
version (Win64)
va_start(args, str);
else
version (X86_64)
va_start(args, __va_argsave);
else
static assert(0, "Platform not supported.");
}
else
version (Win64)
{
va_start(args, str);
else
version (X86_64)
va_start(args, __va_argsave);
else
static assert(0, "Platform not supported.");
}

vprintf(str, args);
va_end(args);
Expand Down