mirror of
https://git.coom.tech/drummyfish/small3dlib.git
synced 2024-11-22 20:49:58 +01:00
Update example
This commit is contained in:
parent
dc6a46ef7d
commit
d77a6ab48b
16 changed files with 31364 additions and 24244 deletions
|
@ -91,7 +91,7 @@ const S3L_Index carUVIndices[CAR_UV_INDEX_COUNT * 3] = {
|
||||||
|
|
||||||
S3L_Model3D carModel;
|
S3L_Model3D carModel;
|
||||||
|
|
||||||
void carModelInit()
|
void carModelInit(void)
|
||||||
{
|
{
|
||||||
S3L_model3DInit(
|
S3L_model3DInit(
|
||||||
carVertices,
|
carVertices,
|
||||||
|
|
|
@ -396,7 +396,7 @@ const S3L_Index cat1UVIndices[CAT1_UV_INDEX_COUNT * 3] = {
|
||||||
|
|
||||||
S3L_Model3D cat1Model;
|
S3L_Model3D cat1Model;
|
||||||
|
|
||||||
void cat1ModelInit()
|
void cat1ModelInit(void)
|
||||||
{
|
{
|
||||||
S3L_model3DInit(
|
S3L_model3DInit(
|
||||||
cat1Vertices,
|
cat1Vertices,
|
||||||
|
|
|
@ -396,7 +396,7 @@ const S3L_Index cat2UVIndices[CAT2_UV_INDEX_COUNT * 3] = {
|
||||||
|
|
||||||
S3L_Model3D cat2Model;
|
S3L_Model3D cat2Model;
|
||||||
|
|
||||||
void cat2ModelInit()
|
void cat2ModelInit(void)
|
||||||
{
|
{
|
||||||
S3L_model3DInit(
|
S3L_model3DInit(
|
||||||
cat2Vertices,
|
cat2Vertices,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -755,7 +755,7 @@ const S3L_Index chestUVIndices[CHEST_UV_INDEX_COUNT * 3] = {
|
||||||
|
|
||||||
S3L_Model3D chestModel;
|
S3L_Model3D chestModel;
|
||||||
|
|
||||||
void chestModelInit()
|
void chestModelInit(void)
|
||||||
{
|
{
|
||||||
S3L_model3DInit(
|
S3L_model3DInit(
|
||||||
chestVertices,
|
chestVertices,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -945,7 +945,7 @@ const S3L_Index cityUVIndices[CITY_UV_INDEX_COUNT * 3] = {
|
||||||
|
|
||||||
S3L_Model3D cityModel;
|
S3L_Model3D cityModel;
|
||||||
|
|
||||||
void cityModelInit()
|
void cityModelInit(void)
|
||||||
{
|
{
|
||||||
S3L_model3DInit(
|
S3L_model3DInit(
|
||||||
cityVertices,
|
cityVertices,
|
||||||
|
|
24006
programs/cityTexture.h
24006
programs/cityTexture.h
File diff suppressed because it is too large
Load diff
|
@ -719,7 +719,7 @@ const S3L_Index houseUVIndices[HOUSE_UV_INDEX_COUNT * 3] = {
|
||||||
|
|
||||||
S3L_Model3D houseModel;
|
S3L_Model3D houseModel;
|
||||||
|
|
||||||
void houseModelInit()
|
void houseModelInit(void)
|
||||||
{
|
{
|
||||||
S3L_model3DInit(
|
S3L_model3DInit(
|
||||||
houseVertices,
|
houseVertices,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1388,7 +1388,7 @@ const S3L_Index levelUVIndices[LEVEL_UV_INDEX_COUNT * 3] = {
|
||||||
|
|
||||||
S3L_Model3D levelModel;
|
S3L_Model3D levelModel;
|
||||||
|
|
||||||
void levelModelInit()
|
void levelModelInit(void)
|
||||||
{
|
{
|
||||||
S3L_model3DInit(
|
S3L_model3DInit(
|
||||||
levelVertices,
|
levelVertices,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
PROGRAM=testTerminal
|
PROGRAM=testTerminal # change this to name of a program you want to compile :)
|
||||||
|
|
||||||
clear; clear; g++ -x c -g -fmax-errors=5 -pedantic -O3 -Wall -Wextra -Wstrict-prototypes -Wold-style-definition -Wno-unused-parameter -Wno-missing-field-initializers -o $PROGRAM $PROGRAM.c -lSDL2 2>&1 >/dev/null && ./$PROGRAM
|
clear; clear; g++ -x c -g -fmax-errors=5 -pedantic -O3 -Wall -Wextra -Wstrict-prototypes -Wold-style-definition -Wno-unused-parameter -Wno-missing-field-initializers -o $PROGRAM $PROGRAM.c -lSDL2 2>&1 >/dev/null && ./$PROGRAM
|
||||||
#clear; clear; clang -x c -g -pedantic -O3 -Wall -Wextra -o $PROGRAM $PROGRAM.c -lSDL2 2>&1 >/dev/null && ./$PROGRAM
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ const S3L_Index plantUVIndices[PLANT_UV_INDEX_COUNT * 3] = {
|
||||||
|
|
||||||
S3L_Model3D plantModel;
|
S3L_Model3D plantModel;
|
||||||
|
|
||||||
void plantModelInit()
|
void plantModelInit(void)
|
||||||
{
|
{
|
||||||
S3L_model3DInit(
|
S3L_model3DInit(
|
||||||
plantVertices,
|
plantVertices,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
56
programs/sdl_helper.h
Normal file
56
programs/sdl_helper.h
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
|
uint32_t pixels[S3L_RESOLUTION_X * S3L_RESOLUTION_Y];
|
||||||
|
|
||||||
|
SDL_Window *window;
|
||||||
|
SDL_Renderer *renderer;
|
||||||
|
SDL_Texture *textureSDL;
|
||||||
|
SDL_Surface *screenSurface;
|
||||||
|
SDL_Event event;
|
||||||
|
|
||||||
|
void sdlInit(void)
|
||||||
|
{
|
||||||
|
window = SDL_CreateWindow("model viewer", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, S3L_RESOLUTION_X, S3L_RESOLUTION_Y, SDL_WINDOW_SHOWN);
|
||||||
|
renderer = SDL_CreateRenderer(window,-1,0);
|
||||||
|
textureSDL = SDL_CreateTexture(renderer,SDL_PIXELFORMAT_RGBX8888, SDL_TEXTUREACCESS_STATIC, S3L_RESOLUTION_X, S3L_RESOLUTION_Y);
|
||||||
|
screenSurface = SDL_GetWindowSurface(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void sdlUpdate(void)
|
||||||
|
{
|
||||||
|
SDL_UpdateTexture(textureSDL,NULL,pixels,S3L_RESOLUTION_X * sizeof(uint32_t));
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
SDL_RenderCopy(renderer,textureSDL,NULL,NULL);
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearScreen(void)
|
||||||
|
{
|
||||||
|
memset(pixels,200,S3L_RESOLUTION_X * S3L_RESOLUTION_Y * sizeof(uint32_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void setPixel(int x, int y, uint8_t red, uint8_t green, uint8_t blue)
|
||||||
|
{
|
||||||
|
uint8_t *p = ((uint8_t *) pixels) + (y * S3L_RESOLUTION_X + x) * 4 + 1;
|
||||||
|
|
||||||
|
*p = blue;
|
||||||
|
++p;
|
||||||
|
*p = green;
|
||||||
|
++p;
|
||||||
|
*p = red;
|
||||||
|
}
|
||||||
|
|
||||||
|
void sampleTexture(const uint8_t *tex, int32_t u, int32_t v, uint8_t *r, uint8_t *g, uint8_t *b)
|
||||||
|
{
|
||||||
|
u = S3L_wrap(u,TEXTURE_W);
|
||||||
|
v = S3L_wrap(v,TEXTURE_H);
|
||||||
|
|
||||||
|
const uint8_t *t = tex + (v * TEXTURE_W + u) * 4;
|
||||||
|
|
||||||
|
*r = *t;
|
||||||
|
t++;
|
||||||
|
*g = *t;
|
||||||
|
t++;
|
||||||
|
*b = *t;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue