资源简介
Unity3D调用Native OpenGL,Unity3D支持调用C++工程的OpenGL渲染,使用RenderingPlugin DLL方式。
代码片段和文件信息
// Example low level rendering Unity plugin
#include “UnityPluginInterface.h“
#include
#include
// --------------------------------------------------------------------------
// Include headers for the graphics APIs we support
#if SUPPORT_D3D9
#include
#endif
#if SUPPORT_OPENGL
#if UNITY_WIN
#include
#else
#include
#endif
#endif
// --------------------------------------------------------------------------
// Helper function to print a string
static void DebugLog (const char* str)
{
#if UNITY_WIN
OutputDebugStringA (str);
#else
printf (“%s“ str);
#endif
}
// --------------------------------------------------------------------------
// SetTimeFromUnity an example function we export which is called by one of the scripts.
static float g_Time;
extern “C“ void EXPORT_API SetTimeFromUnity (float t)
{
g_Time = t;
}
// --------------------------------------------------------------------------
// UnitySetGraphicsDevice
static int g_DeviceType = -1;
#if SUPPORT_D3D9
static IDirect3DDevice9* g_D3D9Device;
// In D3D9 case we‘ll also create a dynamic vertex buffer just to demonstrate
// how to handle D3D9 device resets.
static IDirect3DVertexBuffer9* g_D3D9DynamicVB;
#endif
extern “C“ void EXPORT_API UnitySetGraphicsDevice (void* device int deviceType int eventType)
{
// Set device type to -1 i.e. “not recognized by our plugin“
g_DeviceType = -1;
#if SUPPORT_D3D9
// If we‘ve got a D3D9 device remember device pointer and device type.
// The pointer we get is IDirect3DDevice9.
if (deviceType == kGfxRendererD3D9)
{
DebugLog (“Set D3D9 graphics device\n“);
g_D3D9Device = (IDirect3DDevice9*)device;
g_DeviceType = deviceType;
// Create or release a small dynamic vertex buffer depending on the event type.
switch (eventType) {
case kGfxDeviceEventInitialize:
case kGfxDeviceEventAfterReset:
// After device is initialized or was just reset create the VB.
if (!g_D3D9DynamicVB)
g_D3D9Device->CreateVertexBuffer (1024 D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC 0 D3DPOOL_DEFAULT &g_D3D9DynamicVB NULL);
break;
case kGfxDeviceEventBeforeReset:
case kGfxDeviceEventShutdown:
// Before device is reset or being shut down release the VB.
if (g_D3D9DynamicVB)
{
g_D3D9DynamicVB->Release();
g_D3D9DynamicVB = NULL;
}
break;
}
}
#endif
#if SUPPORT_OPENGL
// If we‘ve got an OpenGL device remember device type. There‘s no OpenGL
// “device pointer“ to remember since OpenGL always operates on a currently set
// global context.
if (deviceType == kGfxRendererOpenGL)
{
DebugLog (“Set OpenGL graphics device\n“);
g_DeviceType = deviceType;
}
#endif
}
// --------------------------------------------------------------------------
// SetDefaultGraphicsState
//
// Helper function to setup some “sane“ g
- 上一篇:squish 帮助手册
- 下一篇:vc++6.0简体中文版
相关资源
- PictureControl
- Dlg_OpenGL
- mfc/cuda/opengl程序
- opengl在MFC平台上绘制三维图形并实现
- 对话框opengl简单程序
- 基于mfc中opengl鼠标控制视图旋转缩放
- OpenGL从高度图创建三维地形三维漫游
- OpenGL编程,画一个球体
- OpenGL_readObj.zip
- 3D天空迷宫.zip
- 基于mfc和opengl的6R机械臂仿真程序
- C++ 解析rtsp流后返回Iplimage,用Opengl显
- Computer Graphics Programming in OpenGL with C
- 基于VC++和OpenGL实现的IGM机器人手臂三
- OpenGL选择和拾取3D模型
- openGL显示动态的雪人
- opengl实现导入正方体obj文件+旋转+平移
- MFC下实现OpenGL纹理贴图
- OpenGL 绘制立方体、茶壶、环面等稍复
- OpenGL视口变换
- OpenGL模拟Minecraft
- OpenGL计算机图形学2D太阳系模型
- OpenGL应用(动画渐变色显示)
- OpenGL应用2(碰撞检测)
- OpenGL编程指南(原书第7版)中文扫描
- OpenGL+MFC实现旋转、缩放、平移
- 基于MFC opengl读取obj并求法向量
-
bvh pla
yer - qtOpenGLDemo2.rar
- opengl圆柱贴图程序,可以直接运行
评论
共有 条评论