Skip to content

Commit

Permalink
Merge branch '3dVisualizer' into visualize3D
Browse files Browse the repository at this point in the history
  • Loading branch information
paxcut committed Oct 12, 2023
2 parents 4a45638 + 289e7ff commit 3416c6b
Show file tree
Hide file tree
Showing 14 changed files with 3,242 additions and 562 deletions.
881 changes: 865 additions & 16 deletions lib/libimhex/include/hex/helpers/opengl.hpp

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions lib/libimhex/source/helpers/opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace hex::gl {
this->m_program = glCreateProgram();

glAttachShader(this->m_program, vertexShader);
glAttachShader(this->m_program, fragmentShader);
glAttachShader(this->m_program, fragmentShader);
glLinkProgram(this->m_program);

int result = false;
Expand Down Expand Up @@ -62,13 +62,14 @@ namespace hex::gl {
glUseProgram(0);
}

void Shader::setUniform(std::string_view name, const int &value) {
glUniform1i(getUniformLocation(name), value);
}

void Shader::setUniform(std::string_view name, const float &value) {
glUniform1f(getUniformLocation(name), value);
}

void Shader::setUniform(std::string_view name, const Vector<float, 3> &value) {
glUniform3f(getUniformLocation(name), value[0], value[1], value[2]);
}

GLint Shader::getUniformLocation(std::string_view name) {
auto uniform = this->m_uniforms.find(name.data());
Expand Down Expand Up @@ -148,20 +149,21 @@ namespace hex::gl {
}

template<typename T>
void Buffer<T>::draw() const {
void Buffer<T>::draw(unsigned primitive) const {
switch (this->m_type) {
case GL_ARRAY_BUFFER:
glDrawArrays(GL_TRIANGLES, 0, this->m_size);
glDrawArrays(primitive, 0, this->m_size);
break;
case GL_ELEMENT_ARRAY_BUFFER:
glDrawElements(GL_TRIANGLES, this->m_size, getType<T>(), nullptr);
glDrawElements(primitive, this->m_size, getType<T>(), nullptr);
break;
}
}

template class Buffer<float>;
template class Buffer<u32>;

template class Buffer<u16>;
template class Buffer<u8>;

VertexArray::VertexArray() {
glGenVertexArrays(1, &this->m_array);
Expand Down
266 changes: 137 additions & 129 deletions plugins/builtin/romfs/lang/de_DE.json

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions plugins/builtin/romfs/lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,48 @@
"hex.builtin.pattern_drawer.var_name": "Name",
"hex.builtin.pattern_drawer.visualizer.unknown": "Unknown visualizer",
"hex.builtin.pattern_drawer.visualizer.invalid_parameter_count": "Invalid parameter count",
"hex.builtin.pl_visualizer.3d.ambient": "Ambient",
"hex.builtin.pl_visualizer.3d.ambientIntensity": "Ambient intensity",
"hex.builtin.pl_visualizer.3d.axes": "Axes",
"hex.builtin.pl_visualizer.3d.axes_description": "Controls axes display",
"hex.builtin.pl_visualizer.3d.diffuse": "Diffuse",
"hex.builtin.pl_visualizer.3d.diffuseIntensity": "Diffuse intensity",
"hex.builtin.pl_visualizer.3d.drawAxes": "Draw Axes",
"hex.builtin.pl_visualizer.3d.dontDrawAxes": "Don't Draw Axes",
"hex.builtin.pl_visualizer.3d.drawGrid": "Draw Grid",
"hex.builtin.pl_visualizer.3d.dontDrawGrid": "Don't Draw Grid",
"hex.builtin.pl_visualizer.3d.graph_controls": "Graph controls",
"hex.builtin.pl_visualizer.3d.grid": "Grid",
"hex.builtin.pl_visualizer.3d.grid_description": "Controls grid display",
"hex.builtin.pl_visualizer.3d.graph": "Graph",
"hex.builtin.pl_visualizer.3d.graph_description": "Graph controls",
"hex.builtin.pl_visualizer.3d.lightPosition": "Light Position",
"hex.builtin.pl_visualizer.3d.lightPosition_description": "Position of light source in world space",
"hex.builtin.pl_visualizer.3d.lightPosition_usage": "X, Y and Z coordinates of the light source",
"hex.builtin.pl_visualizer.3d.line": "Draw model using lines",
"hex.builtin.pl_visualizer.3d.model": "Model",
"hex.builtin.pl_visualizer.3d.nearClipPlane": "Near Clip Plane",
"hex.builtin.pl_visualizer.3d.nearlimit": "Use keypad 9 and 3",
"hex.builtin.pl_visualizer.3d.orthographic": "Orthographic projection",
"hex.builtin.pl_visualizer.3d.perspective": "Perspective projection",
"hex.builtin.pl_visualizer.3d.primitive": "Primitive",
"hex.builtin.pl_visualizer.3d.projection": "Projection",
"hex.builtin.pl_visualizer.3d.reverseRotations": "Reverse rotations",
"hex.builtin.pl_visualizer.3d.rotation": "Rotation",
"hex.builtin.pl_visualizer.3d.rotation_usage": "For x and y axis use middle click\nFor z axis Use keypad + and -",
"hex.builtin.pl_visualizer.3d.scale": "Scale",
"hex.builtin.pl_visualizer.3d.scale_usage": "Ctrl Right click to enter value or use wheel. Hold SHIFT to accelerate. ",
"hex.builtin.pl_visualizer.3d.size": "Size",
"hex.builtin.pl_visualizer.3d.size_usage": "Horizontal and vertical sizes in pixels",
"hex.builtin.pl_visualizer.3d.specular": "Specular",
"hex.builtin.pl_visualizer.3d.specularIntensity": "Specular intensity",
"hex.builtin.pl_visualizer.3d.strength": "Light Intensity",
"hex.builtin.pl_visualizer.3d.strength_usage": "Intensity of each type of light",
"hex.builtin.pl_visualizer.3d.texture": "Enter full path to texture file",
"hex.builtin.pl_visualizer.3d.textureFile": "Texture file name",
"hex.builtin.pl_visualizer.3d.translation": "Translation",
"hex.builtin.pl_visualizer.3d.translationUse": "Use keypad arrow keys (7 and 1 for Z). Hold SHIFT to accelerate.",
"hex.builtin.pl_visualizer.3d.triangle": "Draw model using triangles",
"hex.builtin.pl_visualizer.coordinates.latitude": "Latitude",
"hex.builtin.pl_visualizer.coordinates.longitude": "Longitude",
"hex.builtin.pl_visualizer.coordinates.query": "Find address",
Expand Down
Loading

0 comments on commit 3416c6b

Please sign in to comment.