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.

Newcomers AppGameKit Corner / [SOLVED] [3D] SetRenderToImage

Author
Message
opethmaniac
2
Years of Service
User Offline
Joined: 19th Jul 2018
Location:
Posted: 7th Aug 2018 15:49
Hi,

I'm quite new to AppGameKit and want to achieve rendering 3D on an image. This image should be applied to a sprite to contain the rendered 3D raster image (for example to create chunky 2*2 pixel)

- Window of size 640*360 (Fullscreen)
- CreateRenderImage of size 400 * 240 (for example) and SetRenderToImage

The above work for 2D drawing (lines, boxes...). It doesn't seem to work for 3D objects. The 3D camera viewport is always rendered fullscreen.

Is there a way to achieve the above?

Thanks for replying.

The author of this post has marked a post as an answer.

Go to answer

IronManhood
5
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 8th Aug 2018 08:45
opethmaniac
2
Years of Service
User Offline
Joined: 19th Jul 2018
Location:
Posted: 8th Aug 2018 10:26
Can this work?

- Render 3D to Fullscreen
- Copy fullscreen content to Sprite or Image
- Resize Sprite to 400 * 240 (example)
- Display Sprite on 640 * 360 screen, so that the 3D content is displayed with 2*2 (or more) pixel size?

If this could work, then example code would be very helpful for me.

Thanks!
JLMoondog
Moderator
11
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 8th Aug 2018 12:27 Edited at: 8th Aug 2018 12:30
Create a memory block from the image, than starting at 0,0-2,2, average the r,g, and b values and change all 4 blocks rgb values to the average, this should make 4 pixels look like 1. Make sense? It's 6am here and haven't been to bed lol, I'll write up an example for you, but I'm pretty sure my idea will work and give you the desired effect. Though honestly, this would probably run 100x faster as a shader.
Bengismo
2
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 8th Aug 2018 12:48 Edited at: 8th Aug 2018 12:51
Memblocks?? whhhyy?

- Render 3D to Fullscreen
Render3d()
- Copy fullscreen content to Sprite or Image
img = GetImage(0,0,xres,yres)
- Resize Image to 400 * 240
imgsml = ResizeImage(img,400,240)
- Display Sprite on 640 * 360 screen, so that the 3D content is displayed with 2*2 (or more) pixel size?
SetImageMagfilter(imgsml,0) - this makes it appear blocky
spr =CreateSprite(imgsml) - create a sprite ans size it
SetSpriteSize(spr,800,480) - size sprite to be twice the image size meaning each pixel will be 2x2 in size
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 8th Aug 2018 16:19 Edited at: 8th Aug 2018 16:20
This post has been marked by the post author as the answer.

I think Opethmaniac does have the right approach... using RenderTargets
After trying my code, please consider removing the "//~" and comment the "sync()" command instead, for performance reasons.
opethmaniac
2
Years of Service
User Offline
Joined: 19th Jul 2018
Location:
Posted: 9th Aug 2018 07:20
Hi Janbo,

thx for your answer, this approach is nearly the perfect solution. Here's my code:


Login to post a reply

Server time is: 2020-10-21 00:48:44
Your offset time is: 2020-10-21 00:48:44