mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 04:26:52 -04:00
Port particles to C.
This commit is contained in:
parent
7ce3bfae73
commit
9734be499e
@ -213,10 +213,8 @@
|
|||||||
<Compile Include="Network\Protocols\IProtocol.cs" />
|
<Compile Include="Network\Protocols\IProtocol.cs" />
|
||||||
<Compile Include="Network\Protocols\WoM.cs" />
|
<Compile Include="Network\Protocols\WoM.cs" />
|
||||||
<Compile Include="Network\Utils\PingList.cs" />
|
<Compile Include="Network\Utils\PingList.cs" />
|
||||||
<Compile Include="Particles\CollidableParticle.cs" />
|
|
||||||
<Compile Include="Particles\Particle.cs" />
|
<Compile Include="Particles\Particle.cs" />
|
||||||
<Compile Include="Particles\ParticleManager.cs" />
|
<Compile Include="Particles\ParticleManager.cs" />
|
||||||
<Compile Include="Particles\ParticleSpawner.cs" />
|
|
||||||
<Compile Include="Entities\Player.cs" />
|
<Compile Include="Entities\Player.cs" />
|
||||||
<Compile Include="Game\ChatLog.cs" />
|
<Compile Include="Game\ChatLog.cs" />
|
||||||
<Compile Include="Game\Game.cs" />
|
<Compile Include="Game\Game.cs" />
|
||||||
|
@ -215,6 +215,7 @@
|
|||||||
<ClInclude Include="Mouse.h" />
|
<ClInclude Include="Mouse.h" />
|
||||||
<ClInclude Include="NetworkEnums.h" />
|
<ClInclude Include="NetworkEnums.h" />
|
||||||
<ClInclude Include="Options.h" />
|
<ClInclude Include="Options.h" />
|
||||||
|
<ClInclude Include="Particle.h" />
|
||||||
<ClInclude Include="Physics.h" />
|
<ClInclude Include="Physics.h" />
|
||||||
<ClInclude Include="Picking.h" />
|
<ClInclude Include="Picking.h" />
|
||||||
<ClInclude Include="PickedPosRenderer.h" />
|
<ClInclude Include="PickedPosRenderer.h" />
|
||||||
@ -289,6 +290,7 @@
|
|||||||
<ClCompile Include="GraphicsCommon.c" />
|
<ClCompile Include="GraphicsCommon.c" />
|
||||||
<ClCompile Include="Matrix.c" />
|
<ClCompile Include="Matrix.c" />
|
||||||
<ClCompile Include="Noise.c" />
|
<ClCompile Include="Noise.c" />
|
||||||
|
<ClCompile Include="Particle.c" />
|
||||||
<ClCompile Include="Physics.c" />
|
<ClCompile Include="Physics.c" />
|
||||||
<ClCompile Include="PickedPosRenderer.c" />
|
<ClCompile Include="PickedPosRenderer.c" />
|
||||||
<ClCompile Include="Picking.c" />
|
<ClCompile Include="Picking.c" />
|
||||||
|
@ -357,6 +357,9 @@
|
|||||||
<ClInclude Include="Drawer2D.h">
|
<ClInclude Include="Drawer2D.h">
|
||||||
<Filter>Header Files\2D</Filter>
|
<Filter>Header Files\2D</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Particle.h">
|
||||||
|
<Filter>Header Files\Entities</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Noise.c">
|
<ClCompile Include="Noise.c">
|
||||||
@ -545,5 +548,8 @@
|
|||||||
<ClCompile Include="Drawer2D.c">
|
<ClCompile Include="Drawer2D.c">
|
||||||
<Filter>Source Files\2D</Filter>
|
<Filter>Source Files\2D</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Particle.c">
|
||||||
|
<Filter>Source Files\Entities</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -18,19 +18,6 @@ Int32 Drawer2D_BoxSize;
|
|||||||
#define DRAWER2D_LOG2_CHARS_PER_ROW 4
|
#define DRAWER2D_LOG2_CHARS_PER_ROW 4
|
||||||
Int32 Drawer2D_Widths[256];
|
Int32 Drawer2D_Widths[256];
|
||||||
|
|
||||||
void Drawer2D_FreeFontBitmap(void) {
|
|
||||||
if (Drawer2D_FontBitmap.Scan0 == NULL) return;
|
|
||||||
Platform_MemFree(Drawer2D_FontBitmap.Scan0);
|
|
||||||
Drawer2D_FontBitmap.Scan0 = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Drawer2D_SetFontBitmap(Bitmap bmp) {
|
|
||||||
Drawer2D_FreeFontBitmap();
|
|
||||||
Drawer2D_FontBitmap = bmp;
|
|
||||||
Drawer2D_BoxSize = bmp.Width >> DRAWER2D_LOG2_CHARS_PER_ROW;
|
|
||||||
Drawer2D_CalculateTextWidths();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Drawer2D_CalculateTextWidths(void) {
|
void Drawer2D_CalculateTextWidths(void) {
|
||||||
Int32 width = Drawer2D_FontBitmap.Width, height = Drawer2D_FontBitmap.Height;
|
Int32 width = Drawer2D_FontBitmap.Width, height = Drawer2D_FontBitmap.Height;
|
||||||
Int32 i;
|
Int32 i;
|
||||||
@ -61,6 +48,19 @@ void Drawer2D_CalculateTextWidths(void) {
|
|||||||
Drawer2D_Widths[' '] = Drawer2D_BoxSize / 4;
|
Drawer2D_Widths[' '] = Drawer2D_BoxSize / 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Drawer2D_FreeFontBitmap(void) {
|
||||||
|
if (Drawer2D_FontBitmap.Scan0 == NULL) return;
|
||||||
|
Platform_MemFree(Drawer2D_FontBitmap.Scan0);
|
||||||
|
Drawer2D_FontBitmap.Scan0 = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Drawer2D_SetFontBitmap(Bitmap bmp) {
|
||||||
|
Drawer2D_FreeFontBitmap();
|
||||||
|
Drawer2D_FontBitmap = bmp;
|
||||||
|
Drawer2D_BoxSize = bmp.Width >> DRAWER2D_LOG2_CHARS_PER_ROW;
|
||||||
|
Drawer2D_CalculateTextWidths();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Drawer2D_HexEncodedCol(Int32 i, Int32 hex, UInt8 lo, UInt8 hi) {
|
void Drawer2D_HexEncodedCol(Int32 i, Int32 hex, UInt8 lo, UInt8 hi) {
|
||||||
PackedCol* col = &Drawer2D_Cols[i];
|
PackedCol* col = &Drawer2D_Cols[i];
|
||||||
@ -78,11 +78,11 @@ void Drawer2D_Init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i <= 9; i++) {
|
for (i = 0; i <= 9; i++) {
|
||||||
Drawer2D_GetHexEncodedCol('0' + i, i, 191, 64);
|
Drawer2D_HexEncodedCol('0' + i, i, 191, 64);
|
||||||
}
|
}
|
||||||
for (i = 10; i <= 15; i++) {
|
for (i = 10; i <= 15; i++) {
|
||||||
Drawer2D_GetHexEncodedCol('a' + (i - 10), i, 191, 64);
|
Drawer2D_HexEncodedCol('a' + (i - 10), i, 191, 64);
|
||||||
Drawer2D_GetHexEncodedCol('a' + (i - 10), i, 191, 64);
|
Drawer2D_HexEncodedCol('a' + (i - 10), i, 191, 64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ Texture Drawer2D_MakeTextTexture(DrawTextArgs* args, Int32 windowX, Int32 window
|
|||||||
|
|
||||||
Bitmap bmp; Bitmap_AllocatePow2(&bmp, size.Width, size.Height);
|
Bitmap bmp; Bitmap_AllocatePow2(&bmp, size.Width, size.Height);
|
||||||
Drawer2D_Begin(&bmp);
|
Drawer2D_Begin(&bmp);
|
||||||
Drawer2D_DrawText(&args, 0, 0);
|
Drawer2D_DrawText(args, 0, 0);
|
||||||
Drawer2D_End();
|
Drawer2D_End();
|
||||||
return Drawer2D_Make2DTexture(&bmp, size, windowX, windowY);
|
return Drawer2D_Make2DTexture(&bmp, size, windowX, windowY);
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ bool Drawer2D_IsEmptyText(STRING_TRANSIENT String* text) {
|
|||||||
Int32 i;
|
Int32 i;
|
||||||
for (i = 0; i < text->length; i++) {
|
for (i = 0; i < text->length; i++) {
|
||||||
if (text->buffer[i] != '&') return false;
|
if (text->buffer[i] != '&') return false;
|
||||||
if (!ValidColCode(text, i + 1)) return false;
|
if (!Drawer2D_ValidColCodeAt(text, i + 1)) return false;
|
||||||
i++; /* skip colour code */
|
i++; /* skip colour code */
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -162,7 +162,7 @@ UInt8 Drawer2D_LastCol(STRING_TRANSIENT String* text, Int32 start) {
|
|||||||
Int32 i;
|
Int32 i;
|
||||||
for (i = start; i >= 0; i--) {
|
for (i = start; i >= 0; i--) {
|
||||||
if (text->buffer[i] != '&') continue;
|
if (text->buffer[i] != '&') continue;
|
||||||
if (Drawer2D_ValidColCode(text, i + 1)) {
|
if (Drawer2D_ValidColCodeAt(text, i + 1)) {
|
||||||
return text->buffer[i + 1];
|
return text->buffer[i + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ void Drawer2D_ReducePadding_Tex(Texture* tex, Int32 point, Int32 scale) {
|
|||||||
point = Drawer2D_AdjTextSize(point);
|
point = Drawer2D_AdjTextSize(point);
|
||||||
|
|
||||||
Int32 padding = (tex->Height - point) / scale;
|
Int32 padding = (tex->Height - point) / scale;
|
||||||
Real32 vAdj = (Real32)padding / Math_NextPowerOf2(tex->Height);
|
Real32 vAdj = (Real32)padding / Math_NextPowOf2(tex->Height);
|
||||||
tex->V1 += vAdj; tex->V2 -= vAdj;
|
tex->V1 += vAdj; tex->V2 -= vAdj;
|
||||||
tex->Height -= (UInt16)(padding * 2);
|
tex->Height -= (UInt16)(padding * 2);
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,103 @@
|
|||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
#include "GraphicsAPI.h"
|
#include "GraphicsAPI.h"
|
||||||
|
#include "Deflate.h"
|
||||||
|
#include "Formats.h"
|
||||||
|
#include "ZipArchive.h"
|
||||||
|
#include "Bitmap.h"
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
ErrorHandler_Init();
|
ErrorHandler_Init();
|
||||||
Platform_Init();
|
Platform_Init();
|
||||||
|
|
||||||
|
/*void* file;
|
||||||
|
String path = String_FromConstant("H:\\PortableApps\\GitPortable\\App\\Git\\ClassicalSharp\\output\\release\\texpacks\\skybox.png");
|
||||||
|
ReturnCode openCode = Platform_FileOpen(&file, &path, true);
|
||||||
|
Stream fileStream;
|
||||||
|
Stream_FromFile(&fileStream, file, &path);
|
||||||
|
Bitmap bmp;
|
||||||
|
Bitmap_DecodePng(&bmp, &fileStream);*/
|
||||||
|
|
||||||
|
/*BITMAPFILEHEADER bmpfileheader = { 0 };
|
||||||
|
BITMAPV5HEADER bmpinfoheader = { 0 };
|
||||||
|
bmpfileheader.bfType = (Int16)(('B' << 0) | ('M' << 8));
|
||||||
|
bmpfileheader.bfOffBits = sizeof(bmpfileheader) + sizeof(bmpinfoheader);
|
||||||
|
bmpfileheader.bfSize = Bitmap_DataSize(bmp.Width, bmp.Height) + bmpfileheader.bfOffBits;
|
||||||
|
|
||||||
|
bmpinfoheader.bV5Size = sizeof(bmpinfoheader);
|
||||||
|
bmpinfoheader.bV5BitCount = 32;
|
||||||
|
bmpinfoheader.bV5Planes = 1;
|
||||||
|
bmpinfoheader.bV5Width = bmp.Width;
|
||||||
|
bmpinfoheader.bV5Height = -bmp.Height;
|
||||||
|
bmpinfoheader.bV5Compression = BI_BITFIELDS;
|
||||||
|
bmpinfoheader.bV5AlphaMask = 0xFF000000UL;
|
||||||
|
bmpinfoheader.bV5RedMask = 0x00FF0000UL;
|
||||||
|
bmpinfoheader.bV5GreenMask = 0x0000FF00UL;
|
||||||
|
bmpinfoheader.bV5BlueMask = 0x000000FFUL;
|
||||||
|
|
||||||
|
void* file2;
|
||||||
|
String path2 = String_FromConstant("H:\\PortableApps\\GitPortable\\App\\Git\\ClassicalSharp\\output\\release\\texpacks\\skybox8.bmp");
|
||||||
|
openCode = Platform_FileCreate(&file2, &path2);
|
||||||
|
Stream fileStream2;
|
||||||
|
Stream_FromFile(&fileStream2, file2, &path2);
|
||||||
|
Stream_Write(&fileStream2, &bmpfileheader, sizeof(bmpfileheader));
|
||||||
|
Stream_Write(&fileStream2, &bmpinfoheader, sizeof(bmpinfoheader));
|
||||||
|
Stream_Write(&fileStream2, bmp.Scan0, Bitmap_DataSize(bmp.Width, bmp.Height));
|
||||||
|
fileStream2.Close(&fileStream2);*/
|
||||||
|
|
||||||
|
//return 0;
|
||||||
|
|
||||||
|
/*void* file;
|
||||||
|
String path = String_FromConstant("H:\\PortableApps\\GitPortable\\App\\Git\\ClassicalSharp\\output\\release\\texpacks\\default.zip");
|
||||||
|
ReturnCode openCode = Platform_FileOpen(&file, &path, true);
|
||||||
|
Stream fileStream;
|
||||||
|
Stream_FromFile(&fileStream, file, &path);
|
||||||
|
ZipState state;
|
||||||
|
Zip_Init(&state, &fileStream);
|
||||||
|
Zip_Extract(&state);
|
||||||
|
return 0;*/
|
||||||
|
|
||||||
|
void* file;
|
||||||
|
String path = String_FromConstant("H:\\PortableApps\\GitPortable\\App\\Git\\ClassicalSharp\\src\\x64\\Release\\canyon.lvl");
|
||||||
|
ReturnCode openCode = Platform_FileOpen(&file, &path, true);
|
||||||
|
Stream fileStream;
|
||||||
|
Stream_FromFile(&fileStream, file, &path);
|
||||||
|
Lvl_Load(&fileStream);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/*void* file;
|
||||||
|
String path = String_FromConstant("H:\\PortableApps\\GitPortable\\App\\Git\\\ClassicalSharp\\src\\Debug\\gunzip.c.gz");
|
||||||
|
ReturnCode openCode = Platform_FileOpen(&file, &path, true);
|
||||||
|
Stream fileStream;
|
||||||
|
Stream_FromFile(&fileStream, file, &path);
|
||||||
|
|
||||||
|
GZipHeader gzip;
|
||||||
|
GZipHeader_Init(&gzip);
|
||||||
|
while (!gzip.Done) { GZipHeader_Read(&fileStream, &gzip); }
|
||||||
|
UInt32 pos = Platform_FilePosition(file);
|
||||||
|
|
||||||
|
DeflateState deflate;
|
||||||
|
Deflate_Init(&deflate, &fileStream);
|
||||||
|
UInt32 read;
|
||||||
|
fileStream.Read(&fileStream, deflate.Input, 8192, &read);
|
||||||
|
deflate.AvailIn = read;
|
||||||
|
|
||||||
|
UInt8 out[56000];
|
||||||
|
deflate.Output = out;
|
||||||
|
deflate.AvailOut = 56000;
|
||||||
|
//puff(out, &deflate.AvailOut, deflate.Input, &deflate.AvailIn);
|
||||||
|
Deflate_Process(&deflate);
|
||||||
|
|
||||||
|
String path2 = String_FromConstant("H:\\PortableApps\\GitPortable\\App\\Git\\ClassicalSharp\\src\\x64\\Debug\\ffff.c");
|
||||||
|
openCode = Platform_FileCreate(&file, &path2);
|
||||||
|
Stream_FromFile(&fileStream, file, &path);
|
||||||
|
UInt32 written;
|
||||||
|
fileStream.Write(&fileStream, out, 56000 - deflate.AvailOut, &written);
|
||||||
|
fileStream.Close(&fileStream);
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
String str = String_FromConstant("TEST");
|
String str = String_FromConstant("TEST");
|
||||||
Window_Create(320, 320, 640, 480, &str, NULL);
|
Window_Create(320, 320, 640, 480, &str, NULL);
|
||||||
Window_SetVisible(true);
|
Window_SetVisible(true);
|
||||||
@ -24,5 +116,5 @@ int main(int argc, char* argv[]) {
|
|||||||
Gfx_EndFrame();
|
Gfx_EndFrame();
|
||||||
}
|
}
|
||||||
Gfx_Free();
|
Gfx_Free();
|
||||||
return 0;
|
return 0;*/
|
||||||
}
|
}
|
@ -13,6 +13,7 @@
|
|||||||
#include "Vectors.h"
|
#include "Vectors.h"
|
||||||
#include "VertexStructs.h"
|
#include "VertexStructs.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
|
#include "Particle.h"
|
||||||
|
|
||||||
GfxResourceID weather_rainTex;
|
GfxResourceID weather_rainTex;
|
||||||
GfxResourceID weather_snowTex;
|
GfxResourceID weather_snowTex;
|
||||||
@ -133,8 +134,8 @@ void WeatherRenderer_Render(Real64 deltaTime) {
|
|||||||
if (height <= 0) continue;
|
if (height <= 0) continue;
|
||||||
|
|
||||||
if (particles && (weather_accumulator >= 0.25 || moved)) {
|
if (particles && (weather_accumulator >= 0.25 || moved)) {
|
||||||
/* TODO: Implement particles*/
|
Vector3 particlePos = Vector3_Create3((Real32)x, y, (Real32)z);
|
||||||
//ParticleManager_AddRainParticle(x, y, z);
|
Particles_RainSnowEffect(particlePos);
|
||||||
}
|
}
|
||||||
|
|
||||||
Real32 dist = (Real32)dx * (Real32)dx + (Real32)dz * (Real32)dz;
|
Real32 dist = (Real32)dx * (Real32)dx + (Real32)dz * (Real32)dz;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user