fix: remove alpha blending
This commit is contained in:
parent
1489671f24
commit
1cdce17eb9
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
build/
|
||||
.cache/
|
||||
compile_commands.json
|
||||
|
|
|
@ -19,7 +19,7 @@ class EngineObject {
|
|||
glm::vec4 scale;
|
||||
|
||||
std::vector<float> vertices;
|
||||
std::vector<uint16_t> indices;
|
||||
std::vector<unsigned int> indices;
|
||||
|
||||
bgfx::VertexLayout layout;
|
||||
bgfx::TextureHandle texture;
|
||||
|
|
1309064
models/dragon.obj
Normal file
1309064
models/dragon.obj
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -30,5 +30,5 @@ void main() {
|
|||
vec4 pos = view + u_position;
|
||||
|
||||
gl_Position = mul(u_proj, pos);
|
||||
f_position = r_position;
|
||||
f_position = a_position;
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ int Engine::Update(void) {
|
|||
BGFX_STATE_WRITE_G |
|
||||
BGFX_STATE_WRITE_B |
|
||||
BGFX_STATE_WRITE_A |
|
||||
BGFX_STATE_BLEND_ALPHA |
|
||||
BGFX_STATE_WRITE_Z |
|
||||
BGFX_STATE_DEPTH_TEST_LESS |
|
||||
BGFX_STATE_CULL_CCW );
|
||||
|
||||
|
@ -153,7 +153,7 @@ int Engine::Update(void) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void Engine::Shutdown(void) {
|
||||
void Engine::Shutdown(void) {
|
||||
for (int i = 0; i < this->objs.size(); i++) {
|
||||
EngineObject* obj = this->objs[i];
|
||||
bgfx::destroy(obj->vbh);
|
||||
|
|
|
@ -18,14 +18,6 @@ EngineObject::EngineObject() {
|
|||
}
|
||||
|
||||
int EngineObject::load_node(aiScene *scene, aiNode *node) {
|
||||
if (node == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (scene == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < scene->mNumMeshes; ++i) {
|
||||
aiMesh *mesh = scene->mMeshes[i];
|
||||
for (unsigned int j = 0; j < mesh->mNumVertices; ++j) {
|
||||
|
@ -47,12 +39,6 @@ int EngineObject::load_node(aiScene *scene, aiNode *node) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct vertex {
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
};
|
||||
|
||||
int EngineObject::load_model(std::string filename) {
|
||||
Assimp::Importer importer;
|
||||
aiScene *scene = (aiScene *) importer.ReadFile(filename, aiProcess_Triangulate | aiProcess_FlipUVs);
|
||||
|
@ -62,20 +48,12 @@ int EngineObject::load_model(std::string filename) {
|
|||
}
|
||||
|
||||
aiNode *root = scene->mRootNode;
|
||||
if (root == NULL) {
|
||||
std::cout << "--error: no model inside the loaded scene" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int ret = this->load_node(scene, root);
|
||||
if (ret < 0) {
|
||||
std::cout << "-error: failed loading node tree" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::cout << "--log: successfully loaded model (" << filename << ")" << std::endl;
|
||||
|
||||
this->vbh = bgfx::createVertexBuffer(bgfx::makeRef(
|
||||
this->vertices.data(),
|
||||
this->vertices.size()*sizeof(float)),
|
||||
|
@ -83,8 +61,8 @@ int EngineObject::load_model(std::string filename) {
|
|||
|
||||
this->ibh = bgfx::createIndexBuffer(bgfx::makeRef(
|
||||
this->indices.data(),
|
||||
this->indices.size()*sizeof(uint16_t))
|
||||
);
|
||||
this->indices.size()*sizeof(unsigned int)),
|
||||
BGFX_BUFFER_INDEX32);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
EngineObject obj;
|
||||
obj.load_model("models/cube.obj");
|
||||
obj.load_model("models/dragon.obj");
|
||||
obj.position.z = -30.0f;
|
||||
|
||||
engine.Instantiate(&obj);
|
||||
|
|
Loading…
Reference in New Issue
Block a user