change texture2d to texture

This commit is contained in:
CrackedPixel 2024-08-07 19:42:06 -05:00
commit 1c829e7b81
47 changed files with 73 additions and 73 deletions

View file

@ -38,8 +38,8 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input"); InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad input");
Texture2D texPs3Pad = LoadTexture("resources/ps3.png"); Texture texPs3Pad = LoadTexture("resources/ps3.png");
Texture2D texXboxPad = LoadTexture("resources/xbox.png"); Texture texXboxPad = LoadTexture("resources/xbox.png");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------

View file

@ -42,7 +42,7 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
Model model = LoadModel("resources/models/iqm/guy.iqm"); // Load the animated model mesh and basic data Model model = LoadModel("resources/models/iqm/guy.iqm"); // Load the animated model mesh and basic data
Texture2D texture = LoadTexture("resources/models/iqm/guytex.png"); // Load model texture and set material Texture texture = LoadTexture("resources/models/iqm/guytex.png"); // Load model texture and set material
SetMaterialTexture(&model.materials[0], MATERIAL_MAP_DIFFUSE, texture); // Set model material map texture SetMaterialTexture(&model.materials[0], MATERIAL_MAP_DIFFUSE, texture); // Set model material map texture
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position

View file

@ -34,7 +34,7 @@ int main(void)
camera.fovy = 45.0f; // Camera field-of-view Y camera.fovy = 45.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Texture2D bill = LoadTexture("resources/billboard.png"); // Our billboard texture Texture bill = LoadTexture("resources/billboard.png"); // Our billboard texture
Vector3 billPositionStatic = { 0.0f, 2.0f, 0.0f }; // Position of static billboard Vector3 billPositionStatic = { 0.0f, 2.0f, 0.0f }; // Position of static billboard
Vector3 billPositionRotating = { 1.0f, 2.0f, 1.0f }; // Position of rotating billboard Vector3 billPositionRotating = { 1.0f, 2.0f, 1.0f }; // Position of rotating billboard

View file

@ -34,13 +34,13 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM) Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM) Texture cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM)
Mesh mesh = GenMeshCubicmap(image, (Vector3){ 1.0f, 1.0f, 1.0f }); Mesh mesh = GenMeshCubicmap(image, (Vector3){ 1.0f, 1.0f, 1.0f });
Model model = LoadModelFromMesh(mesh); Model model = LoadModelFromMesh(mesh);
// NOTE: By default each cube is mapped to one part of texture atlas // NOTE: By default each cube is mapped to one part of texture atlas
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture Texture texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position Vector3 mapPosition = { -16.0f, 0.0f, -8.0f }; // Set model position

View file

@ -18,8 +18,8 @@
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Custom Functions Declaration // Custom Functions Declaration
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured void DrawCubeTexture(Texture texture, Vector3 position, float width, float height, float length, Color color); // Draw cube textured
void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color); // Draw cube with a region of a texture void DrawCubeTextureRec(Texture texture, Rectangle source, Vector3 position, float width, float height, float length, Color color); // Draw cube with a region of a texture
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
@ -42,7 +42,7 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; camera.projection = CAMERA_PERSPECTIVE;
// Load texture to be applied to the cubes sides // Load texture to be applied to the cubes sides
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); Texture texture = LoadTexture("resources/cubicmap_atlas.png");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -95,7 +95,7 @@ int main(void)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Draw cube textured // Draw cube textured
// NOTE: Cube position is the center position // NOTE: Cube position is the center position
void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float height, float length, Color color) void DrawCubeTexture(Texture texture, Vector3 position, float width, float height, float length, Color color)
{ {
float x = position.x; float x = position.x;
float y = position.y; float y = position.y;
@ -157,7 +157,7 @@ void DrawCubeTexture(Texture2D texture, Vector3 position, float width, float hei
} }
// Draw cube with texture piece applied to all faces // Draw cube with texture piece applied to all faces
void DrawCubeTextureRec(Texture2D texture, Rectangle source, Vector3 position, float width, float height, float length, Color color) void DrawCubeTextureRec(Texture texture, Rectangle source, Vector3 position, float width, float height, float length, Color color)
{ {
float x = position.x; float x = position.x;
float y = position.y; float y = position.y;

View file

@ -36,12 +36,12 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Image imMap = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM) Image imMap = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
Texture2D cubicmap = LoadTextureFromImage(imMap); // Convert image to texture to display (VRAM) Texture cubicmap = LoadTextureFromImage(imMap); // Convert image to texture to display (VRAM)
Mesh mesh = GenMeshCubicmap(imMap, (Vector3){ 1.0f, 1.0f, 1.0f }); Mesh mesh = GenMeshCubicmap(imMap, (Vector3){ 1.0f, 1.0f, 1.0f });
Model model = LoadModelFromMesh(mesh); Model model = LoadModelFromMesh(mesh);
// NOTE: By default each cube is mapped to one part of texture atlas // NOTE: By default each cube is mapped to one part of texture atlas
Texture2D texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture Texture texture = LoadTexture("resources/cubicmap_atlas.png"); // Load map texture
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
// Get map image data to be used for collision detection // Get map image data to be used for collision detection

View file

@ -34,7 +34,7 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM) Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM) Texture texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM) Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM)
Model model = LoadModelFromMesh(mesh); // Load model from generated mesh Model model = LoadModelFromMesh(mesh); // Load model from generated mesh

View file

@ -47,7 +47,7 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; // Camera mode type camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
Model model = LoadModel("resources/models/obj/castle.obj"); // Load model Model model = LoadModel("resources/models/obj/castle.obj"); // Load model
Texture2D texture = LoadTexture("resources/models/obj/castle_diffuse.png"); // Load model texture Texture texture = LoadTexture("resources/models/obj/castle_diffuse.png"); // Load model texture
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position

View file

@ -31,7 +31,7 @@ int main(void)
// We generate a checked image for texturing // We generate a checked image for texturing
Image checked = GenImageChecked(2, 2, 1, 1, RED, GREEN); Image checked = GenImageChecked(2, 2, 1, 1, RED, GREEN);
Texture2D texture = LoadTextureFromImage(checked); Texture texture = LoadTextureFromImage(checked);
UnloadImage(checked); UnloadImage(checked);
Model models[NUM_MODELS] = { 0 }; Model models[NUM_MODELS] = { 0 };

View file

@ -41,7 +41,7 @@ int main(void)
Ray ray = { 0 }; // Picking ray Ray ray = { 0 }; // Picking ray
Model tower = LoadModel("resources/models/obj/turret.obj"); // Load OBJ model Model tower = LoadModel("resources/models/obj/turret.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/obj/turret_diffuse.png"); // Load model texture Texture texture = LoadTexture("resources/models/obj/turret_diffuse.png"); // Load model texture
tower.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture tower.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position Vector3 towerPos = { 0.0f, 0.0f, 0.0f }; // Set model position

View file

@ -23,7 +23,7 @@
#endif #endif
// Generate cubemap (6 faces) from equirectangular (panorama) texture // Generate cubemap (6 faces) from equirectangular (panorama) texture
static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int size, int format); static TextureCubemap GenTextureCubemap(Shader shader, Texture panorama, int size, int format);
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
@ -74,7 +74,7 @@ int main(void)
TextCopy(skyboxFileName, "resources/dresden_square_2k.hdr"); TextCopy(skyboxFileName, "resources/dresden_square_2k.hdr");
// Load HDR panorama (sphere) texture // Load HDR panorama (sphere) texture
Texture2D panorama = LoadTexture(skyboxFileName); Texture panorama = LoadTexture(skyboxFileName);
// Generate cubemap (texture with 6 quads-cube-mapping) from panorama HDR texture // Generate cubemap (texture with 6 quads-cube-mapping) from panorama HDR texture
// NOTE 1: New texture is generated rendering to texture, shader calculates the sphere->cube coordinates mapping // NOTE 1: New texture is generated rendering to texture, shader calculates the sphere->cube coordinates mapping
@ -118,7 +118,7 @@ int main(void)
if (useHDR) if (useHDR)
{ {
// Load HDR panorama (sphere) texture // Load HDR panorama (sphere) texture
Texture2D panorama = LoadTexture(droppedFiles.paths[0]); Texture panorama = LoadTexture(droppedFiles.paths[0]);
// Generate cubemap from panorama texture // Generate cubemap from panorama texture
skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8); skybox.materials[0].maps[MATERIAL_MAP_CUBEMAP].texture = GenTextureCubemap(shdrCubemap, panorama, 1024, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8);
@ -182,7 +182,7 @@ int main(void)
} }
// Generate cubemap texture from HDR texture // Generate cubemap texture from HDR texture
static TextureCubemap GenTextureCubemap(Shader shader, Texture2D panorama, int size, int format) static TextureCubemap GenTextureCubemap(Shader shader, Texture panorama, int size, int format)
{ {
TextureCubemap cubemap = { 0 }; TextureCubemap cubemap = { 0 };

View file

@ -38,7 +38,7 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; // Camera type camera.projection = CAMERA_PERSPECTIVE; // Camera type
Model model = LoadModel("resources/models/obj/plane.obj"); // Load model Model model = LoadModel("resources/models/obj/plane.obj"); // Load model
Texture2D texture = LoadTexture("resources/models/obj/plane_diffuse.png"); // Load model texture Texture texture = LoadTexture("resources/models/obj/plane_diffuse.png"); // Load model texture
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture
float pitch = 0.0f; float pitch = 0.0f;

View file

@ -61,7 +61,7 @@ int main(void)
}; };
// Image converted to Texture (VRAM) to be drawn // Image converted to Texture (VRAM) to be drawn
Texture2D texture = LoadTextureFromImage(image); Texture texture = LoadTextureFromImage(image);
// With an Image loaded from file, after Texture is loaded, we can unload Image // With an Image loaded from file, after Texture is loaded, we can unload Image
// but in our case, Image is embedded in executable, in program .data segment // but in our case, Image is embedded in executable, in program .data segment

View file

@ -49,7 +49,7 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Model model = LoadModel("resources/models/barracks.obj"); // Load OBJ model Model model = LoadModel("resources/models/barracks.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/barracks_diffuse.png"); // Load model texture (diffuse map) Texture texture = LoadTexture("resources/models/barracks_diffuse.png"); // Load model texture (diffuse map)
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position

View file

@ -277,7 +277,7 @@ int main(void)
} break; } break;
case DEFERRED_POSITION: case DEFERRED_POSITION:
{ {
DrawTextureRec((Texture2D){ DrawTextureRec((Texture){
.id = gBuffer.positionTexture, .id = gBuffer.positionTexture,
.width = screenWidth, .width = screenWidth,
.height = screenHeight, .height = screenHeight,
@ -287,7 +287,7 @@ int main(void)
} break; } break;
case DEFERRED_NORMAL: case DEFERRED_NORMAL:
{ {
DrawTextureRec((Texture2D){ DrawTextureRec((Texture){
.id = gBuffer.normalTexture, .id = gBuffer.normalTexture,
.width = screenWidth, .width = screenWidth,
.height = screenHeight, .height = screenHeight,
@ -297,7 +297,7 @@ int main(void)
} break; } break;
case DEFERRED_ALBEDO: case DEFERRED_ALBEDO:
{ {
DrawTextureRec((Texture2D){ DrawTextureRec((Texture){
.id = gBuffer.albedoSpecTexture, .id = gBuffer.albedoSpecTexture,
.width = screenWidth, .width = screenWidth,
.height = screenHeight, .height = screenHeight,

View file

@ -49,7 +49,7 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Model model = LoadModel("resources/models/watermill.obj"); // Load OBJ model Model model = LoadModel("resources/models/watermill.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/watermill_diffuse.png"); // Load model texture Texture texture = LoadTexture("resources/models/watermill_diffuse.png"); // Load model texture
// Load shader for model // Load shader for model
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader // NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader

View file

@ -83,7 +83,7 @@ int main(void)
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Model model = LoadModel("resources/models/church.obj"); // Load OBJ model Model model = LoadModel("resources/models/church.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/church_diffuse.png"); // Load model texture (diffuse map) Texture texture = LoadTexture("resources/models/church_diffuse.png"); // Load model texture (diffuse map)
model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position

View file

@ -38,7 +38,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders"); InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders");
Texture2D fudesumi = LoadTexture("resources/fudesumi.png"); Texture fudesumi = LoadTexture("resources/fudesumi.png");
// Load shader to be used on some parts drawing // Load shader to be used on some parts drawing
// NOTE 1: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version // NOTE 1: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version

View file

@ -36,7 +36,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing"); InitWindow(screenWidth, screenHeight, "raylib [shaders] example - texture drawing");
Image imBlank = GenImageColor(1024, 1024, BLANK); Image imBlank = GenImageColor(1024, 1024, BLANK);
Texture2D texture = LoadTextureFromImage(imBlank); // Load blank texture to fill on shader Texture texture = LoadTextureFromImage(imBlank); // Load blank texture to fill on shader
UnloadImage(imBlank); UnloadImage(imBlank);
// NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version // NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version

View file

@ -36,7 +36,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - Apply an outline to a texture"); InitWindow(screenWidth, screenHeight, "raylib [shaders] example - Apply an outline to a texture");
Texture2D texture = LoadTexture("resources/fudesumi.png"); Texture texture = LoadTexture("resources/fudesumi.png");
Shader shdrOutline = LoadShader(0, TextFormat("resources/shaders/glsl%i/outline.fs", GLSL_VERSION)); Shader shdrOutline = LoadShader(0, TextFormat("resources/shaders/glsl%i/outline.fs", GLSL_VERSION));

Some files were not shown because too many files have changed in this diff Show more