Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / RenderToImage does not work like expected

Author
Message
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 12th Sep 2016 19:03
Intel HD 3000 on Windows 10 64 Bit.

I have a 3D Model (object) with an JPEG as Texture. I want to colorize the texture and make a new object or instance with a colored texture on it.
I was using:

renimg = CreateRenderImage(1024,1024,0,0 ) // this would be black
And my WindowSize of the App is 1280 x 720
Virtual Screen Size is 1920 x 1080

I draw a box on the RenderTarget
DrawBox(0,0,GetImageWidth(renimg),GetImageHeight(renimg),MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),MakeColor(255,255,255),1)

and I put this image on the 3D-Object, but it had black holes. I thought it would be easy, to colorchange or manipulate a texture.

With DrawSprite, CreateSprite(img) and LoadSprite etc.

The problem was, that the RenderThings will not depend on the RenderTarget-Image-Size, but on the ScreenResulution. Maybe this is only a problem with IntelHD 3000.
But I also don't want to write all 2D-Drawing functions for MemBlocks new.

When my RenderTarget is bigger than my screen-resolution, some space of the rendertarget-image will be black. How would I be able to generate an image for print?
In the help-page for CreateRenderImage is no advice for this issue, so it toke me about half this day, to figure this problem out.


Also "SetResolutionMode( 0)" does not effect the Windows 10 program. How can I get nativ 720p but scaled to 1080p? The performance will shrink in full resulution.

Okay, I read again "SetRenderToImage"-help.

It only seems to work if:

Window-Size, VirtualResolution and CreateRenderImage are the exact same size. 128 x 128, 256 x 256, 512 x 512, 1024 x 1024

But this is not, what I want. The problem here is, that I have to switch also the native resolution for getting it to work.

I testet:

Window-Size 512x512, Virtual-Resolution 256x256, RenderTarget 1024x1024 and it worked, but if RenderTarget and VirtualResolution not the same, keep in mind, to scale the Sprite before using DrawSprite()
Maybe this is also the problem when I am using 1280 x 720 as Window Size and my Virtual Resolution is not the same, that I have to Scale something, but I thought, that DrawBox would draw from 0 ... to ImageWidth, but maybe I have to not think of it like another image in memory, but a second screen,
where all is the same like my Window-Resolution. So I have maybe to scale also the Sprite, if it is 1024 x 1024, by xScale = 1.25 and yScale = 0.703125

Solution:

The Virtual Resolution has to be not bigger than the "Real"-Resolution. Maybe that was my mistake.







BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 12th Sep 2016 20:09
I found the best way to manage this issue is to "cheat".

Set your virtual resolution to the same as your screen resolution.
Render and get your image
Set the resolution back to virtual resolution.
Also, always use power of 2 images.

It also took me hours of messing around to understand the process! I have an app that renders to an image every cycle, and for this one I have had to use the complicated method of recalculating the dimensions, I can't resize the resolution every frame.
I believe this is because it uses the GPU to render the image.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2024-09-29 19:15:37
Your offset time is: 2024-09-29 19:15:37