CgDxEffect::CgDxEffect(D3D11GraphicDevice* device): mContext(0), mDevice(device) { mContext = cgCreateContext(); mist_assert(mContext); cgD3D11SetDevice(mContext, device->getD3DDevice()); }
CgDxEffect::CgDxEffect(D3D11GraphicDevice* device): mContext(0), mDevice(device) { mContext = cgCreateContext(); mist_assert(mContext); cgD3D11SetDevice(mContext, device->getD3DDevice()); cgD3D11SetManageTextureParameters(mContext, CG_TRUE); }
Array<uint8> zlib_compress(uint8* input, uint32 input_length, ZlibCompressionMethod method) { uint32 buffer_size = 1024; Array<uint8> buffer; buffer.resize(buffer_size); int err; z_stream strm; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; strm.next_in = input; strm.avail_in = input_length; strm.next_out = &buffer.front(); strm.avail_out = buffer_size; const int windowBits = (method == ZCM_Gzip) ? 15 + 16 : 15; err = deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, windowBits, 8, Z_DEFAULT_STRATEGY); if (err != Z_OK) { log_zlib_error(err); return Array<uint8>(); } do { err = deflate(&strm, Z_FINISH); mist_assert(err != Z_STREAM_ERROR); if (err == Z_OK) { buffer.resize(buffer_size * 2); strm.next_out = (Bytef *)(&buffer.front() + buffer_size); strm.avail_out = buffer_size; buffer_size *= 2; } } while (err == Z_OK); if (err != Z_STREAM_END) { log_zlib_error(err); deflateEnd(&strm); return Array<uint8>(); } size_t outLength = buffer_size - strm.avail_out; deflateEnd(&strm); buffer.resize(outLength); return buffer; }
void Context::loadGraphicFactory(const UknString& name) { mGraphicFactoryLoader.close(); UknString libName = mist::get_lib_name(name); if(!mist::File::FileExists(libName)) { libName = mist::Path::GetApplicationPath() + libName; } if(mGraphicFactoryLoader.open(string::WStringToString(libName).c_str())) { CreateGraphicFactoryFunc func = (CreateGraphicFactoryFunc)mGraphicFactoryLoader.getProc("CreateGraphicFactory"); if(func) { func(mGraphicFactory); mist_assert(mGraphicFactory.isValid()); } } else { mist::MessageBox::Show(L"Unable to load renderer plugin " + libName, L"Fatal Error", MBO_OK | MBO_IconError); } }
void AppLauncher::doCreate() { mist_assert(mInited); GraphicDevice& graphic_device = Context::Instance().getGraphicFactory().getGraphicDevice(); try { mMainWindow = graphic_device.createRenderWindow(mName, Context::Instance().getCfg().render_cfg); } catch(mist::Exception& e) { mist::MessageBox::Show(e.what(), L"Error", mist::MBB_OK | mist::MBO_IconError); } if(!mMainWindow) return terminate(); mMainWindow->onClose() += Bind(this, &AppLauncher::onWindowClose); // log basic information Logger::Instance().setFeature(LF_PrependRunningTime, false); log_info(format_string("Project Unknown %d.%d Rev %d", UKN_VERSION_MAJOR, UKN_VERSION_MINOR, UKN_VERSION_REV)); log_info(SystemInformation::GetOSVersion()); log_info(format_string("CPU Speed: %d mhz", SystemInformation::GetProcessorSpeed())); log_info(format_string("Memory Size: %d kb", SystemInformation::GetMemorySize() / 1024)); CpuInfo cpuinfo; log_info(format_string("CPU: %s, %s, Cores: %d Threads: %d", cpuinfo.getCPUString().c_str(), cpuinfo.getCPUBrandString().c_str(), cpuinfo.getNumCores(), cpuinfo.getNumHWThreads())); log_info(graphic_device.description()); GraphicDeviceCaps caps; graphic_device.fillGraphicCaps(caps); log_info(format_string("Graphic Device Caps:\n\tMaxTextureSize:\t(%d, %d)\n\tMaxCubeMapSize:\t%d\n\tMaxIndices:\t%d\n\tMaxVertices:\t%d\n\tMaxPixelTextureUnits:\t%d\n\tMaxVertexTextureUnits:\t%d\n", caps.max_texture_width, caps.max_texture_height, caps.max_texture_cube_map_size, caps.max_indices, caps.max_vertices, caps.max_pixel_texture_units, caps.max_vertex_texture_units)); Logger::Instance().setFeature(LF_PrependRunningTime, true); // setup default rendering states BlendStateObject::InitializeBuildInStates(); RasterizerStateObject::InitializeBuildInStates(); SamplerStateObject::InitializeBuildInStates(); DepthStencilStateObject::InitializeBuildInStates(); graphic_device.setBlendState(BlendStateObject::BlendOff()); graphic_device.setRasterizerState(RasterizerStateObject::CullCounterClockwise()); graphic_device.setSamplerState(SamplerStateObject::LinearClamp()); graphic_device.setDepthStencilState(DepthStencilStateObject::Default()); }
void FrameBuffer::attach(uint32 attachment, const RenderViewPtr& view) { switch(attachment) { case ATT_DepthStencil: if(mRSView) { this->detach(attachment); } mRSView = view; mIsDepthBuffered = true; // to do element formats switch(view->format()) { case EF_D16: mDepthBits = 16; mStencilBits = 0; break; case EF_D24S8: mDepthBits = 24; mStencilBits = 8; break; case EF_D32: mDepthBits = 32; mStencilBits = 0; break; default: break; } break; default: mist_assert(attachment >= ATT_Color0); uint32 clrid = attachment - ATT_Color0; if(mClearViews.size() < clrid + 1) mClearViews.resize(clrid + 1); mClearViews[clrid] = view; size_t min_clr_index = clrid; for(size_t i = 0; i < clrid; ++i) { if(mClearViews[i]) min_clr_index = i; } if(min_clr_index == clrid) { mWidth = view->width(); mHeight = view->height(); mColorDepth = view->bpp(); mViewPort.left = 0; mViewPort.top = 0; mViewPort.width = mWidth; mViewPort.height = mHeight; } break; } view->onAttached(*this, attachment); mActive = true; mViewsDirty = true; }
bool Connection::operator ==(const Connection &rhs) { mist_assert(con.get()); return con.get() == rhs.con.get(); }
GraphicFactory& Context::getGraphicFactory() const { mist_assert(mGraphicFactory.get()); return *mGraphicFactory; }
SceneManager& Context::getSceneManager() { mist_assert(mScene); return *mScene; }
CgGLEffect::CgGLEffect(GLGraphicDevice* device): mContext(0), mDevice(device) { mContext = cgCreateContext(); mist_assert(mContext); }