Sign in to follow this  

need on algorithm advice - SDL

Recommended Posts

hi all,

 

im using SDL and rendering the images as sdl texture (loaded to surface and convert them to texture)

ive got lots and lots of sprites that if loaded together i will get a VIdeo memory not enough error, cant create texture error.

so what i did is to load the sprites that are needed and while the current sprites are being rendered i will load the next sprites at the back..

now the problem is, yes, we can load the images to SDL_Surface but we cannot just create the Texture from a separate thread, it should be in the main thread.

which basically defeats my purpose of loading and creating the sprite at the back thread.

 

how can we address this issue or do you guys have any approach you can suggest?

Share this post


Link to post
Share on other sites

Background threads in Windows Forms, or in Browser JavaScript have no access the the UI. Yet after the first baffling every developer seems to get along. Do you really have a performance problem with your main thread? I read you are memory bound, not a CPU bound.

Share this post


Link to post
Share on other sites

Background threads in Windows Forms, or in Browser JavaScript have no access the the UI. Yet after the first baffling every developer seems to get along. Do you really have a performance problem with your main thread? I read you are memory bound, not a CPU bound.

i know that that is why i am asking for advice on how the other guys knew  it, they might have experienced the same thing, 

also im using SDL in C++.

and yes, creating the SDL_Texture in main thread everytime it is needed somehow got that "stucky" feeling or a frame is frozen for few seconds before it continues.

Share this post


Link to post
Share on other sites

SDL can be used for many simple things, but this is beyond its capabilities. You have to use directly DirectX or OpenGL. You can still use SDL for creating window, receiving input and such.

 

Even if you do that, that probably not solves all your problems. The slowest part of the computer is the hard drive, and those freezes may come from the reading of image files from drive. Even if another thread reads the textures, you have to wait for them to be available. One way to go around this to predict what textures will be needed in the future, and load them way before they are needed.

Share this post


Link to post
Share on other sites

ive got lots and lots of sprites that if loaded together i will get a VIdeo memory not enough error, cant create texture error.


I’m skeptical— that’s a lot of data!

How many sprites do you have?
What are the dimensions of your sprites, on average? And the smallest? And the largest?
What file format are your sprites in?
Are the sprites bin-packed into sprite sheets?
Have you looked into texture compression options?
Are your sprites artificially upscaled? That is, an image that represents a 16x16 sprite should only be 16x16 in size, and not any of: 32x32, 64x64, and etc. Edited by fastcall22

Share this post


Link to post
Share on other sites

 

ive got lots and lots of sprites that if loaded together i will get a VIdeo memory not enough error, cant create texture error.


I’m skeptical— that’s a lot of data!

How many sprites do you have?
What are the dimensions of your sprites, on average? And the smallest? And the largest?
What file format are your sprites in?
Are the sprites bin-packed into sprite sheets?
Have you looked into texture compression options?
Are your sprites artificially upscaled? That is, an image that represents a 16x16 sprite should only be 16x16 in size, and not any of: 32x32, 64x64, and etc.

 

its my first time building a visual studio novel using my own engine, in previous games using this engine it was all ok and do not have this problem, coz of the fact that i am using small szed sprites, i can just load all sprites and points to it after,

 

but now since sprites are huge like full screen sprites for characters, i ran across this video memory error.

the sprite sizes average at 6000 x 1000 pixels, and i have like 69 sprites, the lowest size is 1000x1000. yeah its kinda huge and we need to have adjustment

our working screen resolution is 1980x1080 pixels, with character size (frame size) of 700x900, as characters should appear huge.

Edited by cebugdev

Share this post


Link to post
Share on other sites
  1. Your art asset might be the right size for printing, but for a visual novel they need to be downscaled.
  2. How can you possibly use 69 sprites in a single game state? I'd expect 1 background, a handful of characters and maybe some special effects

Regarding the original technical question, the weak spot of your technique is trying to do work "while the current sprites are being rendered" Couldn't you try loading sprites on the main rendering thread at screen transitions?A slight delay before the sprites are available and transition animations begin would be barely noticeable.

Edited by LorenzoGatti

Share this post


Link to post
Share on other sites

 

  1. Your art asset might be the right size for printing, but for a visual novel they need to be downscaled.
  2. How can you possibly use 69 sprites in a single game state? I'd expect 1 background, a handful of characters and maybe some special effects

Regarding the original technical question, the weak spot of your technique is trying to do work "while the current sprites are being rendered" Couldn't you try loading sprites on the main rendering thread at screen transitions?A slight delay before the sprites are available and transition animations begin would be barely noticeable.

 

yeah that's the solution im thinking right now, just to put loading and transition animation like fade in/out for scenes,

 

lasly, for a target resolution of 1980x1080 how should we handle the sprites and images? should we have a scene targetting that resolution or we draw the sprite lower than 19080x1080 and resize thru hardware like bit block transfer or something? my problem is that, it might be blocky or blurry as a result though

Edited by cebugdev

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this