Browse Source

fixed 9 files out of 506:

- removed 0 CR characters
 - removed 7 trailing whitespaces
 - replaced 332 tabs with spaces
legacy
Lolbot Sam Hocevar <sam@hocevar.net> 8 years ago
parent
commit
af53a69eb7
9 changed files with 142 additions and 142 deletions
  1. +55
    -55
      doc/tutorial/15_lolimgui.cpp
  2. +16
    -16
      src/gpu/shader.cpp
  3. +2
    -2
      src/gpu/vertexbuffer.cpp
  4. +12
    -12
      src/lol/base/string.h
  5. +1
    -1
      src/lol/gpu/vertexbuffer.h
  6. +51
    -51
      src/lolimgui.cpp
  7. +3
    -3
      src/lolimgui.h
  8. +1
    -1
      src/mesh/mesh.cpp
  9. +1
    -1
      tools/lolremez/lolremez.cpp

+ 55
- 55
doc/tutorial/15_lolimgui.cpp View File

@@ -23,66 +23,66 @@ using namespace lol;
class LolImGuiDemo : public WorldEntity
{
public:
LolImGuiDemo()
{
LolImGui::Init();
}
LolImGuiDemo()
{
LolImGui::Init();
}

~LolImGuiDemo()
{
LolImGui::Shutdown();
}
~LolImGuiDemo()
{
LolImGui::Shutdown();
}

virtual void TickGame(float seconds)
virtual void TickGame(float seconds)
{
WorldEntity::TickGame(seconds);

static float f;
static vec3 clear_color;
static char buf[512];
ImGuiIO& io = ImGui::GetIO();
ImGui::SetNextWindowFocus();
ImGui::Begin("testature");
{
if (ImGui::IsWindowHovered())
ImGui::Text("Hovered: true");
else
ImGui::Text("Hovered: false");
if (ImGui::IsWindowFocused())
ImGui::Text("Focused: true");
else
ImGui::Text("Focused: false");
ImGui::Text("Hello, world!");
ImGui::Text("prout!");
ImGui::Text("prout!%i", 100);
ImGui::Text("MousePos!%.2f/%.2f", io.MousePos.x, io.MousePos.y);
ImGui::Button("Test Window");
ImGui::Text("Slider: %.2f", f);
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
//ImGui::ColorEdit3("clear color", (float*)&clear_color);
ImGui::Text("Left Mouse: %s", io.MouseDown[0] ? "true" : "false");
ImGui::Text("Scroll: %f", io.MouseWheel);
ImGui::Text("Maj: %s", io.KeyShift ? "true" : "false");
ImGui::Text("Ctrl: %s", io.KeyCtrl ? "true" : "false");
ImGui::Text("Clipboard %s", LolImGui::GetClipboard().C());
ImGui::InputText("base input", buf, 512);
}
ImGui::End();
ImGui::Begin("SO FUN !!");
{
if (ImGui::IsWindowHovered())
ImGui::Text("Hovered: true");
else
ImGui::Text("Hovered: false");
if (ImGui::IsWindowFocused())
ImGui::Text("Focused: true");
else
ImGui::Text("Focused: false");
ImGui::Text("poucka!");
ImGui::Text(" poucka!");
}
ImGui::End();
}
static float f;
static vec3 clear_color;
static char buf[512];
ImGuiIO& io = ImGui::GetIO();
ImGui::SetNextWindowFocus();
ImGui::Begin("testature");
{
if (ImGui::IsWindowHovered())
ImGui::Text("Hovered: true");
else
ImGui::Text("Hovered: false");
if (ImGui::IsWindowFocused())
ImGui::Text("Focused: true");
else
ImGui::Text("Focused: false");
ImGui::Text("Hello, world!");
ImGui::Text("prout!");
ImGui::Text("prout!%i", 100);
ImGui::Text("MousePos!%.2f/%.2f", io.MousePos.x, io.MousePos.y);
ImGui::Button("Test Window");
ImGui::Text("Slider: %.2f", f);
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
//ImGui::ColorEdit3("clear color", (float*)&clear_color);
ImGui::Text("Left Mouse: %s", io.MouseDown[0] ? "true" : "false");
ImGui::Text("Scroll: %f", io.MouseWheel);
ImGui::Text("Maj: %s", io.KeyShift ? "true" : "false");
ImGui::Text("Ctrl: %s", io.KeyCtrl ? "true" : "false");
ImGui::Text("Clipboard %s", LolImGui::GetClipboard().C());
ImGui::InputText("base input", buf, 512);
}
ImGui::End();
ImGui::Begin("SO FUN !!");
{
if (ImGui::IsWindowHovered())
ImGui::Text("Hovered: true");
else
ImGui::Text("Hovered: false");
if (ImGui::IsWindowFocused())
ImGui::Text("Focused: true");
else
ImGui::Text("Focused: false");
ImGui::Text("poucka!");
ImGui::Text(" poucka!");
}
ImGui::End();
}

virtual void TickDraw(float seconds, Scene &scene)
{


+ 16
- 16
src/gpu/shader.cpp View File

@@ -658,11 +658,11 @@ String ShaderData::Patch(String const &code, ShaderType type)
}

/* Perform small replaces */
char const * const fast_replaces[] =
{
"#version 130", "#version 120",
"out vec4 out_color;", " ",
"out_color =", "gl_FragColor =",
char const * const fast_replaces[] =
{
"#version 130", "#version 120",
"out vec4 out_color;", " ",
"out_color =", "gl_FragColor =",
"in vec2", type == ShaderType::Vertex ? "attribute vec2" : "varying vec2",
"in vec3", type == ShaderType::Vertex ? "attribute vec3" : "varying vec3",
"in vec4", type == ShaderType::Vertex ? "attribute vec4" : "varying vec4",
@@ -676,20 +676,20 @@ String ShaderData::Patch(String const &code, ShaderType type)

for (char const * const *rep = fast_replaces; rep[0]; rep += 2)
{
while (true)
{
int index = patched_code.index_of(rep[0]);
if (index == INDEX_NONE)
break;
while (true)
{
int index = patched_code.index_of(rep[0]);
if (index == INDEX_NONE)
break;

size_t l0 = strlen(rep[0]);
size_t l1 = strlen(rep[1]);
size_t l0 = strlen(rep[0]);
size_t l1 = strlen(rep[1]);

String left = patched_code.sub(0, index);
String right = patched_code.sub(index + l0, patched_code.count() - (index + l0));
String left = patched_code.sub(0, index);
String right = patched_code.sub(index + l0, patched_code.count() - (index + l0));

patched_code = left + String(rep[1]) + right;
}
patched_code = left + String(rep[1]) + right;
}
}
}



+ 2
- 2
src/gpu/vertexbuffer.cpp View File

@@ -108,7 +108,7 @@ void VertexDeclaration::DrawIndexedElements(MeshPrimitive type, int count, const
if (count <= 0)
return;

uint32_t elementType = typeSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;
uint32_t elementType = typeSize == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT;

/* FIXME: this has nothing to do here! */
switch (type.ToScalar())
@@ -118,7 +118,7 @@ void VertexDeclaration::DrawIndexedElements(MeshPrimitive type, int count, const
break;
case MeshPrimitive::TriangleStrips:
glDrawElements(GL_TRIANGLE_STRIP, count, elementType, skip);
break;
break;
case MeshPrimitive::TriangleFans:
glDrawElements(GL_TRIANGLE_FAN, count, elementType, skip);
break;


+ 12
- 12
src/lol/base/string.h View File

@@ -170,18 +170,18 @@ public:
return -1;
}

int count_occurence(String const& token) const { return last_index_of(token.C()); }
int count_occurence(char const* token) const
{
int count = 0;
const char *match = strstr(C(), token);
while (match)
{
count++;
match = strstr(match + 1, token);
}
return count;
}
int count_occurence(String const& token) const { return last_index_of(token.C()); }
int count_occurence(char const* token) const
{
int count = 0;
const char *match = strstr(C(), token);
while (match)
{
count++;
match = strstr(match + 1, token);
}
return count;
}

int replace(char const old_token, char const new_token,
bool all_occurrences = false)


+ 1
- 1
src/lol/gpu/vertexbuffer.h View File

@@ -212,7 +212,7 @@ public:

/* Draw elements. See MeshPrimitive for a list of all available
* types. Both skip and count are numbers of indices, not primitives. */
void DrawIndexedElements(MeshPrimitive type, int count, const short* skip = nullptr, short typeSize = 2);
void DrawIndexedElements(MeshPrimitive type, int count, const short* skip = nullptr, short typeSize = 2);

void Unbind();
void SetStream(VertexBuffer *vb, ShaderAttrib attr1,


+ 51
- 51
src/lolimgui.cpp View File

@@ -145,11 +145,11 @@ io.AddInputCharacter((unsigned short)c);

void LolImGui::Shutdown()
{
if (g_lolimgui)
{
Ticker::Unref(g_lolimgui);
g_lolimgui = nullptr;
}
if (g_lolimgui)
{
Ticker::Unref(g_lolimgui);
g_lolimgui = nullptr;
}

ImGui::Shutdown();
}
@@ -257,9 +257,9 @@ void LolImGui::TickGame(float seconds)
io.MousePos = ImVec2(-1.f, -1.f);
}
else
{
{
//msg::debug("Focused !!\n");
}
}
break;
}
}
@@ -315,9 +315,9 @@ void LolImGui::RenderDrawListsMethod(ImDrawData* draw_data)
if (!m_shader)
{
String code;
m_builder.Build(code);
m_builder.Build(code);

m_shader = Shader::Create(m_builder.GetName(), code);
m_shader = Shader::Create(m_builder.GetName(), code);
ASSERT(m_shader);

m_ortho.m_uniform = m_shader->GetUniformLocation(m_ortho.m_var);
@@ -353,39 +353,39 @@ void LolImGui::RenderDrawListsMethod(ImDrawData* draw_data)
m_shader->SetUniform(m_ortho, ortho);
m_shader->SetUniform(m_texture, m_font->GetTexture()->GetTextureUniform(), 0);

struct Vertex
{
vec2 pos, tex;
u8vec4 color;
};
VertexBuffer* vbo = new VertexBuffer(cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
ImDrawVert *vert = (ImDrawVert *)vbo->Lock(0, 0);
memcpy(vert, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
vbo->Unlock();
IndexBuffer *ibo = new IndexBuffer(cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
ImDrawIdx *indices = (ImDrawIdx *)ibo->Lock(0, 0);
memcpy(indices, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
ibo->Unlock();
m_font->Bind();
ibo->Bind();
m_vdecl->Bind();
m_vdecl->SetStream(vbo, m_attribs[0], m_attribs[1], m_attribs[2]);
const ImDrawIdx* idx_buffer_offset = 0;
for (size_t cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
struct Vertex
{
vec2 pos, tex;
u8vec4 color;
};
VertexBuffer* vbo = new VertexBuffer(cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
ImDrawVert *vert = (ImDrawVert *)vbo->Lock(0, 0);
memcpy(vert, cmd_list->VtxBuffer.Data, cmd_list->VtxBuffer.Size * sizeof(ImDrawVert));
vbo->Unlock();
IndexBuffer *ibo = new IndexBuffer(cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
ImDrawIdx *indices = (ImDrawIdx *)ibo->Lock(0, 0);
memcpy(indices, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx));
ibo->Unlock();
m_font->Bind();
ibo->Bind();
m_vdecl->Bind();
m_vdecl->SetStream(vbo, m_attribs[0], m_attribs[1], m_attribs[2]);
const ImDrawIdx* idx_buffer_offset = 0;
for (size_t cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[(int)cmd_i];
#ifdef SHOW_IMGUI_DEBUG
//-----------------------------------------------------------------
//<Debug render> --------------------------------------------------
//-----------------------------------------------------------------
//Doesn't work anymore ......
static uint32_t idx_buffer_offset_i = 0;
if (cmd_i == 0)
idx_buffer_offset_i = 0;
//Doesn't work anymore ......
static uint32_t idx_buffer_offset_i = 0;
if (cmd_i == 0)
idx_buffer_offset_i = 0;

float mod = -200.f;
vec3 off = vec3(vec2(-size.x, -size.y), 0.f);
@@ -397,10 +397,10 @@ void LolImGui::RenderDrawListsMethod(ImDrawData* draw_data)
};
for (int i = 0; i < 4; ++i)
Debug::DrawLine(pos[i], pos[(i + 1) % 4], Color::white);
ImDrawVert* buf = vert;
ImDrawVert* buf = vert;
for (uint16_t i = 0; i < pcmd->ElemCount; i += 3)
{
uint16_t ib = indices[idx_buffer_offset_i + i];
uint16_t ib = indices[idx_buffer_offset_i + i];
vec2 pos[3];
pos[0] = vec2(buf[ib + 0].pos.x, buf[ib + 0].pos.y);
pos[1] = vec2(buf[ib + 1].pos.x, buf[ib + 1].pos.y);
@@ -413,27 +413,27 @@ void LolImGui::RenderDrawListsMethod(ImDrawData* draw_data)
Debug::DrawLine((off + vec3(pos[1], 0.f)) / mod, (off + vec3(pos[2], 0.f)) / mod, col[1]);
Debug::DrawLine((off + vec3(pos[2], 0.f)) / mod, (off + vec3(pos[0], 0.f)) / mod, col[2]);
}
idx_buffer_offset_i += pcmd->ElemCount;
//-----------------------------------------------------------------
idx_buffer_offset_i += pcmd->ElemCount;
//-----------------------------------------------------------------
//<\Debug render> -------------------------------------------------
//-----------------------------------------------------------------
#endif //SHOW_IMGUI_DEBUG
Debug::DrawLine(vec2::zero, vec2::axis_x, Color::green);
Debug::DrawLine(vec2::zero, vec2::axis_x, Color::green);

m_vdecl->DrawIndexedElements(MeshPrimitive::Triangles, pcmd->ElemCount, (const short*)idx_buffer_offset);
m_vdecl->DrawIndexedElements(MeshPrimitive::Triangles, pcmd->ElemCount, (const short*)idx_buffer_offset);

idx_buffer_offset += pcmd->ElemCount;
idx_buffer_offset += pcmd->ElemCount;
}

m_vdecl->Unbind();
ibo->Unbind();
m_font->Unbind();
m_vdecl->Unbind();
ibo->Unbind();
m_font->Unbind();

delete vbo;
delete ibo;
}
delete vbo;
delete ibo;
}

m_shader->Unbind();
m_shader->Unbind();
}


+ 3
- 3
src/lolimgui.h View File

@@ -167,9 +167,9 @@ protected:
Uniform m_ortho;
Uniform m_texture;
array<ShaderAttrib> m_attribs;
VertexDeclaration* m_vdecl = nullptr;
IndexBuffer* m_ibuff = nullptr;
Controller* m_controller = nullptr;
VertexDeclaration* m_vdecl = nullptr;
IndexBuffer* m_ibuff = nullptr;
Controller* m_controller = nullptr;
InputDevice* m_mouse = nullptr;
InputDevice* m_keyboard = nullptr;
InputProfile m_profile;


+ 1
- 1
src/mesh/mesh.cpp View File

@@ -143,7 +143,7 @@ void SubMesh::Render()
ShaderUniform u_tex = m_shader->GetUniformLocation(m_textures[i].m1.C());
m_shader->SetUniform(u_tex, m_textures[i].m2->GetTextureUniform(), i);
}
m_ibo->Bind();
m_vdecl->Bind();
m_vdecl->DrawIndexedElements(MeshPrimitive::Triangles, m_ibo->GetSize() / sizeof(uint16_t));


+ 1
- 1
tools/lolremez/lolremez.cpp View File

@@ -41,7 +41,7 @@ static void usage()
{
printf("Usage: lolremez [-d degree] [-r xmin:xmax] x-expression [x-error]\n");
printf(" lolremez -h | --help\n");
printf(" lolremez -V | --version\n");
printf(" lolremez -V | --version\n");
printf("Find a polynomial approximation for x-expression.\n");
printf("\n");
printf("Mandatory arguments to long options are mandatory for short options too.\n");


Loading…
Cancel
Save