ParaToxic Posted March 25, 2012 Share Posted March 25, 2012 Hey I have a question .Can I load a kind of pieces from one texture file ? Look at that: I think when I programmed in Blitz3D it was possible to call every pic in the texture to make an animated texture Quote Link to comment Share on other sites More sharing options...
Furbolg Posted March 25, 2012 Share Posted March 25, 2012 Hi ParaToxic, forget Blitz3D (LoadAnimTexture or so..) it just a tricky function/structure to hide the texture coordinate calculations. You can load the texture above in a whole and then display a "frame" by setting the uv coordinates to x1 = row / maximumRow; y1 = col / maximumCol; x2 = x1 + (1.0f / maximumRow); y2 = y1 + (1.0f / maximumCol); This is just one method, i bet there are plenty different. You just have to see the whole texture from 0,0 to 512,512 as 0,0 to 1,1 and then "scale" it to your needs. E.g.: If you have a 512x512 texture and want to show 0,0 to 256,256 then you have to write x1 = 0 y1 = 0 x2 = 0.5 y2 = 0.5 ps. x1/y1 and x2/y2 are the uv coordinates if you see the texture as a simple rectangle (they are the corners). Hope this helps you. 1 Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted March 26, 2012 Author Share Posted March 26, 2012 Thanks ;D Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted March 27, 2012 Author Share Posted March 27, 2012 So now I made a class with some function for that. Imagine I have a texture and at the top left is an image like in the pic I posted. I load the texture to my TTexture variable and create a new TTexture with the height and width of 128.So I set my 128*128 texture with SetBuffer(display_texture); and draw only a piece of the first texture like this : SetBuffer(display_texture); DrawImage(loaded_texture,0,0,128,-128); // x and y are 0 ,so we see the left top image But I can't see anything when I display the created image. Does anyone know how to make that? Quote Link to comment Share on other sites More sharing options...
smashthewindow Posted March 27, 2012 Share Posted March 27, 2012 I've searched everywhere to achieve the samething while writing a GWEN Leadwerks renderer. I believe this cannot be achieved with only pure Leadwerks command set, although using OpenGL is an option. Quote Blog & Portfolio Current project: moon.chase.star Link to comment Share on other sites More sharing options...
Daimour Posted March 28, 2012 Share Posted March 28, 2012 You can draw a little piece of big texture to little texture. Then you can use that little texture as you want. Code from the video: --preparations local cbst = LoadTexture("abstract::cobblestones.dds") local buf = CreateBuffer(128, 128, BUFFER_COLOR) local tex = CreateTexture(128, 128, TEXTURE_RGB) SetColorBuffer(buf, tex, 0, 0) --render image to custom buffer SetBuffer(buf) DrawImage(cbst, MouseX() - 512, -(MouseY() - 512), 1024, -1024) SetBuffer(BackBuffer()) --draw custom buffer to back buffer DrawImage(tex, 100, 100, 128, 128) 2 Quote Link to comment Share on other sites More sharing options...
Daimour Posted March 28, 2012 Share Posted March 28, 2012 And a little explosions. Just for fun. Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted March 28, 2012 Author Share Posted March 28, 2012 Thanks.I heard that it's faster to load the frames as separate textures and only change the MaterialTexture.Is that right ,or would you say that the methode with the 2nd buffer is better? Quote Link to comment Share on other sites More sharing options...
Daimour Posted March 28, 2012 Share Posted March 28, 2012 I heard that it's faster to load the frames as separate textures and only change the MaterialTexture.Is that right ,or would you say that the methode with the 2nd buffer is better? I think they are the same. They different only in getting small texture (grabbing it from the big one vs loading from separate file). Since it happens only once at starting game the difference has no matter. If you are looking for the fastest way, I think it would be fastest to use one big texture and special shader to change UV coordinates. Quote Link to comment Share on other sites More sharing options...
smashthewindow Posted March 28, 2012 Share Posted March 28, 2012 Just integrated the buffer-based system on GWEN... I'm having terrible FPS though. Maybe you aren't suppose to use buffer method extensively (for example, like a complete GUI, where you would do this process multiple times in a single frame). Quote Blog & Portfolio Current project: moon.chase.star Link to comment Share on other sites More sharing options...
Daimour Posted March 28, 2012 Share Posted March 28, 2012 Rendering something to buffers every frame is not the best idea. Do it only if your picture changes every frame (for post-effects, mirrors, picture in picture etc.). In other cases render picture only once to get desired texture. And then use this texture multiple times where you need to draw it. I think you can use such approach for GUI. Quote Link to comment Share on other sites More sharing options...
Furbolg Posted March 28, 2012 Share Posted March 28, 2012 Thats not exact the way i thought you would go. You guys know the video where Josh creates a cube on 3 different ways ? One way was to create it by code with AddVertex etc. That was my Idea, you have 1 big texture and then update the UV coordinates of your mesh/plane 1 Quote Link to comment Share on other sites More sharing options...
Daimour Posted March 28, 2012 Share Posted March 28, 2012 That was my Idea, you have 1 big texture and then update the UV coordinates of your mesh/plane Yes. It's good idea. May be the best. If you have access to vertices of course. Quote Link to comment Share on other sites More sharing options...
Furbolg Posted March 28, 2012 Share Posted March 28, 2012 Maybe someone can write a pixelshader for this ? I dont know much about shader right now. Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted March 28, 2012 Author Share Posted March 28, 2012 I think I will make a shader but later ,because I have to finish my own class Does somebody know how to make a frameupdater (for animationframes) for integers which is dependent from the appspeed? I tryied it with frame = frame + 0.1 * speed * AppSpeed() but when frame is an integer it doesn't work. Quote Link to comment Share on other sites More sharing options...
Furbolg Posted March 28, 2012 Share Posted March 28, 2012 Which language do you use ? I mostly doing animations with timers (not windows/winapi timer more like int counter = GetTickCount(). Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted March 28, 2012 Author Share Posted March 28, 2012 I use C/C++ Quote Link to comment Share on other sites More sharing options...
Furbolg Posted March 28, 2012 Share Posted March 28, 2012 Then try GetTickCount() or TimeGetTime() if its not precise enaugh then you can use http://cplus.about.com/od/howtodothingsi2/a/timing.htm (high performance counter). Quote Link to comment Share on other sites More sharing options...
shadmar Posted September 17, 2012 Share Posted September 17, 2012 I made a shader for ChrisV for playing spritesheets exactly like this. Works in the editor. (lua) Give me a pm if you want to test it ParaToxic. Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.