Go to the documentation of this file.
30 #define BUFFER_OFFSET(x) ((const void*) (x))
41 float v = (h - ps.
y) / h;
44 b2Vec2 extents(ratio * 25.0
f, 25.0
f);
51 pw.
x = (1.0f - u) * lower.
x + u * upper.
x;
52 pw.
y = (1.0f - v) * lower.
y + v * upper.
y;
62 b2Vec2 extents(ratio * 25.0
f, 25.0
f);
68 float u = (pw.
x - lower.
x) / (upper.
x - lower.
x);
69 float v = (pw.
y - lower.
y) / (upper.
y - lower.
y);
73 ps.
y = (1.0f - v) * h;
84 b2Vec2 extents(ratio * 25.0
f, 25.0
f);
90 m[0] = 2.0f / (upper.
x - lower.
x);
96 m[5] = 2.0f / (upper.
y - lower.
y);
105 m[12] = -(upper.
x + lower.
x) / (upper.
x - lower.
x);
106 m[13] = -(upper.
y + lower.
y) / (upper.
y - lower.
y);
117 fprintf(stderr,
"OpenGL error = %d\n", errCode);
125 GLint log_length = 0;
132 fprintf(stderr,
"printlog: Not a shader or a program\n");
136 char* log = (
char*)malloc(log_length);
143 fprintf(stderr,
"%s", log);
152 const char* sources[] = { source };
159 fprintf(stderr,
"Error compiling shader of type %d!\n",
type);
173 assert(vsId != 0 && fsId != 0);
198 "uniform mat4 projectionMatrix;\n"
199 "layout(location = 0) in vec2 v_position;\n"
200 "layout(location = 1) in vec4 v_color;\n"
201 "layout(location = 2) in float v_size;\n"
202 "out vec4 f_color;\n"
205 " f_color = v_color;\n"
206 " gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);\n"
207 " gl_PointSize = v_size;\n"
216 " color = f_color;\n"
290 float proj[16] = { 0.0f };
342 "uniform mat4 projectionMatrix;\n"
343 "layout(location = 0) in vec2 v_position;\n"
344 "layout(location = 1) in vec4 v_color;\n"
345 "out vec4 f_color;\n"
348 " f_color = v_color;\n"
349 " gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);\n"
358 " color = f_color;\n"
425 float proj[16] = { 0.0f };
470 "uniform mat4 projectionMatrix;\n"
471 "layout(location = 0) in vec2 v_position;\n"
472 "layout(location = 1) in vec4 v_color;\n"
473 "out vec4 f_color;\n"
476 " f_color = v_color;\n"
477 " gl_Position = projectionMatrix * vec4(v_position, 0.0f, 1.0f);\n"
486 " color = f_color;\n"
553 float proj[16] = { 0.0f };
641 b2Vec2 p1 = vertices[vertexCount - 1];
642 for (
int32 i = 0; i < vertexCount; ++i)
654 b2Color fillColor(0.5
f * color.
r, 0.5f * color.
g, 0.5f * color.
b, 0.5f);
656 for (
int32 i = 1; i < vertexCount - 1; ++i)
663 b2Vec2 p1 = vertices[vertexCount - 1];
664 for (
int32 i = 0; i < vertexCount; ++i)
676 const float k_segments = 16.0f;
677 const float k_increment = 2.0f *
b2_pi / k_segments;
678 float sinInc = sinf(k_increment);
679 float cosInc = cosf(k_increment);
681 b2Vec2 v1 = center + radius * r1;
682 for (
int32 i = 0; i < k_segments; ++i)
686 r2.
x = cosInc * r1.x - sinInc * r1.y;
687 r2.
y = sinInc * r1.x + cosInc * r1.y;
688 b2Vec2 v2 = center + radius * r2;
699 const float k_segments = 16.0f;
700 const float k_increment = 2.0f *
b2_pi / k_segments;
701 float sinInc = sinf(k_increment);
702 float cosInc = cosf(k_increment);
704 b2Vec2 r1(cosInc, sinInc);
705 b2Vec2 v1 = center + radius * r1;
706 b2Color fillColor(0.5
f * color.
r, 0.5f * color.
g, 0.5f * color.
b, 0.5f);
707 for (
int32 i = 0; i < k_segments; ++i)
711 r2.
x = cosInc * r1.x - sinInc * r1.y;
712 r2.
y = sinInc * r1.x + cosInc * r1.y;
713 b2Vec2 v2 = center + radius * r2;
722 v1 = center + radius * r1;
723 for (
int32 i = 0; i < k_segments; ++i)
726 r2.
x = cosInc * r1.x - sinInc * r1.y;
727 r2.
y = sinInc * r1.x + cosInc * r1.y;
728 b2Vec2 v2 = center + radius * r2;
736 b2Vec2 p = center + radius * axis;
751 const float k_axisScale = 0.4f;
780 va_start(arg,
string);
794 va_start(arg,
string);
#define glUniformMatrix4fv
@ ImGuiWindowFlags_NoScrollbar
IMGUI_API void TextColoredV(const ImVec4 &col, const char *fmt, va_list args) IM_FMTLIST(2)
#define GL_ONE_MINUS_SRC_ALPHA
#define GL_COMPILE_STATUS
#define GL_PROGRAM_POINT_SIZE
#define glGetShaderInfoLog
void BuildProjectionMatrix(float *m, float zBias)
void DrawSegment(const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color) override
Draw a line segment.
static GLuint sCreateShaderFromString(const char *source, GLenum type)
void DrawAABB(b2AABB *aabb, const b2Color &color)
@ ImGuiWindowFlags_AlwaysAutoResize
b2Vec2 GetXAxis() const
Get the x-axis.
void Set(float x_, float y_)
Set this vector to some specified coordinates.
static void sPrintLog(GLuint object)
b2Vec2 upperBound
the upper vertex
float m_sizes[e_maxVertices]
#define glBindFragDataLocation
IMGUI_API void SetCursorPos(const ImVec2 &local_pos)
void Vertex(const b2Vec2 &v, const b2Color &c)
b2Vec2 m_vertices[e_maxVertices]
b2Color m_colors[e_maxVertices]
GLint m_projectionUniform
b2Vec2 m_vertices[e_maxVertices]
b2Color m_colors[e_maxVertices]
void DrawPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color) override
Draw a closed polygon provided in CCW order.
GLRenderPoints * m_points
void DrawString(int x, int y, const char *string,...)
static GLuint sCreateShaderProgram(const char *vs, const char *fs)
#define glDeleteVertexArrays
#define glEnableVertexAttribArray
Color for debug drawing. Each value has the range [0,1].
#define GL_FRAGMENT_SHADER
void DrawPoint(const b2Vec2 &p, float size, const b2Color &color) override
Draw a point.
#define glGetUniformLocation
#define glGetProgramInfoLog
void DrawSolidCircle(const b2Vec2 ¢er, float radius, const b2Vec2 &axis, const b2Color &color) override
Draw a solid circle.
GLint m_projectionUniform
An axis aligned bounding box.
#define glVertexAttribPointer
b2Vec2 GetYAxis() const
Get the u-axis.
GLRenderTriangles * m_triangles
IMGUI_API bool Begin(const char *name, bool *p_open=NULL, ImGuiWindowFlags flags=0)
#define GL_INFO_LOG_LENGTH
void DrawCircle(const b2Vec2 ¢er, float radius, const b2Color &color) override
Draw a circle.
void DrawTransform(const b2Transform &xf) override
b2Vec2 m_vertices[e_maxVertices]
#define glGenVertexArrays
b2Vec2 ConvertScreenToWorld(const b2Vec2 &screenPoint)
@ ImGuiWindowFlags_NoTitleBar
#define glBindVertexArray
GLint m_projectionUniform
void DrawSolidPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color) override
Draw a solid closed polygon provided in CCW order.
b2Vec2 ConvertWorldToScreen(const b2Vec2 &worldPoint)
void Vertex(const b2Vec2 &v, const b2Color &c)
b2Color m_colors[e_maxVertices]
b2Vec2 lowerBound
the lower vertex
@ ImGuiWindowFlags_NoInputs
void Vertex(const b2Vec2 &v, const b2Color &c, float size)
static void sCheckGLError()
mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:07