Added ui3d shader
This commit is contained in:
parent
28d93ca39a
commit
11d00dbbf8
@ -110,6 +110,7 @@ void AssetsLoader::addDefaults(AssetsLoader& loader) {
|
|||||||
loader.add(ASSET_SHADER, resdir/path(SHADERS_FOLDER"/main"), "main");
|
loader.add(ASSET_SHADER, resdir/path(SHADERS_FOLDER"/main"), "main");
|
||||||
loader.add(ASSET_SHADER, resdir/path(SHADERS_FOLDER"/lines"), "lines");
|
loader.add(ASSET_SHADER, resdir/path(SHADERS_FOLDER"/lines"), "lines");
|
||||||
loader.add(ASSET_SHADER, resdir/path(SHADERS_FOLDER"/ui"), "ui");
|
loader.add(ASSET_SHADER, resdir/path(SHADERS_FOLDER"/ui"), "ui");
|
||||||
|
loader.add(ASSET_SHADER, resdir/path(SHADERS_FOLDER"/ui3d"), "ui3d");
|
||||||
loader.add(ASSET_SHADER, resdir/path(SHADERS_FOLDER"/background"), "background");
|
loader.add(ASSET_SHADER, resdir/path(SHADERS_FOLDER"/background"), "background");
|
||||||
loader.add(ASSET_SHADER, resdir/path(SHADERS_FOLDER"/skybox_gen"), "skybox_gen");
|
loader.add(ASSET_SHADER, resdir/path(SHADERS_FOLDER"/skybox_gen"), "skybox_gen");
|
||||||
|
|
||||||
|
|||||||
@ -4,10 +4,18 @@
|
|||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
#include "../typedefs.h"
|
||||||
|
|
||||||
#define VERTEX_SIZE 9
|
#define VERTEX_SIZE 9
|
||||||
|
|
||||||
Batch3D::Batch3D(size_t capacity) : capacity(capacity), offset(0), color(1.0f, 1.0f, 1.0f, 0.0f){
|
using glm::vec2;
|
||||||
|
using glm::vec3;
|
||||||
|
using glm::vec4;
|
||||||
|
|
||||||
|
Batch3D::Batch3D(size_t capacity)
|
||||||
|
: capacity(capacity),
|
||||||
|
offset(0),
|
||||||
|
color(1.0f, 1.0f, 1.0f, 1.0f) {
|
||||||
const vattr attrs[] = {
|
const vattr attrs[] = {
|
||||||
{3}, {2}, {4}, {0}
|
{3}, {2}, {4}, {0}
|
||||||
};
|
};
|
||||||
@ -16,8 +24,8 @@ Batch3D::Batch3D(size_t capacity) : capacity(capacity), offset(0), color(1.0f, 1
|
|||||||
mesh = new Mesh(buffer, 0, attrs);
|
mesh = new Mesh(buffer, 0, attrs);
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|
||||||
unsigned char pixels[] = {
|
ubyte pixels[] = {
|
||||||
255, 255, 255, 255,
|
255, 255, 255, 255,
|
||||||
};
|
};
|
||||||
blank = new Texture(pixels, 1, 1, GL_RGBA);
|
blank = new Texture(pixels, 1, 1, GL_RGBA);
|
||||||
_texture = nullptr;
|
_texture = nullptr;
|
||||||
@ -35,7 +43,7 @@ void Batch3D::begin(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Batch3D::vertex(float x, float y, float z, float u, float v,
|
void Batch3D::vertex(float x, float y, float z, float u, float v,
|
||||||
float r, float g, float b, float a) {
|
float r, float g, float b, float a) {
|
||||||
buffer[index++] = x;
|
buffer[index++] = x;
|
||||||
buffer[index++] = y;
|
buffer[index++] = y;
|
||||||
buffer[index++] = z;
|
buffer[index++] = z;
|
||||||
@ -47,8 +55,8 @@ void Batch3D::vertex(float x, float y, float z, float u, float v,
|
|||||||
buffer[index++] = a;
|
buffer[index++] = a;
|
||||||
}
|
}
|
||||||
void Batch3D::vertex(vec3 point,
|
void Batch3D::vertex(vec3 point,
|
||||||
vec2 uvpoint,
|
vec2 uvpoint,
|
||||||
float r, float g, float b, float a) {
|
float r, float g, float b, float a) {
|
||||||
buffer[index++] = point.x;
|
buffer[index++] = point.x;
|
||||||
buffer[index++] = point.y;
|
buffer[index++] = point.y;
|
||||||
buffer[index++] = point.z;
|
buffer[index++] = point.z;
|
||||||
@ -160,6 +168,6 @@ void Batch3D::sprite(vec3 pos, vec3 up, vec3 right, float w, float h, int atlasR
|
|||||||
|
|
||||||
void Batch3D::render() {
|
void Batch3D::render() {
|
||||||
mesh->reload(buffer, index / VERTEX_SIZE);
|
mesh->reload(buffer, index / VERTEX_SIZE);
|
||||||
mesh->draw(GL_TRIANGLES);
|
mesh->draw();
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,8 +4,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
using namespace glm;
|
|
||||||
|
|
||||||
class Mesh;
|
class Mesh;
|
||||||
class Texture;
|
class Texture;
|
||||||
|
|
||||||
@ -21,10 +19,10 @@ class Batch3D {
|
|||||||
Texture* _texture;
|
Texture* _texture;
|
||||||
|
|
||||||
void vertex(float x, float y, float z,
|
void vertex(float x, float y, float z,
|
||||||
float u, float v,
|
float u, float v,
|
||||||
float r, float g, float b, float a);
|
float r, float g, float b, float a);
|
||||||
void vertex(vec3 point, vec2 uvpoint,
|
void vertex(glm::vec3 point, glm::vec2 uvpoint,
|
||||||
float r, float g, float b, float a);
|
float r, float g, float b, float a);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Batch3D(size_t capacity);
|
Batch3D(size_t capacity);
|
||||||
@ -32,8 +30,9 @@ public:
|
|||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
void texture(Texture* texture);
|
void texture(Texture* texture);
|
||||||
void sprite(vec3 pos, vec3 up, vec3 right, float w, float h, int atlasRes, int index, vec4 tint);
|
void sprite(glm::vec3 pos, glm::vec3 up, glm::vec3 right, float w, float h,
|
||||||
void sprite(vec3 pos, vec3 up, vec3 right, float w, float h);
|
int atlasRes, int index, glm::vec4 tint);
|
||||||
|
void sprite(glm::vec3 pos, glm::vec3 up, glm::vec3 right, float w, float h);
|
||||||
void render();
|
void render();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -181,7 +181,6 @@ void PlayerController::updateControls(float delta){
|
|||||||
player->update(level, input, delta);
|
player->update(level, input, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
void PlayerController::updateInteraction(){
|
void PlayerController::updateInteraction(){
|
||||||
auto contentIds = level->content->indices;
|
auto contentIds = level->content->indices;
|
||||||
Chunks* chunks = level->chunks;
|
Chunks* chunks = level->chunks;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user