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"/lines"), "lines");
|
||||
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"/skybox_gen"), "skybox_gen");
|
||||
|
||||
|
||||
@ -4,10 +4,18 @@
|
||||
#include "Texture.h"
|
||||
|
||||
#include <GL/glew.h>
|
||||
#include "../typedefs.h"
|
||||
|
||||
#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[] = {
|
||||
{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);
|
||||
index = 0;
|
||||
|
||||
unsigned char pixels[] = {
|
||||
255, 255, 255, 255,
|
||||
ubyte pixels[] = {
|
||||
255, 255, 255, 255,
|
||||
};
|
||||
blank = new Texture(pixels, 1, 1, GL_RGBA);
|
||||
_texture = nullptr;
|
||||
@ -35,7 +43,7 @@ void Batch3D::begin(){
|
||||
}
|
||||
|
||||
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++] = y;
|
||||
buffer[index++] = z;
|
||||
@ -47,8 +55,8 @@ void Batch3D::vertex(float x, float y, float z, float u, float v,
|
||||
buffer[index++] = a;
|
||||
}
|
||||
void Batch3D::vertex(vec3 point,
|
||||
vec2 uvpoint,
|
||||
float r, float g, float b, float a) {
|
||||
vec2 uvpoint,
|
||||
float r, float g, float b, float a) {
|
||||
buffer[index++] = point.x;
|
||||
buffer[index++] = point.y;
|
||||
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() {
|
||||
mesh->reload(buffer, index / VERTEX_SIZE);
|
||||
mesh->draw(GL_TRIANGLES);
|
||||
mesh->draw();
|
||||
index = 0;
|
||||
}
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
using namespace glm;
|
||||
|
||||
class Mesh;
|
||||
class Texture;
|
||||
|
||||
@ -21,10 +19,10 @@ class Batch3D {
|
||||
Texture* _texture;
|
||||
|
||||
void vertex(float x, float y, float z,
|
||||
float u, float v,
|
||||
float r, float g, float b, float a);
|
||||
void vertex(vec3 point, vec2 uvpoint,
|
||||
float r, float g, float b, float a);
|
||||
float u, float v,
|
||||
float r, float g, float b, float a);
|
||||
void vertex(glm::vec3 point, glm::vec2 uvpoint,
|
||||
float r, float g, float b, float a);
|
||||
|
||||
public:
|
||||
Batch3D(size_t capacity);
|
||||
@ -32,8 +30,9 @@ public:
|
||||
|
||||
void begin();
|
||||
void texture(Texture* texture);
|
||||
void sprite(vec3 pos, vec3 up, vec3 right, float w, float h, int atlasRes, int index, vec4 tint);
|
||||
void sprite(vec3 pos, vec3 up, vec3 right, float w, float h);
|
||||
void sprite(glm::vec3 pos, glm::vec3 up, glm::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();
|
||||
};
|
||||
|
||||
|
||||
@ -181,7 +181,6 @@ void PlayerController::updateControls(float delta){
|
||||
player->update(level, input, delta);
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
void PlayerController::updateInteraction(){
|
||||
auto contentIds = level->content->indices;
|
||||
Chunks* chunks = level->chunks;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user