Jump to content

Recommended Posts

Posted

I need to save 6 images of my surroundings for a static cubemap at FOV90

Is there anyway I can dump current camera to a image file?

2.5 had a savebuffer, but I couldn't find any similar for 3.0.

HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB

Posted

buffer->colorcomponent[0]->GetPixels();

 

Then save the pixel data to a bitmap. Here's some code for loading bitmaps, so it's just this reversed:

#pragma once

#include "../Leadwerks3D.h"

namespace Leadwerks3D
{
bool BMPLoader::Load(AssetReference* assetreference, Stream* stream)
{
	int format, hsize, pad, hoffset, width, height, planes, bits, compression, isize, xpels, ypels, inuse, size, cols, x, y, r, g, b;
	Bank* pixels, *data;
	TextureReference* texturereference = (TextureReference*)assetreference;

	if (stream->ReadByte()!=Asc("B")) return false;
	if (stream->ReadByte()!=Asc("M")) return false;
	hsize=stream->ReadInt();
	pad=stream->ReadInt();
	hoffset=stream->ReadInt();
	size=stream->ReadInt();
	width=stream->ReadInt();
	height=stream->ReadInt();
	planes=stream->ReadShort();
	bits=stream->ReadShort();
	compression=stream->ReadInt();
	isize=stream->ReadInt();
	xpels=stream->ReadInt();
	ypels=stream->ReadInt();
	cols=stream->ReadInt();
	inuse=stream->ReadInt();
	hoffset -= 54;

	if (bits==32)
	{
		format = TEXTURE_RGBA;
	}
	else
	{
		format = TEXTURE_RGB;
	}

	switch (bits)
	{
	case 1:

		break;
	case 4:

		break;
	case 8:

		break;
	case 24:
		format = TEXTURE_BGR;
		pixels = CreateBank(width*height*3);
		//stream->ReadBytes(pixels->buf,pixels->GetSize());
		data = CreateBank(width*height*3);
		//stream->ReadBytes(data->buf,data->GetSize());

		for (y=height-1; y>-1; y--)
		{
			//for (x=0; x<width; x++)
			//{
				//r = stream->ReadByte();
				//g = stream->ReadByte();
				//b = stream->ReadByte();
				/*
				r = data->PeekByte(((height-1-y)*width+x)*3+0);
				g = data->PeekByte(((height-1-y)*width+x)*3+1);
				b = data->PeekByte(((height-1-y)*width+x)*3+2);

				pixels->PokeByte((width*y+x)*3+2,r);
				pixels->PokeByte((width*y+x)*3+1,g);
				pixels->PokeByte((width*y+x)*3+0,B);
				*/
				stream->ReadBytes(pixels->buf + (y*width*3),width*3);
			//}
		}

		//

		break;
	case 32:
		format = TEXTURE_RGBA;
		pixels = CreateBank(width*height*4);
		break;
	default:
		return false;
	}

	texturereference->Initialize(width,height,format,0,0);
	texturereference->GenerateMipmaps(pixels);

	delete pixels;
	return true;
}
}

 

 

 

 

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...