Hi, this is my first post. I wasn’t sure if this was the appropriate place or SDL development.
I have one image.png that I load using SDL_IMG. I load by creating a surface. Then I create a texture using CreateTextureFromSurface() and I free the original surface. I repeat the same process but now at the end I use SetColorMod(128, 128, 0) to this new texture. This changes the color of the image as I wanted! Cool!
This whole process is done way before the images are rendered to the screen. The original texture (without the color change) is rendered normally. The texture with the color change creates a mini delay when rendered for the first time. After that it keeps rendering without any delay.
Has anyone experienced this or have any idea on what is going on? I’m using SDL 2.0.2 (I’m using ubuntu 14.04)
Hi tupan,
think this place is good. SDL-Dev is more about coding on SDL not with.
Actually you don’t need to free the surface all the time. Put it into clean_up().
Hi, Acry! Thanks for the response. I forgot to mention that I’m using Go (https://github.com/veandco/go-sdl2) to write the code, not C or C++. I’m not sure how familiar you are with go but for clarity when there is a colon followed by a equal sign, it means that it is declaring and allocating memory for that memory in one line.
this part of the code on how I load the (I also do some checking such as if file exist, errors when loading to the surface… I’m not putting it here). You can see more the repository https://github.com/tubelz/macaw this part would be in the files entity/spritesheet.go and system/render.go
Okay, that changes the play-field a bit, after my lunch break I am gonna have a quick go tour and maybe I can be useful after that, except the issue is solved in between.
I use atom (https://atom.io/) to play with it. It recognizes go by default. You could also install some other packages to make it better (like a linter).
I was using Emacs, then Kate for the snippets, now I use KDevelop. Did already check if there is a plugin for go, since it doesn’t look like it’s supported yet.
I am basically using snippets all the time since C support is very poor in most IDE’s except making the code colorful =) and I made my own templates for Kdev, which is good for rapid proto-typing. The rest is copied out of my code-base. I checked so many IDE’s that it’s not even funny anymore. Now since SDL2 has support for Android Studio I will try that again, when the code on my game is done. I did the proto-typing with the ndk and ant.
You have to render the texture, though. The SetColorMod itself doesn’t show any lag. I run that on the pre-load to load the textures. I render the texture a few seconds after that command has executed. That’s where you see the lag