0

When trying to load a texture into the console, the output is: Couldn't open lettuce.png I tried to upload both jpg files and webp. Changed SDL flags. But nothing helped. There are no problems with initializing SDL enter image description here If anyone has met with such a tell me.

using System;
using System.IO;
using SDL2;
using System.Runtime.InteropServices;

namespace GGG
{
    public class Program
    {
        public static void Main()
        {
            if (SDL.SDL_Init(SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_EVENTS) < 0)
            {
                Console.WriteLine("Error SDL2 Initialization : " + SDL.SDL_GetError());
            }
            
            if (SDL_image.IMG_Init(SDL_image.IMG_InitFlags.IMG_INIT_PNG) == 0)
            {
                Console.WriteLine("Error SDL2_image Initialization : " + SDL_image.IMG_GetError());
            }
            
            IntPtr window = SDL.SDL_CreateWindow("Pizda", 10, 10, 800, 800, SDL.SDL_WindowFlags.SDL_WINDOW_OPENGL);
            if (window == IntPtr.Zero)
            {
                Console.WriteLine("Error window creation");
            }

            IntPtr render = SDL.SDL_CreateRenderer(window, -1, SDL.SDL_RendererFlags.SDL_RENDERER_ACCELERATED);
            if (render == IntPtr.Zero)
            {
                Console.WriteLine("Error renderer creation");
            }

            IntPtr texture = SDL_image.IMG_LoadTexture(render, "lettuce.png");
            if (texture == IntPtr.Zero)
            {
                Console.WriteLine("Error texture load : " + SDL_image.IMG_GetError());
            }

            if (SDL.SDL_RenderClear(render) != 0)
            {
                Console.WriteLine("Error render clear : " + SDL.SDL_GetError());
            }

            if (SDL.SDL_RenderCopy(render, texture, IntPtr.Zero, IntPtr.Zero) == 0)
            {
                Console.WriteLine("Error render copy : " + SDL.SDL_GetError());
            }

            SDL.SDL_RenderPresent(render);

            while (true)
            {
                SDL.SDL_Event e;
                if (SDL.SDL_PollEvent(out e) == 1)
                {
                    if (e.type == SDL2.SDL.SDL_EventType.SDL_QUIT)
                    {
                        break;
                    }
                }
            }
            
            SDL.SDL_DestroyTexture(texture);
            SDL.SDL_DestroyRenderer(render);
            SDL.SDL_DestroyWindow(window);
            SDL_image.IMG_Quit();
            SDL.SDL_Quit();
        }
    }
}

SDL2_image.dll and SDL2.dll and the image is in a package with an executable file.

OZYREO
  • 1

0 Answers0