mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-22 16:03:31 +00:00
ADD: WebASM port (no sound/no network)
This commit is contained in:
@@ -79,6 +79,9 @@ RenderChunk Tesselator::end( bool useMine, int bufferId )
|
||||
const int o_vertices = vertices;
|
||||
|
||||
if (vertices > 0) {
|
||||
if (p <= 0 || p > maxVertices) { clear(); return RenderChunk(); }
|
||||
int bytes = p * sizeof(VERTEX);
|
||||
if (bytes <= 0) return RenderChunk();
|
||||
if (++vboId >= vboCounts)
|
||||
vboId = 0;
|
||||
|
||||
@@ -92,11 +95,11 @@ RenderChunk Tesselator::end( bool useMine, int bufferId )
|
||||
bufferId = vboIds[vboId];
|
||||
#endif
|
||||
int access = GL_STATIC_DRAW;//(accessMode==ACCESS_DYNAMIC) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW;
|
||||
int bytes = p * sizeof(VERTEX);
|
||||
glBindBuffer2(GL_ARRAY_BUFFER, bufferId);
|
||||
glBufferData2(GL_ARRAY_BUFFER, bytes, _varray, access); // GL_STREAM_DRAW
|
||||
|
||||
totalSize += bytes;
|
||||
|
||||
|
||||
#ifndef USE_VBO
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// x y z u v c
|
||||
@@ -264,6 +267,7 @@ void Tesselator::vertex( float x, float y, float z )
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
const int offs = 3 - i;
|
||||
if (p - offs < 0 || p >= maxVertices) { clear(); return; }
|
||||
VERTEX& src = _varray[p - offs];
|
||||
VERTEX& dst = _varray[p];
|
||||
|
||||
@@ -287,6 +291,7 @@ void Tesselator::vertex( float x, float y, float z )
|
||||
}
|
||||
}
|
||||
|
||||
if (p < 0 || p >= maxVertices) { clear(); return; }
|
||||
VERTEX& vertex = _varray[p];
|
||||
|
||||
if (hasTexture) {
|
||||
@@ -377,13 +382,15 @@ void Tesselator::draw()
|
||||
tesselating = false;
|
||||
|
||||
if (vertices > 0) {
|
||||
if (p <= 0 || p > maxVertices) { clear(); return; }
|
||||
int bytes = p * sizeof(VERTEX);
|
||||
if (bytes <= 0) { clear(); return; }
|
||||
if (++vboId >= vboCounts)
|
||||
vboId = 0;
|
||||
|
||||
int bufferId = vboIds[vboId];
|
||||
|
||||
int access = GL_DYNAMIC_DRAW;//(accessMode==ACCESS_DYNAMIC) ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW;
|
||||
int bytes = p * sizeof(VERTEX);
|
||||
glBindBuffer2(GL_ARRAY_BUFFER, bufferId);
|
||||
glBufferData2(GL_ARRAY_BUFFER, bytes, _varray, access); // GL_STREAM_DRAW
|
||||
|
||||
|
||||
@@ -47,9 +47,13 @@ void glInit()
|
||||
}
|
||||
|
||||
void anGenBuffers(GLsizei n, GLuint* buffers) {
|
||||
static GLuint k = 1;
|
||||
for (int i = 0; i < n; ++i)
|
||||
buffers[i] = ++k;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
glGenBuffers(n, buffers);
|
||||
#else
|
||||
static GLuint k = 1;
|
||||
for (int i = 0; i < n; ++i)
|
||||
buffers[i] = ++k;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_VBO
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
#endif
|
||||
|
||||
// Other systems might run it, if they #define OPENGL_ES
|
||||
#if defined(OPENGL_ES) // || defined(ANDROID)
|
||||
// #if defined(OPENGL_ES) // || defined(ANDROID)
|
||||
#define USE_VBO
|
||||
#define GL_QUADS 0x0007
|
||||
#if defined(__APPLE__)
|
||||
#import <OpenGLES/ES1/gl.height>
|
||||
#import <OpenGLES/ES1/glext.height>
|
||||
#elif defined(ANDROID)
|
||||
#elif defined(ANDROID) || defined(__EMSCRIPTEN__)
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#else
|
||||
@@ -28,18 +28,18 @@
|
||||
#define glClearDepthf(x) glClearDepth(x)
|
||||
#define glDepthRangef(a,b) glDepthRange(a,b)
|
||||
#endif
|
||||
#else
|
||||
// Uglyness to fix redeclaration issues
|
||||
#ifdef WIN32
|
||||
#include <WinSock2.h>
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
#include <gl/glew.h>
|
||||
#include <gl/GL.h>
|
||||
// #else
|
||||
// // Uglyness to fix redeclaration issues
|
||||
// #ifdef WIN32
|
||||
// #include <WinSock2.h>
|
||||
// #include <Windows.h>
|
||||
// #endif
|
||||
// #include <gl/glew.h>
|
||||
// #include <gl/GL.h>
|
||||
|
||||
#define glFogx(a,b) glFogi(a,b)
|
||||
#define glOrthof(a,b,c,d,e,f) glOrtho(a,b,c,d,e,f)
|
||||
#endif
|
||||
// #define glFogx(a,b) glFogi(a,b)
|
||||
// #define glOrthof(a,b,c,d,e,f) glOrtho(a,b,c,d,e,f)
|
||||
// #endif
|
||||
|
||||
|
||||
#define GLERRDEBUG 1
|
||||
|
||||
Reference in New Issue
Block a user