obj renders
This commit is contained in:
@@ -109,6 +109,7 @@ namespace Archimedes {
|
||||
stbtt_aligned_quad q;
|
||||
stbtt_GetBakedQuad(bcdata, 1024,1024, text[j]-32, &x,&y,&q,0);//1=opengl & d3d10+,0=d3d9
|
||||
|
||||
//bcdata[text[j]-32].xadvance
|
||||
v.push_back(q.x0);
|
||||
v.push_back(q.y0);
|
||||
v.push_back(0.0f);
|
||||
@@ -170,9 +171,21 @@ namespace Archimedes {
|
||||
shader,
|
||||
texture,
|
||||
RenderMode::Triangles,
|
||||
glm::scale(glm::mat4(1.0f), glm::vec3(0.1f))
|
||||
glm::scale(glm::mat4(1.0f), glm::vec3(0.2f))
|
||||
);
|
||||
}
|
||||
|
||||
float textWidth(std::string str, float height) {
|
||||
|
||||
float w = 0;
|
||||
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
stbtt_bakedchar c = bcdata[str[i]];
|
||||
w += c.xadvance;
|
||||
}
|
||||
|
||||
return w * height / fontSize;
|
||||
}
|
||||
};
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -111,7 +111,7 @@ void Sandbox::run() {
|
||||
static glm::vec3 camPos(0.0f, 0.0f, 3.0f), camRot(0.0f, glm::pi<float>(), 0.0f);
|
||||
static glm::vec3 camPosPrev(0.0f, 0.0f, 3.0f), camRotPrev(0.0f, glm::pi<float>(), 0.0f);
|
||||
|
||||
static glm::vec4 color = { 0.4f, 0.0f, 0.3f, 1.0f };
|
||||
static glm::vec4 color = { 0.4f, 3.0f, 0.4f, 1.0f };
|
||||
|
||||
static int w, h;
|
||||
window->getSize(w, h);
|
||||
@@ -127,16 +127,6 @@ void Sandbox::run() {
|
||||
camPosPrev = camPos;
|
||||
camRotPrev = camRot;
|
||||
|
||||
|
||||
/*
|
||||
window->getRenderer()->draw(
|
||||
hexagon.getMesh(),
|
||||
hexagon.getTransform(),
|
||||
camera.getTransform(),
|
||||
camera.getPerspective(),
|
||||
color
|
||||
);
|
||||
*/
|
||||
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
@@ -240,6 +230,18 @@ void Sandbox::run() {
|
||||
}
|
||||
}
|
||||
|
||||
static bool show_obj = true;
|
||||
ImGui::Checkbox("show obj", &show_obj);
|
||||
if(show_obj) {
|
||||
window->getRenderer()->draw(
|
||||
hexagon.getMesh(),
|
||||
hexagon.getTransform(),
|
||||
camera.getTransform(),
|
||||
camera.getPerspective(),
|
||||
color
|
||||
);
|
||||
}
|
||||
|
||||
ImGui::Text("Camera Properties");
|
||||
|
||||
ImGui::SliderFloat("cam pitch", &camRot.x, -glm::pi<float>(), glm::pi<float>());
|
||||
@@ -271,11 +273,8 @@ bool Sandbox::onEvent(const Archimedes::Event& e) {
|
||||
if(type == app->getEventType(Archimedes::ResizeWindowEvent())) {
|
||||
Archimedes::ResizeWindowEvent event = (Archimedes::ResizeWindowEvent&) e;
|
||||
|
||||
for(auto o : jObject.objectMap) {
|
||||
if(o.second != nullptr) {
|
||||
o.second->scaleRel(1.0f / (float)event.height);
|
||||
}
|
||||
}
|
||||
camera.setPerspective(glm::perspective(glm::radians(45.0f), (float)event.width/(float)event.height, 0.1f, 100.0f));
|
||||
|
||||
} else if(type == app->getEventType(Archimedes::KeyPressedWindowEvent()) && !io.WantCaptureKeyboard) {
|
||||
|
||||
return false;
|
||||
|
||||
@@ -211,7 +211,9 @@ Archimedes::Body readOBJ(std::string path, Archimedes::Shader shader) {
|
||||
return Archimedes::Body(
|
||||
Archimedes::VertexBuffer(verticies),
|
||||
Archimedes::IndexArray(indicies),
|
||||
Archimedes::VertexLayout(),
|
||||
Archimedes::VertexLayout({
|
||||
Archimedes::LayoutElement(Archimedes::LayoutElement::Type::Float, 3, 3 * sizeof(float), 0),
|
||||
}),
|
||||
shader
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user