Skip to content

Commit

Permalink
rotating car, base dot product shading
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcypher89 committed Apr 27, 2024
1 parent 19a4ec9 commit 6e82fce
Show file tree
Hide file tree
Showing 11 changed files with 456 additions and 364 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/out/dbg/carcockpit",
"args": [],
"args": ["--window", "--res-path=res"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ else ifeq ($(os),linux)
this_ldflags += -rdynamic
endif

this_ldlibs += -lruisapp-opengles -lpapki -lclargs -ltml -lruis -lutki -lm
this_ldlibs += -lruisapp-opengles-xorg -lpapki -lclargs -ltml -lruis -lutki -lm -l ruis-render-opengles

$(eval $(prorab-build-app))

Expand Down
28 changes: 26 additions & 2 deletions src/car_view/model_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//
//-----------------------------------------------------------------------------

#include "model_obj.h"
#include "model_obj.hpp"
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <GLES2/gl2platform.h>
Expand Down Expand Up @@ -1291,6 +1291,30 @@ void ModelOBJ::buildShortIndexBuffer()
m_shortIndexBuffer.push_back(static_cast<uint16_t>(index));
}

void ModelOBJ::buildVBOs()
{
buildShortIndexBuffer();

GLuint vn = getNumberOfVertices();

positions.clear(); positions.reserve(vn);
textureCoords.clear(); textureCoords.reserve(vn);
normals.clear(); normals.reserve(vn);
tangents.clear(); tangents.reserve(vn);
bitangents.clear(); bitangents.reserve(vn);

for(uint32_t i = 0; i < vn; ++i)
{
const Vertex& v = m_vertexBuffer[i];

positions.push_back (ruis::vec4 {v.position[0], v.position[1], v.position[2], 1.0f});
textureCoords.push_back (ruis::vec2 {v.texCoord[0], v.texCoord[1]});
normals.push_back (ruis::vec3 {v.normal[0], v.normal[1], v.normal[2]});
tangents.push_back (ruis::vec4 {v.tangent[0], v.tangent[1], v.tangent[2], v.tangent[3]});
bitangents.push_back (ruis::vec4 {v.bitangent[0], v.bitangent[1], v.bitangent[2], 1.0f});
}
}

void ModelOBJ::createVBOs()
{
buildShortIndexBuffer(); // TODO: make it a non-kolkhoz fashion. OpenGLES 2 requires us to use 16-bit indices
Expand Down Expand Up @@ -1335,7 +1359,7 @@ void ModelOBJ::createVBOs()

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboHandles[1]);
//glBufferData(GL_ELEMENT_ARRAY_BUFFER, getNumberOfIndices() * sizeof(GLuint), getIndexBuffer(), GL_STATIC_DRAW);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, getNumberOfIndices() * sizeof(GLushort), getShortIndexBuffer(), GL_STATIC_DRAW);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, getNumberOfIndices() * sizeof(GLushort), getShortIndexBufferPtr(), GL_STATIC_DRAW);


//glBindVertexArray(0);
Expand Down
240 changes: 0 additions & 240 deletions src/car_view/model_obj.h

This file was deleted.

Loading

0 comments on commit 6e82fce

Please sign in to comment.