示例#1
0
// TextureData
TextureData::TextureData(GLenum _textureTarget, int _width, int _height, int _numTextures,
	unsigned char** _pixelData, GLfloat* _filters, GLenum* _internalFormat,
	GLenum* _format, bool _clamp, GLenum* _attachments) {
	m_textureID = new GLuint[_numTextures];
	m_textureTarget = _textureTarget;
	m_numTextures = _numTextures;

	width = _width;
	height = _height;

	m_frameBuffer = 0;
	m_renderBuffer = 0;

	InitTextures(_pixelData, _filters, _internalFormat, _format, _clamp);
	InitRenderTargets(_attachments);
}
示例#2
0
void GuardianSystemDemo::Start(HINSTANCE hinst)
{
    ovrResult result;
    result = ovr_Initialize(nullptr);
    if (!OVR_SUCCESS(result)) {
        printf("ovr_Initialize failed"); exit(-1);
    }

    ovrGraphicsLuid luid;
    result = ovr_Create(&mSession, &luid);
    if (!OVR_SUCCESS(result)) {
        printf("ovr_Create failed"); exit(-1);
    }

    if (!DIRECTX.InitWindow(hinst, L"GuardianSystemDemo")) {
        printf("DIRECTX.InitWindow failed"); exit(-1);
    }

    // Use HMD desc to initialize device
    ovrHmdDesc hmdDesc = ovr_GetHmdDesc(mSession);
    if (!DIRECTX.InitDevice(hmdDesc.Resolution.w / 2, hmdDesc.Resolution.h / 2, reinterpret_cast<LUID*>(&luid))) {
        printf("DIRECTX.InitDevice failed"); exit(-1);
    }

    // Use FloorLevel tracking origin
    ovr_SetTrackingOriginType(mSession, ovrTrackingOrigin_FloorLevel);
    
    InitRenderTargets(hmdDesc);
    InitSceneGraph();
    mLastUpdateClock = std::chrono::high_resolution_clock::now();

    // Main Loop
    while (DIRECTX.HandleMessages() && !mShouldQuit)
    {
        ovrSessionStatus sessionStatus;
        ovr_GetSessionStatus(mSession, &sessionStatus);
        if (sessionStatus.ShouldQuit)
            break;

        float elapsedTimeSec = UpdateTimeWithBoundaryTest();
        UpdateBoundaryLookAndFeel();
        UpdateObjectsCollisionWithBoundary(elapsedTimeSec);
        Render();
    }

    ovr_Shutdown();
}
示例#3
0
TextureData::TextureData(GLenum textureTarget, int width, int height, int numTextures, unsigned char** data, GLfloat* filters, GLenum* internalFormat, GLenum* format, bool clamp, GLenum* attachments)
{
	m_textureID = new GLuint[numTextures];
	m_textureTarget = textureTarget;
	m_numTextures = numTextures;
	
	#if PROFILING_SET_2x2_TEXTURE == 0
		m_width = width;
		m_height = height;
	#else
		m_width = 2;
		m_height = 2;
	#endif
	m_frameBuffer = 0;
	m_renderBuffer = 0;
	
	InitTextures(data, filters, internalFormat, format, clamp);
	InitRenderTargets(attachments);
}
示例#4
0
gs_texture_2d::gs_texture_2d(device_t device, uint32_t width, uint32_t height,
		gs_color_format colorFormat, uint32_t levels, const void **data,
		uint32_t flags, gs_texture_type type, bool gdiCompatible,
		bool shared)
	: gs_texture      (device, type, levels, colorFormat),
	  width           (width),
	  height          (height),
	  dxgiFormat      (ConvertGSTextureFormat(format)),
	  isGDICompatible (gdiCompatible),
	  isShared        (shared),
	  isDynamic       ((flags & GS_DYNAMIC) != 0),
	  isRenderTarget  ((flags & GS_RENDERTARGET) != 0),
	  genMipmaps      ((flags & GS_BUILDMIPMAPS) != 0)
{
	InitTexture(data);
	InitResourceView();

	if (isRenderTarget)
		InitRenderTargets();
}
/**
 * Initialize the render manager
 *
 * @param inBufferSizeX Width of the full screen render buffer 
 * @param inBufferSizeY Height of the full screen render buffer 
 */
bool RenderManager::Init(const int inBufferSizeX, const int inBufferSizeY)
{
	// Set the size of the render buffers
	fullScreenBufferSizeX = inBufferSizeX;
	fullScreenBufferSizeY = inBufferSizeY;

	gRenderAPI->Init(fullScreenBufferSizeX, fullScreenBufferSizeY, defaultSceneColorBuffer, defaultSceneDepthBuffer); 
	InitRenderTargets();
	InitShaders();
	InitFonts();

	// Create full-screen buffers
	VertexContainer_P3U2 VertexData[] = 
	{
		-1,1,0,		0,0,
		1,1,0,		1,0,
		-1,-1,0,	0,1,
		1,-1,0,		1,1
	};
	
	short IndexData[] = 
	{
		0, 1, 2,
		1, 3, 2
	};

	// Init full screen buffers
	fullScreenVB = gRenderAPI->CreateVertexBuffer(VFMT_P3U2, 4, &VertexData);
	fullScreenIB = gRenderAPI->CreateIndexBuffer(IFMT_16Bit, 6, &IndexData);

	// Init simple primitives
	unitSphereMesh = gMeshManager.LoadStaticMesh("UnitSphere.nff");
	unitConeMesh = gMeshManager.LoadStaticMesh("UnitCone.nff");

	// Init textures
	defaultTexture = gRenderAPI->CreateTexture2DFromFile("checkerboard.png");

	return true;
}