Browse Source

Fix building

master
JavaProphet 5 years ago
parent
commit
3f6c178db0
  1. 8
      Osmium/.gitignore
  2. 3
      Osmium/DebugLinux/.gitignore
  3. 1
      Osmium/DebugLinux/assets/README
  4. 8
      Osmium/DebugLinux/shaders/ftextures.glsl
  5. 9
      Osmium/DebugLinux/shaders/vtextures.glsl
  6. 28
      Osmium/DebugLinux/src/block.d
  7. 8
      Osmium/DebugLinux/src/bmodel.d
  8. 23
      Osmium/DebugLinux/src/entity.d
  9. 25
      Osmium/DebugLinux/src/gui.d
  10. 28
      Osmium/DebugLinux/src/ingame.d
  11. 28
      Osmium/DebugLinux/src/inventory.d
  12. 5
      Osmium/DebugLinux/src/json.d
  13. 28
      Osmium/DebugLinux/src/main.d
  14. 23
      Osmium/DebugLinux/src/models.d
  15. 3
      Osmium/DebugLinux/src/nbt.d
  16. 8
      Osmium/DebugLinux/src/network.d
  17. 4
      Osmium/DebugWindows/.gitignore
  18. BIN
      Osmium/DebugWindows/OsmiumWindows_x86.zip
  19. 9
      Osmium/src/block.c
  20. 2
      Osmium/src/block.h
  21. 2
      Osmium/src/gui.c
  22. 26
      Osmium/src/ingame.c
  23. 3
      Osmium/src/main.c
  24. 1005
      Osmium/src/models.c
  25. 2
      Osmium/src/models.h
  26. 44
      Osmium/src/network.c
  27. 8
      Osmium/src/network.h
  28. 25
      Osmium/src/render.c
  29. 2
      Osmium/src/render.h

8
Osmium/.gitignore

@ -1,8 +0,0 @@
*.[do]
*.exe
*.dll
/DebugWindows/Osmium
/DebugLinux/Osmium
/DebugLinux/assets
/DebugWindows/assets
/DebugLinux/

3
Osmium/DebugLinux/.gitignore

@ -0,0 +1,3 @@
assets/minecraft
Osmium
src/*.o

1
Osmium/DebugLinux/assets/README

@ -0,0 +1 @@
Fill this with the assets folder from a 1.9 Mojang Minecraft jar file.

8
Osmium/DebugLinux/shaders/ftextures.glsl

@ -0,0 +1,8 @@
#version 430 core
out vec4 color;
in vec2 uv;
in int l2;
layout (binding=0) uniform sampler2DArray textureArray;
void main(void) {
color = texture(textureArray, vec3(uv.x,uv.y,l2) );
}

9
Osmium/DebugLinux/shaders/vtextures.glsl

@ -0,0 +1,9 @@
#version 430 core
attribute vec2 texCoord;
out vec2 uv;
attribute int layer;
out int l2;
void main(void) {
uv = texCoord;
l2 = layer;
}

28
Osmium/DebugLinux/src/block.d

@ -0,0 +1,28 @@
src/block.d: ../src/block.c ../src/world.h ../src/entity.h \
../src/render.h ../src/models.h ../src/network.h ../src/nbt.h \
../src/inventory.h ../src/block.h ../src/globals.h ../src/bmodel.h \
../src/xstring.h ../src/ingame.h
../src/world.h:
../src/entity.h:
../src/render.h:
../src/models.h:
../src/network.h:
../src/nbt.h:
../src/inventory.h:
../src/block.h:
../src/globals.h:
../src/bmodel.h:
../src/xstring.h:
../src/ingame.h:

8
Osmium/DebugLinux/src/bmodel.d

@ -0,0 +1,8 @@
src/bmodel.d: ../src/bmodel.c ../src/bmodel.h ../src/json.h \
../src/xstring.h
../src/bmodel.h:
../src/json.h:
../src/xstring.h:

23
Osmium/DebugLinux/src/entity.d

@ -0,0 +1,23 @@
src/entity.d: ../src/entity.c ../src/entity.h ../src/world.h \
../src/render.h ../src/models.h ../src/network.h ../src/nbt.h \
../src/inventory.h ../src/globals.h ../src/bmodel.h ../src/ingame.h
../src/entity.h:
../src/world.h:
../src/render.h:
../src/models.h:
../src/network.h:
../src/nbt.h:
../src/inventory.h:
../src/globals.h:
../src/bmodel.h:
../src/ingame.h:

25
Osmium/DebugLinux/src/gui.d

@ -0,0 +1,25 @@
src/gui.d: ../src/gui.c ../src/gui.h ../src/render.h ../src/models.h \
../src/world.h ../src/entity.h ../src/network.h ../src/nbt.h \
../src/inventory.h ../src/globals.h ../src/bmodel.h ../src/ingame.h
../src/gui.h:
../src/render.h:
../src/models.h:
../src/world.h:
../src/entity.h:
../src/network.h:
../src/nbt.h:
../src/inventory.h:
../src/globals.h:
../src/bmodel.h:
../src/ingame.h:

28
Osmium/DebugLinux/src/ingame.d

@ -0,0 +1,28 @@
src/ingame.d: ../src/ingame.c ../src/ingame.h ../src/network.h \
../src/nbt.h ../src/inventory.h ../src/world.h ../src/entity.h \
../src/render.h ../src/models.h ../src/globals.h ../src/bmodel.h \
../src/gui.h ../src/block.h
../src/ingame.h:
../src/network.h:
../src/nbt.h:
../src/inventory.h:
../src/world.h:
../src/entity.h:
../src/render.h:
../src/models.h:
../src/globals.h:
../src/bmodel.h:
../src/gui.h:
../src/block.h:

28
Osmium/DebugLinux/src/inventory.d

@ -0,0 +1,28 @@
src/inventory.d: ../src/inventory.c ../src/inventory.h ../src/nbt.h \
../src/globals.h ../src/bmodel.h ../src/models.h ../src/render.h \
../src/world.h ../src/entity.h ../src/network.h ../src/gui.h \
../src/item.h ../src/ingame.h
../src/inventory.h:
../src/nbt.h:
../src/globals.h:
../src/bmodel.h:
../src/models.h:
../src/render.h:
../src/world.h:
../src/entity.h:
../src/network.h:
../src/gui.h:
../src/item.h:
../src/ingame.h:

5
Osmium/DebugLinux/src/json.d

@ -0,0 +1,5 @@
src/json.d: ../src/json.c ../src/xstring.h ../src/json.h
../src/xstring.h:
../src/json.h:

28
Osmium/DebugLinux/src/main.d

@ -0,0 +1,28 @@
src/main.d: ../src/main.c ../src/gui.h ../src/globals.h ../src/bmodel.h \
../src/entity.h ../src/world.h ../src/render.h ../src/models.h \
../src/network.h ../src/nbt.h ../src/inventory.h ../src/ingame.h \
../src/block.h
../src/gui.h:
../src/globals.h:
../src/bmodel.h:
../src/entity.h:
../src/world.h:
../src/render.h:
../src/models.h:
../src/network.h:
../src/nbt.h:
../src/inventory.h:
../src/ingame.h:
../src/block.h:

23
Osmium/DebugLinux/src/models.d

@ -0,0 +1,23 @@
src/models.d: ../src/models.c ../src/models.h ../src/render.h \
../src/world.h ../src/entity.h ../src/network.h ../src/nbt.h \
../src/inventory.h ../src/xstring.h ../src/globals.h ../src/bmodel.h
../src/models.h:
../src/render.h:
../src/world.h:
../src/entity.h:
../src/network.h:
../src/nbt.h:
../src/inventory.h:
../src/xstring.h:
../src/globals.h:
../src/bmodel.h:

3
Osmium/DebugLinux/src/nbt.d

@ -0,0 +1,3 @@
src/nbt.d: ../src/nbt.c ../src/nbt.h
../src/nbt.h:

8
Osmium/DebugLinux/src/network.d

@ -0,0 +1,8 @@
src/network.d: ../src/network.c ../src/network.h ../src/nbt.h \
../src/inventory.h
../src/network.h:
../src/nbt.h:
../src/inventory.h:

4
Osmium/DebugWindows/.gitignore

@ -0,0 +1,4 @@
libpng15-15.dll
libwinpthread-1.dll
Osmium
src/*.o

BIN
Osmium/DebugWindows/OsmiumWindows_x86.zip

9
Osmium/src/block.c

@ -25,7 +25,7 @@ void getTextureCoordinates(int tx, int ty, float* tx1, float* ty1, float* tx2, f
*ty2 = th * (ty + 1) - ((float) TEXTURE_BUFFER + 0.01) / (float) def_height;
}
void drawBlock(struct vertex_tex** vex, size_t* vexs, size_t* cvec, block blk, unsigned char faceMask, float x, float y, float z, int32_t wx, int32_t wy, int32_t wz) {
void drawBlock(uint16_t** txd, size_t* txs, size_t* txc, struct vertex_tex** vex, size_t* vexs, size_t* cvec, block blk, unsigned char faceMask, float x, float y, float z, int32_t wx, int32_t wy, int32_t wz) {
unsigned char fc = 0;
if (faceMask & 0x01) fc++;
if (faceMask & 0x02) fc++;
@ -33,6 +33,13 @@ void drawBlock(struct vertex_tex** vex, size_t* vexs, size_t* cvec, block blk, u
if (faceMask & 0x08) fc++;
if (faceMask & 0x10) fc++;
if (faceMask & 0x20) fc++;
if (*txc - *txs <= fc) {
*txc += 512;
*txd = realloc(*txd, *txc * sizeof(uint16_t));
}
for (int i = 0; i < fc; i++) {
(*txd)[(*txs)++] = 1;
}
goto pimpl;
unimpl: ;
{

2
Osmium/src/block.h

@ -407,7 +407,7 @@
void loadBlocks();
void drawBlock(struct vertex_tex** vex, size_t* vexs, size_t* cvec, block block, unsigned char faceMask, float x, float y, float z, int32_t wx, int32_t wy, int32_t wz);
void drawBlock(uint16_t** txd, size_t* txs, size_t* txc, struct vertex_tex** vex, size_t* vexs, size_t* cvec, block blk, unsigned char faceMask, float x, float y, float z, int32_t wx, int32_t wy, int32_t wz);
int isBlockOpaque(block block);

2
Osmium/src/gui.c

@ -78,7 +78,7 @@ void loadGUI() {
virtTexCoord2f(&vt[2], 1., 1.);
virtVertex3f(&vt[3], -1., 1., 1.);
virtTexCoord2f(&vt[3], 0., 1.);
createVAO(vt, 4, &mod_pan, 1, 0, 4);
createVAO(vt, 4, &mod_pan, 1, 0, 0);
for (int32_t i = 0; i < 32; i++) {
int32_t v6 = (i >> 3 & 1) * 85;
int32_t v7 = (i >> 2 & 1) * 170 + v6;

26
Osmium/src/ingame.c

@ -38,7 +38,7 @@ void loadIngame() {
virtVertex3f(&vts[vi++], x1, 16., x2 + 64.);
}
}
createVAO(vts, 676, &skybox, 0, 0, 4);
createVAO(vts, 676, &skybox, 0, 0, 0);
gs.playerinv = malloc(sizeof(struct inventory));
newInventory(gs.playerinv, INVTYPE_PLAYERINVENTORY, 0);
gs.playerinv->slot_count = 46;
@ -500,12 +500,12 @@ void ingame_tick() {
}
struct packet pkt;
pkt.id = PKT_PLAY_CLIENT_PLAYERPOSLOOK;
pkt.data.play_client.playerposlook.x = gs.player->x;
pkt.data.play_client.playerposlook.y = gs.player->y;
pkt.data.play_client.playerposlook.z = gs.player->z;
pkt.data.play_client.playerposlook.yaw = gs.player->yaw;
pkt.data.play_client.playerposlook.pitch = gs.player->pitch;
pkt.data.play_client.playerposlook.onGround = gs.player->onGround;
pkt.data.play_client.playerpositionandlook.x = gs.player->x;
pkt.data.play_client.playerpositionandlook.y = gs.player->y;
pkt.data.play_client.playerpositionandlook.z = gs.player->z;
pkt.data.play_client.playerpositionandlook.yaw = gs.player->yaw;
pkt.data.play_client.playerpositionandlook.pitch = gs.player->pitch;
pkt.data.play_client.playerpositionandlook.onGround = gs.player->onGround;
if (writePacket(gs.conn, &pkt) != 0) {
printf("Failed to write packet: %s\n", strerror(errno));
}
@ -1204,18 +1204,18 @@ void runNetwork(struct conn* conn) {
} else if (pkt.id == PKT_PLAY_SERVER_PLAYERLISTITEM) {
} else if (pkt.id == PKT_PLAY_SERVER_PLAYERPOSLOOK) {
gs.player->x = ((pkt.data.play_server.playerposlook.flags & 0x01) == 0x01 ? gs.player->x : 0.) + pkt.data.play_server.playerposlook.x;
gs.player->y = ((pkt.data.play_server.playerposlook.flags & 0x02) == 0x02 ? gs.player->y : 0.) + pkt.data.play_server.playerposlook.y;
gs.player->z = ((pkt.data.play_server.playerposlook.flags & 0x04) == 0x04 ? gs.player->z : 0.) + pkt.data.play_server.playerposlook.z;
gs.player->x = ((pkt.data.play_server.playerpositionandlook.flags & 0x01) == 0x01 ? gs.player->x : 0.) + pkt.data.play_server.playerpositionandlook.x;
gs.player->y = ((pkt.data.play_server.playerpositionandlook.flags & 0x02) == 0x02 ? gs.player->y : 0.) + pkt.data.play_server.playerpositionandlook.y;
gs.player->z = ((pkt.data.play_server.playerpositionandlook.flags & 0x04) == 0x04 ? gs.player->z : 0.) + pkt.data.play_server.playerpositionandlook.z;
gs.player->lx = gs.player->x;
gs.player->ly = gs.player->y;
gs.player->lz = gs.player->z;
gs.player->pitch = ((pkt.data.play_server.playerposlook.flags & 0x08) == 0x08 ? gs.player->pitch : 0.) + pkt.data.play_server.playerposlook.y;
gs.player->yaw = ((pkt.data.play_server.playerposlook.flags & 0x10) == 0x10 ? gs.player->yaw : 0.) + pkt.data.play_server.playerposlook.z;
gs.player->pitch = ((pkt.data.play_server.playerpositionandlook.flags & 0x08) == 0x08 ? gs.player->pitch : 0.) + pkt.data.play_server.playerpositionandlook.y;
gs.player->yaw = ((pkt.data.play_server.playerpositionandlook.flags & 0x10) == 0x10 ? gs.player->yaw : 0.) + pkt.data.play_server.playerpositionandlook.z;
gs.player->health = 20.;
printf("spawned in at: %f, %f, %f\n", gs.player->x, gs.player->y, gs.player->z);
rpkt.id = PKT_PLAY_CLIENT_TELEPORTCONFIRM;
rpkt.data.play_client.teleportconfirm.teleportID = pkt.data.play_server.playerposlook.teleportID;
rpkt.data.play_client.teleportconfirm.teleportID = pkt.data.play_server.playerpositionandlook.teleportID;
writePacket(conn, &rpkt);
running = 1;
spawnedIn = 1;

3
Osmium/src/main.c

@ -699,7 +699,8 @@ int main(int argc, char *argv[]) {
blockMap[408] = "door_dark_oak_lower.png";
blockMap[409] = "glass_blue.png";
blockSizeMap = malloc(blockMapLength * sizeof(int));
loadTexturesPNG(INSTALLDIR "assets/minecraft/textures/blocks/", def_wrap, &def_width, &def_height, TX_DEFAULT, 1, blockMap, 410, blockSizeMap);
//&def_width, &def_height
loadTexturesPNG2(INSTALLDIR "assets/minecraft/textures/blocks/", def_wrap, TX_DEFAULT, 1, blockMap, 410, blockSizeMap);
clock_gettime(CLOCK_MONOTONIC, &ts);
lt = (double) ts.tv_sec * 1000. + (double) ts.tv_nsec / 1000000.;
lf = lt;

1005
Osmium/src/models.c
File diff suppressed because it is too large
View File

2
Osmium/src/models.h

@ -631,4 +631,6 @@ int loadTexturesPNG(char* path, int wrap, int* w, int* h, int id, int s, char**
void loadTextureData(int id, size_t width, size_t height, void* data, int s);
int loadTexturesPNG2(char* path, int wrap, int id, int s, char** map, int maps, int* smap);
#endif /* MODELS_H_ */

44
Osmium/src/network.c

@ -1956,30 +1956,30 @@ int readPacket(struct conn* conn, struct packet* packet) {
free(pktbuf);
return -1;
}
memcpy(&packet->data.play_server.playerposlook.x, pbuf, sizeof(double));
memcpy(&packet->data.play_server.playerpositionandlook.x, pbuf, sizeof(double));
pbuf += sizeof(double);
ps -= sizeof(double);
swapEndian(&packet->data.play_server.playerposlook.x, 8);
memcpy(&packet->data.play_server.playerposlook.y, pbuf, sizeof(double));
swapEndian(&packet->data.play_server.playerpositionandlook.x, 8);
memcpy(&packet->data.play_server.playerpositionandlook.y, pbuf, sizeof(double));
pbuf += sizeof(double);
ps -= sizeof(double);
swapEndian(&packet->data.play_server.playerposlook.y, 8);
memcpy(&packet->data.play_server.playerposlook.z, pbuf, sizeof(double));
swapEndian(&packet->data.play_server.playerpositionandlook.y, 8);
memcpy(&packet->data.play_server.playerpositionandlook.z, pbuf, sizeof(double));
pbuf += sizeof(double);
ps -= sizeof(double);
swapEndian(&packet->data.play_server.playerposlook.z, 8);
memcpy(&packet->data.play_server.playerposlook.yaw, pbuf, sizeof(float));
swapEndian(&packet->data.play_server.playerpositionandlook.z, 8);
memcpy(&packet->data.play_server.playerpositionandlook.yaw, pbuf, sizeof(float));
pbuf += sizeof(float);
ps -= sizeof(float);
swapEndian(&packet->data.play_server.playerposlook.yaw, 4);
memcpy(&packet->data.play_server.playerposlook.pitch, pbuf, sizeof(float));
swapEndian(&packet->data.play_server.playerpositionandlook.yaw, 4);
memcpy(&packet->data.play_server.playerpositionandlook.pitch, pbuf, sizeof(float));
pbuf += sizeof(float);
ps -= sizeof(float);
swapEndian(&packet->data.play_server.playerposlook.pitch, 4);
packet->data.play_server.playerposlook.flags = pbuf[0];
swapEndian(&packet->data.play_server.playerpositionandlook.pitch, 4);
packet->data.play_server.playerpositionandlook.flags = pbuf[0];
pbuf++;
ps--;
int rx = readVarInt(&packet->data.play_server.playerposlook.teleportID, pbuf, ps);
int rx = readVarInt(&packet->data.play_server.playerpositionandlook.teleportID, pbuf, ps);
pbuf += rx;
ps -= rx;
} else if (id == PKT_PLAY_SERVER_USEBED) {
@ -2721,34 +2721,34 @@ int writePacket(struct conn* conn, struct packet* packet) {
} else if (packet->id == PKT_PLAY_CLIENT_KEEPALIVE) {
pi += writeVarInt(packet->data.play_client.keepalive.key, pktbuf + pi);
} else if (packet->id == PKT_PLAY_CLIENT_PLAYERPOS) {
memcpy(pktbuf + pi, &packet->data.play_client.playerpos.x, sizeof(double));
memcpy(pktbuf + pi, &packet->data.play_client.playerposition.x, sizeof(double));
swapEndian(pktbuf + pi, 8);
pi += sizeof(double);
memcpy(pktbuf + pi, &packet->data.play_client.playerpos.y, sizeof(double));
memcpy(pktbuf + pi, &packet->data.play_client.playerposition.y, sizeof(double));
swapEndian(pktbuf + pi, 8);
pi += sizeof(double);
memcpy(pktbuf + pi, &packet->data.play_client.playerpos.z, sizeof(double));
memcpy(pktbuf + pi, &packet->data.play_client.playerposition.z, sizeof(double));
swapEndian(pktbuf + pi, 8);
pi += sizeof(double);
memcpy(pktbuf + pi, &packet->data.play_client.playerpos.onGround, 1);
memcpy(pktbuf + pi, &packet->data.play_client.playerposition.onGround, 1);
pi++;
} else if (packet->id == PKT_PLAY_CLIENT_PLAYERPOSLOOK) {
memcpy(pktbuf + pi, &packet->data.play_client.playerposlook.x, sizeof(double));
memcpy(pktbuf + pi, &packet->data.play_client.playerpositionandlook.x, sizeof(double));
swapEndian(pktbuf + pi, 8);
pi += sizeof(double);
memcpy(pktbuf + pi, &packet->data.play_client.playerposlook.y, sizeof(double));
memcpy(pktbuf + pi, &packet->data.play_client.playerpositionandlook.y, sizeof(double));
swapEndian(pktbuf + pi, 8);
pi += sizeof(double);
memcpy(pktbuf + pi, &packet->data.play_client.playerposlook.z, sizeof(double));
memcpy(pktbuf + pi, &packet->data.play_client.playerpositionandlook.z, sizeof(double));
swapEndian(pktbuf + pi, 8);
pi += sizeof(double);
memcpy(pktbuf + pi, &packet->data.play_client.playerposlook.yaw, sizeof(float));
memcpy(pktbuf + pi, &packet->data.play_client.playerpositionandlook.yaw, sizeof(float));
swapEndian(pktbuf + pi, 4);
pi += sizeof(float);
memcpy(pktbuf + pi, &packet->data.play_client.playerposlook.pitch, sizeof(float));
memcpy(pktbuf + pi, &packet->data.play_client.playerpositionandlook.pitch, sizeof(float));
swapEndian(pktbuf + pi, 4);
pi += sizeof(float);
memcpy(pktbuf + pi, &packet->data.play_client.playerposlook.onGround, 1);
memcpy(pktbuf + pi, &packet->data.play_client.playerpositionandlook.onGround, 1);
pi++;
} else if (packet->id == PKT_PLAY_CLIENT_PLAYERLOOK) {
memcpy(pktbuf + pi, &packet->data.play_client.playerlook.yaw, sizeof(float));

8
Osmium/src/network.h

@ -787,7 +787,7 @@ struct pkt_play_server_playerlistitem {
struct li_player* players;
};
struct pkt_play_server_playerposlook {
struct pkt_play_server_playerpositionandlook {
double x;
double y;
double z;
@ -1056,8 +1056,8 @@ union pkt_state_play_client {
struct pkt_play_client_pluginmessage pluginmessage;
struct pkt_play_client_useentity useentity;
struct pkt_play_client_keepalive keepalive;
struct pkt_play_client_playerpos playerpos;
struct pkt_play_client_playerposlook playerposlook;
struct pkt_play_client_playerpos playerposition;
struct pkt_play_client_playerposlook playerpositionandlook;
struct pkt_play_client_playerlook playerlook;
struct pkt_play_client_player player;
struct pkt_play_client_vehiclemove vehiclemove;
@ -1122,7 +1122,7 @@ union pkt_state_play_server {
struct pkt_play_server_playerabilities playerabilities;
struct pkt_play_server_combatevent combatevent;
struct pkt_play_server_playerlistitem playerlistitem;
struct pkt_play_server_playerposlook playerposlook;
struct pkt_play_server_playerpositionandlook playerpositionandlook;
struct pkt_play_server_usebed usebed;
struct pkt_play_server_destroyentities destroyentities;
struct pkt_play_server_removeentityeffect removeentityeffect;

25
Osmium/src/render.c

@ -33,7 +33,7 @@ void virtTexCoord2f(struct vertex_tex* vert, float x, float y) {
vert->texY = y;
}
void createVAO(struct vertex* verticies, size_t count, struct vao* vao, int textures, int overwrite, uint16_t restart) {
void createVAO(struct vertex* verticies, size_t count, struct vao* vao, int textures, int overwrite, int vattrib) {
if (!overwrite) glGenVertexArrays(1, &vao->vao);
glBindVertexArray(vao->vao);
if (!overwrite) {
@ -55,10 +55,12 @@ void createVAO(struct vertex* verticies, size_t count, struct vao* vao, int text
//}
}
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint16_t) * vao->index_count, indicies, GL_STATIC_DRAW);
glVertexPointer(3, GL_FLOAT, textures ? sizeof(struct vertex_tex) : sizeof(struct vertex), 0);
if (textures) glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex_tex), (void*) (sizeof(struct vertex)));
size_t rz = vattrib ? ((vattrib == GL_BYTE || vattrib == GL_UNSIGNED_BYTE) ? 1 : ((vattrib == GL_SHORT || vattrib == GL_UNSIGNED_SHORT) ? 2 : 4)) : 0;
glVertexPointer(3, GL_FLOAT, (textures ? sizeof(struct vertex_tex) : sizeof(struct vertex)) + rz, 0);
if (textures) glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex_tex) + rz, (void*) (sizeof(struct vertex)));
glEnableClientState (GL_VERTEX_ARRAY);
if (textures) glEnableClientState (GL_TEXTURE_COORD_ARRAY);
if (vattrib) glVertexAttribIPointer(0, 1, vattrib, (textures ? sizeof(struct vertex_tex) : sizeof(struct vertex)) + rz, (void*) (sizeof(struct vertex_tex)));
glBindVertexArray(0);
vao->tex = textures;
}
@ -150,7 +152,7 @@ void createMultSubCube(float size, struct vertex_tex* vrt, float x, float y, flo
void createTexCube(float size, struct vao* vao) {
struct vertex_tex vrt[24];
createSubCube(size, vrt, 0xFF, 0., 0., 0., 0., 0., 1., 1.);
createVAO(vrt, 24, vao, 1, 0, 4);
createVAO(vrt, 24, vao, 1, 0, 0);
}
void drawSkeleton(struct vao* vao) {
@ -179,6 +181,9 @@ int updateChunk(struct chunk* chunk) {
struct vertex_tex* vts = malloc(2048 * 4 * 6 * sizeof(struct vertex_tex));
size_t vtsx = 2048 * 4 * 6 * sizeof(struct vertex_tex);
size_t cvts = 0;
uint16_t* txd = malloc(512 * sizeof(uint16_t));
size_t txs = 0;
size_t txc = 512;
//struct vertex_tex* tvts = malloc(2048 * 4 * 6 * sizeof(struct vertex_tex));
//size_t tvtsx = 2048 * 4 * 6 * sizeof(struct vertex_tex);
//size_t tcvts = 0;
@ -211,7 +216,7 @@ int updateChunk(struct chunk* chunk) {
} else if (z == 15 && chzp != NULL && isBlockOpaque(chzp->blocks[x][0][y + sy])) fm ^= 0x01;
if (fm > 0) drawBlock(&vts, &vtsx, &cvts, blk, fm, (float) x, (float) sy, (float) z, chunk->x << 4 | x, y + sy, chunk->z << 4 | z);
} else {
drawBlock(&vts, &vtsx, &cvts, blk, 0xFF, (float) x, (float) sy, (float) z, chunk->x << 4 | x, y + sy, chunk->z << 4 | z);
drawBlock(&txd, &txs, &txc, &vts, &vtsx, &cvts, blk, 0xFF, (float) x, (float) sy, (float) z, chunk->x << 4 | x, y + sy, chunk->z << 4 | z);
}
}
}
@ -220,9 +225,12 @@ int updateChunk(struct chunk* chunk) {
//clock_gettime(CLOCK_MONOTONIC, &ts);
//ms2 = ((double) ts.tv_sec * 1000. + (double) ts.tv_nsec / 1000000.) - ms2;
//printf("chunk took: %f opaq = %i/4096\n", ms2, opaw);
glBindTexture(GL_TEXTURE_BUFFER, chunk->tbufs[i]);
glTexBuffer(GL_TEXTURE_BUFFER, GL_RG8UI, chunk->tbufs[i]);
glTexImage1D(GL_TEXTURE_BUFFER, 0, GL_RG8UI, txs, 0, GL_RG8UI, GL_UNSIGNED_BYTE, txd);
if (cvts > 0) {
//printf("pic (opaque) = %i\n", cvts);
createVAO(vts, cvts, &chunk->vaos[i], 1, chunk->vaos[i].vao == -1 ? 0 : 1, 4);
createVAO(vts, cvts, &chunk->vaos[i], 1, chunk->vaos[i].vao == -1 ? 0 : 1, 0);
free(vts);
//if (chunk->calls[i] == -1) {
// chunk->calls[i] = glGenLists(1);
@ -302,6 +310,9 @@ void drawChunk(struct chunk* chunk, struct plane* planes) {
glTranslatef(0., 16. * ltc, 0.);
ltc = 0.;
}
glBindTexture(GL_TEXTURE_BUFFER, chunk->tbufs[i]);
glTexBuffer(GL_TEXTURE_BUFFER, GL_RG8UI, chunk->tbufs[i]);
if (chunk->vaos[i].vao >= 0) {
drawQuads(&chunk->vaos[i]);
}
@ -433,7 +444,7 @@ void drawWorld(struct world* world) {
frust[FR_RIGHT].px = ncx + (xp[0] * wnear);
frust[FR_RIGHT].py = ncy + (xp[1] * wnear);
frust[FR_RIGHT].pz = ncz + (xp[2] * wnear);
glBindTexture(GL_TEXTURE_2D, TX_DEFAULT);
glBindTexture(GL_TEXTURE_2D_ARRAY, TX_DEFAULT);
for (size_t i = 0; i < world->chunk_count; i++) {
if (world->chunks[i] != NULL) {
if (world->chunks[i]->kill) {

2
Osmium/src/render.h

@ -169,7 +169,7 @@ void virtVertex3f(union uvertex* vert, float x, float y, float z);
void virtTexCoord2f(struct vertex_tex* vert, float x, float y);
void createVAO(struct vertex* verticies, size_t count, struct vao* vao, int textures, int overwrite, uint16_t restart);
void createVAO(struct vertex* verticies, size_t count, struct vao* vao, int textures, int overwrite, int vattrib);
void deleteVAO(struct vao* vao);

Loading…
Cancel
Save