コード例 #1
0
void OpenGLModule::sharedContextCreated()
{
    // report OpenGL information
    globalOutputStream() << "GL_VENDOR: "
                         << reinterpret_cast<const char*>(glGetString(GL_VENDOR)) << "\n";
    globalOutputStream() << "GL_RENDERER: "
                         << reinterpret_cast<const char*>(glGetString(GL_RENDERER)) << "\n";
    globalOutputStream() << "GL_VERSION: "
                         << reinterpret_cast<const char*>(glGetString(GL_VERSION)) << "\n";
    globalOutputStream() << "GL_EXTENSIONS: "
                         << reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)) << "\n";

    GLenum err = glewInit();
    if (err != GLEW_OK)	{
        // glewInit failed
        globalErrorStream() << "GLEW error: " <<
                            reinterpret_cast<const char*>(glewGetErrorString(err));
    }

    GlobalRenderSystem().extensionsInitialised();
    GlobalRenderSystem().realise();

    _font = glfont_create("Sans 8");
    m_font = _font.getDisplayList();
    m_fontHeight = _font.getPixelHeight();
}
コード例 #2
0
void OpenGLModule::sharedContextCreated()
{
	// report OpenGL information
	rMessage() << "GL_VENDOR: "
		<< reinterpret_cast<const char*>(glGetString(GL_VENDOR)) << std::endl;
	rMessage() << "GL_RENDERER: "
		<< reinterpret_cast<const char*>(glGetString(GL_RENDERER)) << std::endl;
	rMessage() << "GL_VERSION: "
		<< reinterpret_cast<const char*>(glGetString(GL_VERSION)) << std::endl;
	rMessage() << "GL_EXTENSIONS: "
		<< reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)) << std::endl;

	GLenum err = glewInit();

	if (err != GLEW_OK)
	{
		// glewInit failed
		rError() << "GLEW error: " <<
			reinterpret_cast<const char*>(glewGetErrorString(err));
	}

	GlobalRenderSystem().extensionsInitialised();
	GlobalRenderSystem().realise();

	_font.reset(new wxutil::GLFont(wxutil::GLFont::FONT_SANS, 12));
}
コード例 #3
0
void RadiantSelectionSystem::initialiseModule(const ApplicationContext& ctx) 
{
    rMessage() << "RadiantSelectionSystem::initialiseModule called.\n";

    constructStatic();

    SetManipulatorMode(eTranslate);
    pivotChanged();

    _sigSelectionChanged.connect(
        sigc::mem_fun(this, &RadiantSelectionSystem::pivotChangedSelection)
    );

    GlobalGrid().signal_gridChanged().connect(
        sigc::mem_fun(this, &RadiantSelectionSystem::pivotChanged)
    );

    GlobalRegistry().signalForKey(RKEY_ROTATION_PIVOT).connect(
        sigc::mem_fun(this, &RadiantSelectionSystem::keyChanged)
    );

    // Pass a reference to self to the global event manager
    GlobalEventManager().connectSelectionSystem(this);

    // Connect the bounds changed caller
    GlobalSceneGraph().signal_boundsChanged().connect(
        sigc::mem_fun(this, &RadiantSelectionSystem::onSceneBoundsChanged)
    );

    GlobalRenderSystem().attachRenderable(*this);
}
コード例 #4
0
void MD5ModelNode::constructRemaps() {
	// greebo: Acquire the ModelSkin reference from the SkinCache
	// Note: This always returns a valid reference
	ModelSkin& skin = GlobalModelSkinCache().capture(_skin);

	// Iterate over all surfaces and remaps
	_surfaceRemaps.resize(_model->size());
	MD5ModelNode::SurfaceRemaps::iterator j = _surfaceRemaps.begin();
	for (MD5Model::const_iterator i = _model->begin(); i != _model->end(); ++i,++j) {
		// Get the replacement shadername
		std::string remap = skin.getRemap((*i)->getShader());

		if (!remap.empty()) {
			// We have a valid remap, store it
			j->name = remap;
			j->shader = GlobalRenderSystem().capture(remap);
		} else {
			// No remap, leave the name as it is
			j->shader = ShaderPtr();
		}
	}

	// Refresh the scene
	GlobalSceneGraph().sceneChanged();
}
コード例 #5
0
void SpacePartitionRenderer::uninstallRenderer()
{
	_renderableSP.setRenderSystem(RenderSystemPtr());
	_renderableSP.setSpacePartition(scene::ISpacePartitionSystemPtr());

	GlobalRenderSystem().detachRenderable(_renderableSP);
}
コード例 #6
0
void LightNode::onInsertIntoScene()
{
	// Call the base class first
	EntityNode::onInsertIntoScene();

	GlobalRenderSystem().attachLight(*this);
}
コード例 #7
0
void SpacePartitionRenderer::installRenderer()
{
	_renderableSP.setSpacePartition(GlobalSceneGraph().getSpacePartition());
	_renderableSP.setRenderSystem(boost::dynamic_pointer_cast<RenderSystem>(
		module::GlobalModuleRegistry().getModule(MODULE_RENDERSYSTEM)));

	GlobalRenderSystem().attachRenderable(_renderableSP);
}
コード例 #8
0
MD5ModelNode::MD5ModelNode(const MD5ModelPtr& model) :
	_model(new MD5Model(*model)), // create a copy of the incoming model, we need our own instance
	_surfaceLightLists(_model->size())
{
	_lightList = &GlobalRenderSystem().attachLitObject(*this);

	Node::setTransformChangedCallback(Callback((boost::bind(&MD5ModelNode::lightsChanged, this))));
}
コード例 #9
0
void MapPreview::initialisePreview() {

	// Grab the GL widget with sentry object
	gtkutil::GLWidgetSentry sentry(_glWidget);

	// Clear the window
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glClearColor(0.0, 0.0, 0.0, 0);
	glClearDepth(100.0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	// Set up the camera
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(PREVIEW_FOV, 1, 0.1, 10000);
	
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
			
	// Set up the lights
	glEnable(GL_LIGHTING);

	glEnable(GL_LIGHT0);
	GLfloat l0Amb[] = { 0.3f, 0.3f, 0.3f, 1.0f };
	GLfloat l0Dif[] = { 1.0f, 1.0f, 1.0f, 1.0f };
	GLfloat l0Pos[] = { 1.0f, 1.0f, 1.0f, 0.0f };
	glLightfv(GL_LIGHT0, GL_AMBIENT, l0Amb);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, l0Dif);
	glLightfv(GL_LIGHT0, GL_POSITION, l0Pos);
	
	glEnable(GL_LIGHT1);
	GLfloat l1Dif[] = { 1.0, 1.0, 1.0, 1.0 };
	GLfloat l1Pos[] = { 0.0, 0.0, 1.0, 0.0 };
	glLightfv(GL_LIGHT1, GL_DIFFUSE, l1Dif);
	glLightfv(GL_LIGHT1, GL_POSITION, l1Pos);

	// Reset the rotation
	_rotation = Matrix4::getIdentity();
	
	// Calculate camera distance so model is appropriately zoomed
	_camDist = -(20 * 2.0); 

	_stateSelect1 = GlobalRenderSystem().capture("$CAM_HIGHLIGHT");
	_stateSelect2 = GlobalRenderSystem().capture("$CAM_OVERLAY");
}
コード例 #10
0
// Capture the shaders for the current colour
void Doom3EntityClass::captureColour()
{
	// Set the entity colour to default, if none was specified
	if (_colour == Vector3(-1, -1, -1)) {
		_colour = ColourSchemes().getColour("default_entity");
	}

	// Capture fill and wire versions of the entity colour
	std::string fillCol = _colourTransparent ? 
		(boost::format("[%g %g %g]") % _colour[0] % _colour[1] % _colour[2]).str() : 
		(boost::format("(%g %g %g)") % _colour[0] % _colour[1] % _colour[2]).str();

	std::string wireCol = (boost::format("<%g %g %g>") % _colour[0] % _colour[1] % _colour[2]).str();

	_fillShader = GlobalRenderSystem().capture(fillCol);
	_wireShader = GlobalRenderSystem().capture(wireCol);
}
コード例 #11
0
void Doom3EntityCreator::initialiseModule(const ApplicationContext& ctx)
{
    globalOutputStream() << "Doom3EntityCreator::initialiseModule called." << std::endl;

    LightShader::m_defaultShader = GlobalRegistry().get("game/defaults/lightShader");

    // Construct Doom3Group stuff
    CurveEditInstance::initialiseShaders();

    RenderablePivot::StaticShader() = GlobalRenderSystem().capture("$PIVOT");

    GlobalRenderSystem().attachRenderable(RenderableTargetInstances::Instance());

    GlobalEventManager().addRegistryToggle("ToggleShowAllLightRadii", RKEY_SHOW_ALL_LIGHT_RADII);
    GlobalEventManager().addRegistryToggle("ToggleShowAllSpeakerRadii", RKEY_SHOW_ALL_SPEAKER_RADII);
    GlobalEventManager().addRegistryToggle("ToggleDragResizeEntitiesSymmetrically", RKEY_DRAG_RESIZE_SYMMETRICALLY);
}
コード例 #12
0
void Doom3EntityCreator::shutdownModule()
{
    globalOutputStream() << "Doom3EntityCreator::shutdownModule called." << std::endl;

    GlobalRenderSystem().detachRenderable(RenderableTargetInstances::Instance());

    // Destroy the settings instance
    EntitySettings::destroy();
}
コード例 #13
0
// greebo: Construct a new RenderablePicoModel instance, we re-use the surfaces only
PicoModelNode::PicoModelNode(const RenderablePicoModelPtr& picoModel) :
    _picoModel(new RenderablePicoModel(*picoModel)),
    _name(picoModel->getFilename()),
    _lightList(GlobalRenderSystem().attachLitObject(*this))
{
    Node::setTransformChangedCallback(boost::bind(&PicoModelNode::lightsChanged, this));

    // Update the skin
    skinChanged("");
}
コード例 #14
0
void Doom3MapCompiler::shutdownModule()
{
	if (_debugRenderer)
	{
		GlobalRenderSystem().detachRenderable(*_debugRenderer);
		_debugRenderer.reset();
	}

	_procFile.reset();
}
コード例 #15
0
void RadiantSelectionSystem::shutdownModule() 
{
    // greebo: Unselect everything so that no references to scene::Nodes
    // are kept after shutdown, causing destruction issues.
    setSelectedAll(false);
    setSelectedAllComponents(false);

    GlobalRenderSystem().detachRenderable(*this);

    destroyStatic();
}
コード例 #16
0
void LightNode::onRemoveFromScene()
{
	// Call the base class first
	EntityNode::onRemoveFromScene();

	GlobalRenderSystem().detachLight(*this);

	// De-select all child components as well
	setSelectedComponents(false, SelectionSystem::eVertex);
	setSelectedComponents(false, SelectionSystem::eFace);
}
コード例 #17
0
MD5ModelNode::MD5ModelNode(const MD5ModelPtr& model) :
	_model(model),
	_surfaceLightLists(_model->size()), 
	_surfaceRemaps(_model->size())
{
	_lightList = &GlobalRenderSystem().attach(*this);

	Node::setTransformChangedCallback(Callback((boost::bind(&MD5ModelNode::lightsChanged, this))));

	constructRemaps();
}
コード例 #18
0
ファイル: GlyphSet.cpp プロジェクト: codereader/DarkRadiant
void GlyphSet::realiseShaders()
{
	// For each glyph, acquire the appropriate shader
	for (std::size_t i = 0; i < q3font::GLYPH_COUNT_PER_FONT; ++i)
	{
		TexturePathMap::const_iterator found = _textures.find(_glyphs[i]->texture);
		assert(found != _textures.end());

		_glyphs[i]->shader = GlobalRenderSystem().capture(found->second);
	}
}
コード例 #19
0
void Doom3MapCompiler::setDmapRenderOption(const cmd::ArgumentList& args)
{
	if (args.size() == 0)
	{
		rMessage() << "Usage: setDmapRenderOption <nodeId>" << std::endl;
		return;
	}

	if (!_debugRenderer)
	{
		_debugRenderer.reset(new DebugRenderer);
		GlobalRenderSystem().attachRenderable(*_debugRenderer);
	}

	_debugRenderer->setProcFile(_procFile);
	_debugRenderer->setActiveNode(args[0].getInt());

	GlobalSceneGraph().sceneChanged();
}
コード例 #20
0
MD5ModelNode::~MD5ModelNode() {
	destroyRemaps();
	GlobalRenderSystem().detach(*this);
}
コード例 #21
0
MD5ModelNode::~MD5ModelNode()
{
	GlobalRenderSystem().detachLitObject(*this);
}
コード例 #22
0
void MapPreview::draw() {
	if (_root == NULL) return;

	// Create scoped sentry object to swap the GLWidget's buffers
	gtkutil::GLWidgetSentry sentry(_glWidget);

	// Set up the render
	glClearColor(0.2f, 0.2f, 0.2f, 0.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	AABB aabb(Vector3(0,0,0), Vector3(10,10,10));

	// Premultiply with the translations
	glLoadIdentity();
	glTranslatef(0, 0, _camDist); // camera translation
	glMultMatrixd(_rotation); // post multiply with rotations
	glRotatef(90, -1, 0, 0); // axis rotation (y-up (GL) -> z-up (model))

	// Render the map
	glEnable(GL_LIGHTING);
	glTranslatef(-aabb.origin.x(), -aabb.origin.y(), -aabb.origin.z()); // model translation

	// Start rendering
	unsigned int globalstate = 
		RENDER_DEPTHTEST|RENDER_COLOURWRITE|RENDER_DEPTHWRITE|
		RENDER_ALPHATEST|RENDER_BLEND|RENDER_CULLFACE|RENDER_COLOURARRAY|
		RENDER_OFFSETLINE|RENDER_POLYGONSMOOTH|RENDER_LINESMOOTH|
		RENDER_COLOURCHANGE;

	globalstate |=	RENDER_FILL | RENDER_LIGHTING | RENDER_TEXTURE_2D | 
					RENDER_SMOOTH | RENDER_SCALED | RENDER_BUMP | RENDER_PROGRAM | RENDER_SCREEN;

	CamRenderer renderer(globalstate, _stateSelect1, _stateSelect2, Vector3(0,0,_camDist));
	MapPreviewView view;

	// Save the new GL matrix for GL draw
	glGetDoublev(GL_MODELVIEW_MATRIX, view.modelView);
	glGetDoublev(GL_PROJECTION_MATRIX, view.projection);

	// Instantiate a new walker class
	RenderHighlighted renderHighlightWalker(renderer, view);

	// Small helper class to use scene::Graph::Walkers for direct traversal
	class RenderAdaptor :
		public scene::NodeVisitor
	{
		scene::Graph::Walker& _walker;
	public:
		RenderAdaptor(scene::Graph::Walker& walker) :
			_walker(walker)
		{}

		bool pre(const scene::INodePtr& node)
		{
			_walker.visit(node);
			return true;
		}
	} adaptor(renderHighlightWalker);

	// Submit renderables from this map root
	Node_traverseSubgraph(_root, adaptor);
	
	// Submit renderables directly attached to the ShaderCache
	RenderHighlighted walker(renderer, view);
	GlobalRenderSystem().forEachRenderable(walker.getRenderableCallback());

	renderer.render(view.modelView, view.projection);
}
コード例 #23
0
void RadiantSelectionSystem::constructStatic() {
    _state = GlobalRenderSystem().capture("$POINT");
    TranslateManipulator::_stateWire = GlobalRenderSystem().capture("$WIRE_OVERLAY");
    TranslateManipulator::_stateFill = GlobalRenderSystem().capture("$FLATSHADE_OVERLAY");
    RotateManipulator::_stateOuter = GlobalRenderSystem().capture("$WIRE_OVERLAY");
}
コード例 #24
0
void OpenGLModule::sharedContextDestroyed()
{
	_font.reset();
	GlobalRenderSystem().unrealise();
}
コード例 #25
0
/*greebo: This is a callback function that gets connected in the constructor
* Don't know exactly what it does, but it seems to notify the shader cache that the light has moved or
* something like that.
*/
void LightNode::lightChanged() {
	GlobalRenderSystem().lightChanged(*this);
}