mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
a bunch of junk, merging 'shitty' branch
This commit is contained in:
@@ -3,12 +3,45 @@
|
||||
//
|
||||
|
||||
#include "GL_Drawing.h"
|
||||
#include "../../../../MG_RHI/GLES/RHI.h"
|
||||
|
||||
namespace MG_GL::GL {
|
||||
// This is a test function that directly draws textures.
|
||||
void DrawElements(GLenum mode, GLsizei count, GLenum type, const void *indices) {
|
||||
::GLES::glViewport(0,0,3200,1440);
|
||||
MG_RHI::GLES::Test::DrawAllTextures();
|
||||
// ::GLES::glViewport(0,0,3200,1440);
|
||||
// MG_RHI::GLES::Test::DrawAllTextures();
|
||||
VertexArrayState* vaState = MG_State_T::vertexArrayState;
|
||||
VertexArrayObject* vao = &vaState->vaos_[vaState->currentVao_];
|
||||
|
||||
auto& rhi = MG_RHI::GLES::RHI::GetInstance();
|
||||
rhi.TransitionTo(MG_RHI::GLES::State::DrawElements);
|
||||
|
||||
if (vao->elementBuffer != 0 && indices != nullptr) {
|
||||
static GLuint dynamicIBO = 0;
|
||||
if (dynamicIBO == 0) {
|
||||
MGL_TRY(::GLES::glGenBuffers(1, &dynamicIBO);)
|
||||
}
|
||||
|
||||
size_t typeSize = 0;
|
||||
switch(type) {
|
||||
case GL_UNSIGNED_BYTE: typeSize = sizeof(GLubyte); break;
|
||||
case GL_UNSIGNED_SHORT: typeSize = sizeof(GLushort); break;
|
||||
case GL_UNSIGNED_INT: typeSize = sizeof(GLuint); break;
|
||||
}
|
||||
size_t dataSize = count * typeSize;
|
||||
|
||||
MGL_TRY(::GLES::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dynamicIBO);)
|
||||
MGL_TRY(::GLES::glBufferData(GL_ELEMENT_ARRAY_BUFFER, dataSize, indices, GL_STREAM_DRAW);)
|
||||
}
|
||||
|
||||
if (vao->elementBuffer != 0 || indices != nullptr) {
|
||||
MGL_TRY(::GLES::glDrawElements(
|
||||
mode,
|
||||
count,
|
||||
type,
|
||||
indices
|
||||
);)
|
||||
}
|
||||
};
|
||||
void DrawArrays(GLenum mode, GLint first, GLsizei count) {
|
||||
::GLES::glViewport(0,0,3200,1440);
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
void Delete(GLuint buffer);
|
||||
GLuint GetCurrentBinding(GLenum target) const;
|
||||
|
||||
private:
|
||||
public: // TODO
|
||||
std::unordered_map<GLuint, BufferObject> buffers_;
|
||||
std::set<GLuint> freeIds_;
|
||||
GLuint lastId_ = 0;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "../../../Includes.h"
|
||||
|
||||
class CommonState {
|
||||
private:
|
||||
public: // TODO
|
||||
// Pixel storage parameters
|
||||
std::unordered_map<GLenum, GLint> pixelStoreParams;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
GLenum glValidateCompleteness(GLenum target);
|
||||
FramebufferObject* GetCurrentFBO(GLenum target);
|
||||
|
||||
private:
|
||||
public: // TODO
|
||||
std::unordered_map<GLuint, FramebufferObject> framebuffers_;
|
||||
std::unordered_map<GLenum, GLuint> currentBindings_; // READ/DRAW/FRAMEBUFFER
|
||||
std::set<GLuint> freeIds_;
|
||||
|
||||
@@ -47,7 +47,7 @@ struct ProgramObject {
|
||||
};
|
||||
|
||||
class ProgramState {
|
||||
private:
|
||||
public: // TODO
|
||||
std::unordered_map<GLuint, ShaderObject> shaders_;
|
||||
std::unordered_map<GLuint, ProgramObject> programs_;
|
||||
std::set<GLuint> freeShaderIds_;
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
};
|
||||
|
||||
class TextureState {
|
||||
private:
|
||||
public: // TODO
|
||||
std::vector<TextureUnitState> textureUnits_;
|
||||
GLuint activeTextureUnit_ = 0;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ GLenum VertexArrayState::Create(GLuint* array) {
|
||||
}
|
||||
|
||||
*array = id;
|
||||
vaos_[id].generated = true;
|
||||
// vaos_[id].generated = true;
|
||||
return GL_NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -41,8 +41,9 @@ GLenum VertexArrayState::CreateN(GLsizei n, GLuint* arrays) {
|
||||
}
|
||||
|
||||
GLenum VertexArrayState::Bind(GLuint array) {
|
||||
if (array != 0 && !vaos_.count(array)) return GL_INVALID_OPERATION;
|
||||
if (array != 0 && vaos_.find(array) == vaos_.end()) return GL_INVALID_OPERATION;
|
||||
currentVao_ = array;
|
||||
GetCurrentVAO()->generated = true;
|
||||
return GL_NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
GLuint GetBoundElementBuffer();
|
||||
VertexArrayObject* GetCurrentVAO();
|
||||
|
||||
private:
|
||||
public: // TODO
|
||||
std::unordered_map<GLuint, VertexArrayObject> vaos_;
|
||||
std::set<GLuint> freeIds_;
|
||||
GLuint lastId_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user