Esempio n. 1
0
void Osg3dView::buildPopupMenu()
{
    QAction *a;
    QMenu *sub = m_popupMenu.addMenu("MouseMode...");

    a = sub->addAction("Orbit", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_O));
    a->setData(QVariant(MM_ORBIT));
    a = sub->addAction("Pan", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_P));
    a->setData(QVariant(MM_PAN));
    a = sub->addAction("Rotate", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_R));
    a->setData(QVariant(MM_ROTATE));
    a = sub->addAction("Zoom", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_Z));
    a->setData(QVariant(MM_ZOOM));
    a = sub->addAction("Pick Center", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_C));
    a->setData(QVariant(MM_PICK_CENTER));
    a = sub->addAction("Select Object", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_S));
    a->setData(QVariant(MM_SELECT));

    sub = m_popupMenu.addMenu("Std View...");
    a = sub->addAction("Top", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_T));
    a->setData(V_TOP);
    a = sub->addAction("Underside", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_U));
    a->setData(V_BOTTOM);
    a = sub->addAction("Front", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_F));
    a->setData(V_FRONT);
    a = sub->addAction("Back", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_B));
    a->setData(V_BACK);
    a = sub->addAction("Right", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_R));
    a->setData(V_RIGHT);
    a = sub->addAction("Left", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_L));
    a->setData(V_LEFT);

    sub = m_popupMenu.addMenu("Projection...");
    a = sub->addAction("Orthographic", this, SLOT(setProjection()));
    a->setData(P_ORTHO);
    a = sub->addAction("Perspective", this, SLOT(setProjection()));
    a->setData(P_PERSP);

    sub = m_popupMenu.addMenu("DrawMode...");
    a = sub->addAction("Facets", this, SLOT(setDrawMode()), QKeySequence(Qt::Key_F));
    a->setData(osg::PolygonMode::FILL);
    a = sub->addAction("Wireframe", this, SLOT(setDrawMode()), QKeySequence(Qt::Key_W));
    a->setData(osg::PolygonMode::LINE);
    a = sub->addAction("Verticies", this, SLOT(setDrawMode()), QKeySequence(Qt::Key_V));
    a->setData(osg::PolygonMode::POINT);

    sub = m_popupMenu.addMenu("Toggle...");
    a = sub->addAction("MenuBar", this, SIGNAL(toggleMenuBar()), QKeySequence(Qt::CTRL+ Qt::Key_M));
    a = sub->addAction("ToolBar", this, SIGNAL(toggleToolBar()), QKeySequence(Qt::CTRL+ Qt::Key_T));
}
Esempio n. 2
0
VboMesh::VboMesh(std::shared_ptr<VertexLayout> _vertexLayout, GLenum _drawMode, GLenum _hint, bool _keepMemoryData) : VboMesh() {
    m_vertexLayout = _vertexLayout;
    m_hint = _hint;
    m_keepMemoryData = _keepMemoryData;

    setDrawMode(_drawMode);
}
int GLArea::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGLWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: updateMainWindowMenus(); break;
        case 1: transmitViewDir((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< vcg::Point3f(*)>(_a[2]))); break;
        case 2: transmitViewPos((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< vcg::Point3f(*)>(_a[2]))); break;
        case 3: transmitSurfacePos((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< vcg::Point3f(*)>(_a[2]))); break;
        case 4: transmitCameraPos((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< vcg::Point3f(*)>(_a[2]))); break;
        case 5: updateTexture(); break;
        case 6: setDrawMode((*reinterpret_cast< vcg::GLW::DrawMode(*)>(_a[1]))); break;
        case 7: setColorMode((*reinterpret_cast< vcg::GLW::ColorMode(*)>(_a[1]))); break;
        case 8: setTextureMode((*reinterpret_cast< vcg::GLW::TextureMode(*)>(_a[1]))); break;
        case 9: endEdit(); break;
        case 10: setSelectionRendering((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 11: suspendEditToggle(); break;
        case 12: setCurrentlyActiveLayer((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 13: sendViewPos((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 14: sendSurfacePos((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 15: sendViewDir((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 16: sendCameraPos((*reinterpret_cast< QString(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 17;
    }
    return _id;
}
Esempio n. 4
0
void Osg3dView::keyPressEvent(QKeyEvent *event)
{
    int key = event->key();

    bool isShifted = event->modifiers() & Qt::ShiftModifier;

    switch (key) {
    case Qt::Key_M:
        if (event->modifiers() & Qt::ControlModifier)
            emit toggleMenuBar();
        break;
    case Qt::Key_W: setDrawMode(osg::PolygonMode::LINE); update(); break;
    case Qt::Key_V: setDrawMode(osg::PolygonMode::POINT); update(); break;
    case Qt::Key_T:
        if (isShifted) {
            m_viewingCore->viewTop();
            update();
        } else if (event->modifiers() & Qt::ControlModifier) {
            emit toggleToolBar();
        }
            break;
    case Qt::Key_L: if (isShifted) m_viewingCore->viewLeft(); update(); break;
    case Qt::Key_B: if (isShifted) m_viewingCore->viewBack(); update(); break;
    case Qt::Key_F:
        if (isShifted) {
            m_viewingCore->viewFront();
        } else {
            setDrawMode(osg::PolygonMode::FILL);
        }
        update();
        break;
    case Qt::Key_U: if (isShifted) m_viewingCore->viewBottom(); update(); break;
    case Qt::Key_O: setMouseMode(MM_ORBIT); break;
    case Qt::Key_P: setMouseMode(MM_PAN); break;
    case Qt::Key_Z: setMouseMode(MM_ZOOM); break;
    case Qt::Key_R:
        if (isShifted) {
            m_viewingCore->viewRight();
            update();
        }else
            setMouseMode(MM_ROTATE);
        break;
    case Qt::Key_C: setMouseMode(MM_PICK_CENTER); break;
    case Qt::Key_S: setMouseMode(MM_SELECT); break;
    }
}
//----------------------------------------------------------------------------------------------------------------------
phdControlManager::phdControlManager() {
	usingEvents = false;
	selectedControl = NULL;
	focusedControl = NULL;
	popupMenu = NULL;
	setDrawMode(cmdmBoth);
	enableEvents();
}
Esempio n. 6
0
MeshBase::MeshBase(std::shared_ptr<VertexLayout> _vertexLayout, GLenum _drawMode, GLenum _hint)
    : MeshBase()
{
    m_vertexLayout = _vertexLayout;
    m_hint = _hint;

    setDrawMode(_drawMode);
}
Esempio n. 7
0
ofxMSAFluidDrawer::ofxMSAFluidDrawer() {
	//	printf("ofxMSAFluidDrawer::ofxMSAFluidDrawer()\n");
	_pixels				= NULL;
	_byteCount			= 0;
	_fluidSolver		= NULL;
	_didICreateTheFluid	= false;
	alpha				= 1;
	setDrawMode(FLUID_DRAW_COLOR);
}
Esempio n. 8
0
	void intiData(){
		people = loadPUBModel("resources/456.BINARY",m_pd3dDevice,m_pImmediateContext);

		
		// Initialize the world matrix
		m_World = XMMatrixIdentity();

		// Initialize the view matrix
		XMVECTOR Eye = XMVectorSet( 0, 1.1, -2.0, 0.0f );
		XMVECTOR At = XMVectorSet( 0.0f, 1.1, 0.0f, 0.0f );
		XMVECTOR Up = XMVectorSet( 0.0f, 1.0f, 0.0f, 0.0f );
		m_View = XMMatrixLookAtLH( Eye, At, Up );

		// Initialize the projection matrix
		m_Projection = XMMatrixPerspectiveFovLH( XM_PIDIV4, getWindowWidth() / (FLOAT)getWindowHeight(), 0.01f, 1000.0f );
		m_Projection = XMMatrixOrthographicLH(4,4*getWindowHeight()/(FLOAT)getWindowWidth(),0,100);
		
		bone_shader =new ShaderProgram(m_pd3dDevice);
		bone_shader->setLayout(CUSTOM_LAYOUT_PUB,CUSTOM_LAYOUT_PUB_NUM);
		bone_shader->requestConstantBuffer(192,0);
		bone_shader->requestConstantBuffer(sizeof(XMMATRIX)*BONE_MAX_NUM,1);
		bone_shader->loadShader(L"FX/boneAnime.fx");
		people->useShader(bone_shader);


		Sampler* samp=new Sampler(m_pd3dDevice);
		samp->createSampleState(D3D11_FILTER_MIN_MAG_MIP_LINEAR,D3D11_TEXTURE_ADDRESS_WRAP,-1);
		samp->useSamplerAt(m_pImmediateContext,0);

	//	MyLuaManager::getInstance()->registerFun(ConsleGlue);






		/***********************************************************************/
		
		view_shader= new ShaderProgram(m_pd3dDevice);
		view_shader->setLayout(CUSTOM_LAYOUT_PU,CUSTOM_LAYOUT_PU_NUM);
		view_shader->requestConstantBuffer(192,0);
		view_shader->loadShader(L"FX/Tutorial04.fx");
		quard=new ImageView(m_pd3dDevice);
		quard->setBorder(getWindowWidth(),getWindowHeight());
		quard->setSize(200,150);
		quard->setShader(view_shader);


		backTarget=RenderTarget::generateRenderTarget(m_pd3dDevice,getWindowWidth(),getWindowHeight());
		quard->setTexture(*backTarget->getShaderResource());
		/**********************************************************************/
		setDrawMode(Triangle);
		/*********************************************************************/
		controller=new ObjectController(m_pd3dDevice);
		controller->addObject(quard);
	}
Esempio n. 9
0
void initialize(HWND hwnd, HDC hdc)
{
    gDrawData.hDrawPen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));

    gDrawData.maxBoundary.cx = GetSystemMetrics(SM_CXSCREEN);
    gDrawData.maxBoundary.cy = GetSystemMetrics(SM_CYSCREEN);

    createMemoryBitmap(hdc);
    setDrawMode(READY_MODE, hwnd);
}
/** \brief Initialization of edOLED Library.

    Setup IO pins for SPI port then send initialization commands to the
    SSD1306 controller inside the OLED.
*/
void edOLED::begin()
{
	// default 5x7 font
	setFontType(0);
	setColor(WHITE);
	setDrawMode(NORM);
	setCursor(0,0);
	
	spiSetup();
	
	RST_PIN.pinWrite(HIGH); //(digitalWrite(rstPin, HIGH);
	usleep(5000); // VDD (3.3V) goes high at start, lets just chill for 5 ms
	RST_PIN.pinWrite(LOW); // bring reset low
	usleep(10000); // wait 10ms
	RST_PIN.pinWrite(HIGH);	//digitalWrite(rstPin, HIGH);

	// Init sequence for 64x48 OLED module
	command(DISPLAYOFF);			// 0xAE

	command(SETDISPLAYCLOCKDIV);	// 0xD5
	command(0x80);					// the suggested ratio 0x80

	command(SETMULTIPLEX);			// 0xA8
	command(0x2F);

	command(SETDISPLAYOFFSET);		// 0xD3
	command(0x0);					// no offset

	command(SETSTARTLINE | 0x0);	// line #0

	command(CHARGEPUMP);			// enable charge pump
	command(0x14);

	command(NORMALDISPLAY);			// 0xA6
	command(DISPLAYALLONRESUME);	// 0xA4

	command(SEGREMAP | 0x1);
	command(COMSCANDEC);

	command(SETCOMPINS);			// 0xDA
	command(0x12);

	command(SETCONTRAST);			// 0x81
	command(0x8F);

	command(SETPRECHARGE);			// 0xd9
	command(0xF1);
	
	command(SETVCOMDESELECT);			// 0xDB
	command(0x40);

	command(DISPLAYON);				//--turn on oled panel
	clear(ALL);						// Erase hardware memory inside the OLED
}
Esempio n. 11
0
	void Blittable::init()
	{
		auto as = DisplayDevice::createAttributeSet();
		attribs_.reset(new Attribute<vertex_texcoord>(AccessFreqHint::DYNAMIC, AccessTypeHint::DRAW));
		attribs_->addAttributeDesc(AttributeDesc(AttrType::POSITION, 2, AttrFormat::FLOAT, false, sizeof(vertex_texcoord), offsetof(vertex_texcoord, vtx)));
		attribs_->addAttributeDesc(AttributeDesc(AttrType::TEXTURE,  2, AttrFormat::FLOAT, false, sizeof(vertex_texcoord), offsetof(vertex_texcoord, tc)));
		as->addAttribute(AttributeBasePtr(attribs_));
		as->setDrawMode(DrawMode::TRIANGLE_STRIP);
		
		addAttributeSet(as);
	}
Esempio n. 12
0
/** \brief Initialisation of MicroView Library.

	Setup IO pins for SPI port then send initialisation commands to the SSD1306 controller inside the OLED.
*/
void MicroView::begin() {
	// default 5x7 font
	setFontType(0);
	setColor(WHITE);
	setDrawMode(NORM);
	setCursor(0,0);

	RESETLOW;

	// Enable 3.3V power to the display
	pinMode(OLEDPWR, OUTPUT);
	digitalWrite(OLEDPWR, HIGH);

	// Give some time for power to stabilise
	delay(10);

	RESETHIGH;
	delay(5);
	RESETLOW;

	// Setup SPI frequency
	MVSPI.setClockDivider(SPI_CLOCK_DIV2);
	// Initialise SPI
	MVSPI.begin();

	delay(5);

	// bring out of reset
	RESETHIGH;

	delay(10);

	// Init sequence for 64x48 OLED module
	//	command(DISPLAYOFF);				// 0xAE
	//	command(SETDISPLAYCLOCKDIV, 0x80);	// 0xD5 / the suggested ratio 0x80
	command(SETMULTIPLEX, 0x2F);		// 0xA8
	//	command(SETDISPLAYOFFSET, 0x0);		// 0xD3 / no offset
	//	command(SETSTARTLINE | 0x0);		// 0x40 / line #0
	command(CHARGEPUMP, 0x14);			// 0x8D / enable charge pump
	//	command(NORMALDISPLAY);				// 0xA6
	//	command(DISPLAYALLONRESUME);		// 0xA4
	command(SEGREMAP | 0x1);
	command(COMSCANDEC);
	//	command(SETCOMPINS, 0x12);			// 0xDA
	command(SETCONTRAST, 0x8F);			// 0x81
	command(SETPRECHARGE, 0xF1);		// 0xD9
	command(SETVCOMDESELECT, 0x40);		// 0xDB
	command(DISPLAYON);					//--turn on oled panel

	clear(ALL);							// Erase hardware memory inside the OLED controller to avoid random data in memory.

	//	Serial.begin(115200);				// removed the Serial.begin() so that user can decide their own baud rate.
}
Esempio n. 13
0
//-----------------------------------------------------------------------------
void CDrawContext::init ()
{
	// set the default values
	setFrameColor (kWhiteCColor);
	setLineStyle (kLineSolid);
	setLineWidth (1);
	setFillColor (kBlackCColor);
	setFontColor (kWhiteCColor);
	setFont (kSystemFont);
	setDrawMode (kAliasing);
	setClipRect (surfaceRect);
}
Esempio n. 14
0
VboMesh::VboMesh(std::shared_ptr<VertexLayout> _vertexLayout, GLenum _drawMode)
    : m_vertexLayout(_vertexLayout) {

    m_glVertexBuffer = 0;
    m_glIndexBuffer = 0;
    m_nVertices = 0;
    m_nIndices = 0;

    m_isUploaded = false;
    m_isCompiled = false;

    setDrawMode(_drawMode);
}
Esempio n. 15
0
unsigned int nRenderer::drawNode(nRTreeNode *node, unsigned int lev){
	if(node->isNull() || (node->isLeaf() && node->getChildren().size() == 1)) {
		return 0;
	}
	unsigned int nodes = 1;
	unsigned int mod = lev % 7 + 1;
	glColor3d((mod & 0b001) ? 1 : 0, (mod & 0b010) ? 1 : 0, (mod & 0b100) ? 1 : 0);
	DrawMode m = getDrawMode();
	setDrawMode(WireFrame);
	setAttribute(BackFaceCulling, false);
	drawBox(nBoundingBox::create(node->getNegative(), node->getPositive()));
	if(!node->isLeaf()) {
		list<nRTreeNode *> lst = node->getSubNodes();
		for(list<nRTreeNode *>::iterator it = lst.begin(); it != lst.end(); it++) {
			nodes += drawNode(*it, lev + 1);
		}
	}
	setAttribute(BackFaceCulling, true);
	setDrawMode(m);
	nMaterial::release();
	return nodes;
}
	FluidDrawerBase::FluidDrawerBase() {
		_pixels				= NULL;
		_fluidSolver		= NULL;
		_didICreateTheFluid	= false;
		
		enabled				= true;
		useAdditiveBlending = false;
		brightness			= 1;
		doInvert			= false;
		
		enableAlpha(false);
		
		setDrawMode(kFluidDrawColor);
	}
Esempio n. 17
0
void processCommand(int cmd, HWND hwnd)
{
    int response;
    switch (cmd)
    {
    case ID_CLEAR:
        reset(hwnd);
        setDrawMode(READY_MODE, hwnd);
        break;
    case ID_HYPERBOLA:
        setDrawMode(DRAW_MODE, hwnd);
        DialogBox(NULL, "MyDB", hwnd, (DLGPROC)DlgAxis);
        break;
    case ID_EXIT:
        response = MessageBox(hwnd,
                              "Quit the program?", "EXIT",
                              MB_YESNO);
        if (response == IDYES)
            PostQuitMessage(0);
        break;
    default:
        break;
    }
}
Esempio n. 18
0
 //--------------------------------------------------------------
 DrawerBase::DrawerBase() {
     _pixels				= NULL;
     _fluidSolver		= NULL;
     _didICreateTheFluid	= false;
     
     enabled				= true;
     useAdditiveBlending = false;
     brightness			= 1;
     doInvert			= false;
     velDrawMult				= 1;
     vectorSkipCount		= 0;
     
     enableAlpha(false);
     
     setDrawMode(kDrawColor);
 }
Esempio n. 19
0
void addPoint(HWND hwnd, int x, int y)
{
    switch (gDrawData.drawMode)
    {
    case DRAW_MODE:
        /* the coordinates of the centre is stored
           and the Hyperbola is drawn */
        SelectObject(gDrawData.hdcMem, gDrawData.hDrawPen);
        drawPoint(x, y);
        gDrawData.centre.x = x;
        gDrawData.centre.y = y;
        drawHyperbola();
        setDrawMode(DRAWN_MODE, hwnd);
        reDraw(hwnd);
        break;
    case DRAWN_MODE:
        MessageBox(hwnd,
                   "Hyperbola already drawn, now you can clear the area",
                   "Warning", MB_OK);
        break;
    default:
        break;
    }
}
/** \brief Initialisation of MicroOLED Library.

    Setup IO pins for SPI port then send initialisation commands to the SSD1306 controller inside the OLED.
*/
void MicroOLED::begin()
{
	// default 5x7 font
	setFontType(0);
	setColor(WHITE);
	setDrawMode(NORM);
	setCursor(0,0);

	pinMode(dcPin, OUTPUT);
	pinMode(rstPin, OUTPUT);

	// Set up the selected interface:
	if (interface == MODE_SPI)
		spiSetup();
	else if (interface == MODE_I2C)
		i2cSetup();
	else if (interface == MODE_PARALLEL)
		parallelSetup();

	// Display reset routine
	pinMode(rstPin, OUTPUT);	// Set RST pin as OUTPUT
	digitalWrite(rstPin, HIGH);	// Initially set RST HIGH
	delay(5);	// VDD (3.3V) goes high at start, lets just chill for 5 ms
	digitalWrite(rstPin, LOW);	// Bring RST low, reset the display
	delay(10);	// wait 10ms
	digitalWrite(rstPin, HIGH);	// Set RST HIGH, bring out of reset

	// Display Init sequence for 64x48 OLED module
	command(DISPLAYOFF);			// 0xAE

	command(SETDISPLAYCLOCKDIV);	// 0xD5
	command(0x80);					// the suggested ratio 0x80

	command(SETMULTIPLEX);			// 0xA8
	command(0x2F);

	command(SETDISPLAYOFFSET);		// 0xD3
	command(0x0);					// no offset

	command(SETSTARTLINE | 0x0);	// line #0

	command(CHARGEPUMP);			// enable charge pump
	command(0x14);

	command(NORMALDISPLAY);			// 0xA6
	command(DISPLAYALLONRESUME);	// 0xA4

	command(SEGREMAP | 0x1);
	command(COMSCANDEC);

	command(SETCOMPINS);			// 0xDA
	command(0x12);

	command(SETCONTRAST);			// 0x81
	command(0x8F);

	command(SETPRECHARGE);			// 0xd9
	command(0xF1);

	command(SETVCOMDESELECT);			// 0xDB
	command(0x40);

	command(DISPLAYON);				//--turn on oled panel
	clear(ALL);						// Erase hardware memory inside the OLED controller to avoid random data in memory.
}
	void FluidDrawerBase::incDrawMode() {
		setDrawMode((FluidDrawMode)((int)drawMode + 1));
	}
Esempio n. 22
0
void SurfaceAnimatorDialog::on_linesButton_clicked(bool)
{
    setDrawMode(Layer::Surface::Lines);
}
Esempio n. 23
0
void SurfaceAnimatorDialog::on_dotsButton_clicked(bool)
{
    setDrawMode(Layer::Surface::Dots);
}
Esempio n. 24
0
void SurfaceAnimatorDialog::on_fillButton_clicked(bool)
{
    setDrawMode(Layer::Surface::Fill);
}
Esempio n. 25
0
// Paste a scaled sprite onto the backdrop
void fixScaleSprite (int x, int y, sprite & single, const spritePalette & fontPal, onScreenPerson * thisPerson, int camX, int camY, bool mirror) {

	float scale = thisPerson-> scale;
	bool useZB = ! (thisPerson->extra & EXTRA_NOZB);
	bool light = ! (thisPerson->extra & EXTRA_NOLITE);

	if (scale <= 0.05) return;

	float tx1 = (float)(single.tex_x) / fontPal.tex_w[single.texNum];
	float ty1 = (float) 1.0/fontPal.tex_h[single.texNum];//0.0;
	float tx2 = (float)(single.tex_x + single.width) / fontPal.tex_w[single.texNum];
	float ty2 = (float)(single.height+1)/fontPal.tex_h[single.texNum];

	int diffX = (int)(((float)single.width) * scale);
	int diffY = (int)(((float)single.height) * scale);
	int x1;
	if (single.xhot < 0)
		x1 = x - (int)((mirror ? (float) (single.width - single.xhot) : (float)(single.xhot+1) ) * scale);
	else
		x1 = x - (int)((mirror ? (float) (single.width - (single.xhot+1)) : (float)single.xhot ) * scale);
	int y1 = y - (int)((single.yhot - thisPerson->floaty) * scale);

	float spriteWidth = diffX;
	float spriteHeight = diffY;
	if (x1 < 0) diffX += x1;
	if (y1 < 0) diffY += y1;
	if (x1 + diffX > sceneWidth) diffX = sceneWidth - x1;
	if (y1 + diffY > sceneHeight) diffY = sceneHeight - y1;
	if (diffX < 0) return;
	if (diffY < 0) return;

	GLfloat z;


	if (useZB && zBuffer.numPanels) {
		int i;
		for (i = 1; i<zBuffer.numPanels; i++) {
			if (zBuffer.panel[i] >= y + cameraY) {
				i--;
				break;
			}
		}
		z = 0.999 - (double) i * (1.0 / 128.0);
	} else {
		z = -0.5;
	}

	float ltx1, btx1;
	float ltx2, btx2;
	float lty1, bty1;
	float lty2, bty2;
	if (! NPOT_textures) {
		ltx1 = lightMap.texW * x1 / sceneWidth;
		ltx2 = lightMap.texW * (x1+spriteWidth) / sceneWidth;
		lty1 = lightMap.texH * y1 / sceneHeight;
		lty2 = lightMap.texH * (y1+spriteHeight) / sceneHeight;
		btx1 = backdropTexW * x1 / sceneWidth;
		btx2 = backdropTexW * (x1+spriteWidth) / sceneWidth;
		bty1 = backdropTexH * y1 / sceneHeight;
		bty2 = backdropTexH * (y1+spriteHeight) / sceneHeight;
	} else {
		btx1 = ltx1 = (float) x1 / sceneWidth;
		btx2 = ltx2 = (float) (x1+spriteWidth) / sceneWidth;
		bty1 = lty1 = (float) y1 / sceneHeight;
		bty2 = lty2 = (float) (y1+spriteHeight) / sceneHeight;
	}

	const GLfloat ltexCoords[] = { 
		ltx1, lty1,
		ltx2, lty1,
		ltx1, lty2,
		ltx2, lty2
	}; 

	const GLfloat btexCoords[] = { 
		btx1, bty1,
		btx2, bty1,
		btx1, bty2,
		btx2, bty2
	}; 

	if (light && lightMap.data) {
		if (lightMapMode == LIGHTMAPMODE_HOTSPOT) {
			int lx=x+cameraX;
			int ly=y+cameraY;
			if (lx<0 || ly<0 || lx>=sceneWidth || ly>=sceneHeight) {
				curLight[0] = curLight[1] = curLight[2] = 255;
			} else {
				GLubyte *target = lightMap.data + (ly*sceneWidth + lx)*4;
				curLight[0] = target[0];
				curLight[1] = target[1];
				curLight[2] = target[2];
			}
		} else if (lightMapMode == LIGHTMAPMODE_PIXEL) {
			curLight[0] = curLight[1] = curLight[2] = 255;
			glActiveTexture(GL_TEXTURE1);
			glBindTexture (GL_TEXTURE_2D, lightMap.name);
		}
	} else {
		curLight[0] = curLight[1] = curLight[2] = 255;
	}
	glActiveTexture(GL_TEXTURE2);
	glBindTexture (GL_TEXTURE_2D, backdropTextureName);
	glActiveTexture(GL_TEXTURE0);

	setPixelCoords (true);
	GLfloat xoffset = 0.0f;
	while (xoffset < diffX) {
		int w = (diffX-xoffset < viewportWidth) ? (int) (diffX-xoffset) : viewportWidth;

		GLfloat yoffset = 0.0f;
		while (yoffset < diffY) {

			int h = (diffY-yoffset< viewportHeight) ? (int) (diffY-yoffset) : viewportHeight;

			// Render the scene - first the old backdrop (so that it'll show through when the z-buffer is active
			//glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
			glBindTexture (GL_TEXTURE_2D, backdropTextureName);
			glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
			glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

			const GLfloat vertices[] = { 
				-x1-xoffset, -y1-yoffset, 0.0f, 
				sceneWidth-x1-xoffset, -y1-yoffset, 0.0f, 
				-x1-xoffset, sceneHeight-y1-yoffset, 0.0f,
				sceneWidth-x1-xoffset, sceneHeight-y1-yoffset, 0.0f
			};

			const GLfloat texCoords[] = { 
				0.0f, 0.0f,
				backdropTexW, 0.0f,
				0.0f, backdropTexH,
				backdropTexW, backdropTexH
			}; 

			glUseProgram(shader.texture);
			setPMVMatrix(shader.texture);

			drawQuad(shader.texture, vertices, 1, texCoords);

			// The z-buffer
			if (useZB) {
				glDepthMask (GL_TRUE);
				glClear(GL_DEPTH_BUFFER_BIT);
				drawZBuffer((int) (x1+xoffset+camX), (int) (y1+yoffset+camY), false);

				glDepthMask (GL_FALSE);
				glEnable(GL_DEPTH_TEST);
			}

			// Then the sprite
			glUseProgram(shader.paste);
			GLint uniform = glGetUniformLocation(shader.paste, "useLightTexture");
			if (uniform >= 0) glUniform1i(uniform, light && lightMapMode == LIGHTMAPMODE_PIXEL && lightMap.data);

			setPMVMatrix(shader.paste);

			setDrawMode (thisPerson);

			glBindTexture (GL_TEXTURE_2D, fontPal.tex_names[single.texNum]);

			const GLfloat vertices2[] = { 
				-xoffset, -yoffset, z, 
				spriteWidth-xoffset, -yoffset, z, 
				-xoffset, spriteHeight-yoffset, z,
				spriteWidth-xoffset, spriteHeight-yoffset, z
			};

			if (! mirror) {
				GLfloat tx3 = tx1;
				tx1 = tx2;
				tx2 = tx3;
			}
			const GLfloat texCoords2[] = { 
				tx2, ty1,
				tx1, ty1,
				tx2, ty2,
				tx1, ty2
			}; 

			drawQuad(shader.paste, vertices2, 3, texCoords2, ltexCoords, btexCoords);

			setSecondaryColor(0., 0., 0., 1.);
			//glDisable(GL_COLOR_SUM); FIXME: replace line?

			// Copy Our ViewPort To The Texture
			glUseProgram(0);

			copyTexSubImage2D(GL_TEXTURE_2D, 0, (int) ((x1<0) ? xoffset: x1+xoffset), (int) ((y1<0) ? yoffset: y1+yoffset), (int) ((x1<0) ?viewportOffsetX-x1:viewportOffsetX), (int) ((y1<0) ?viewportOffsetY-y1:viewportOffsetY), w, h, backdropTextureName);

			yoffset += viewportHeight;
		}
		xoffset += viewportWidth;
	}

	setPixelCoords (false);
	glUseProgram(0);
}
Esempio n. 26
0
bool scaleSprite (sprite & single, const spritePalette & fontPal, onScreenPerson * thisPerson, bool mirror) {

	float x = thisPerson->x;
	float y = thisPerson->y;

	float scale = thisPerson-> scale;
	bool light = ! (thisPerson->extra & EXTRA_NOLITE);

	if (scale <= 0.05) return false;

	float tx1 = (float)(single.tex_x) / fontPal.tex_w[single.texNum];
	float ty1 = (float) 1.0/fontPal.tex_h[single.texNum];
	float tx2 = (float)(single.tex_x + single.width) / fontPal.tex_w[single.texNum];
	float ty2 = (float)(single.height+1)/fontPal.tex_h[single.texNum];

	int diffX = (int)(((float)single.width) * scale);
	int diffY = (int)(((float)single.height) * scale);

	GLfloat x1, y1, x2, y2;

	if (thisPerson -> extra & EXTRA_FIXTOSCREEN) {
		x = x / cameraZoom;
		y = y / cameraZoom;
		if (single.xhot < 0)
			x1 = x - (int)((mirror ? (float) (single.width - single.xhot) : (float)(single.xhot+1) ) * scale/cameraZoom);
		else
			x1 = x - (int)((mirror ? (float) (single.width - (single.xhot+1)) : (float)single.xhot ) * scale / cameraZoom);
		y1 = y - (int)((single.yhot - thisPerson->floaty) * scale / cameraZoom);
		x2 = x1 + (int)(diffX / cameraZoom);
		y2 = y1 + (int)(diffY / cameraZoom);
	} else {
		x -= cameraX;
		y -= cameraY;
		if (single.xhot < 0)
			x1 = x - (int)((mirror ? (float) (single.width - single.xhot) : (float)(single.xhot+1) ) * scale);
		else
			x1 = x - (int)((mirror ? (float) (single.width - (single.xhot+1)) : (float)single.xhot ) * scale);
		y1 = y - (int)((single.yhot - thisPerson->floaty) * scale);
		x2 = x1 + diffX;
		y2 = y1 + diffY;
	}

	GLfloat z;

	if ((! (thisPerson->extra & EXTRA_NOZB)) && zBuffer.numPanels) {
		int i;
		for (i = 1; i<zBuffer.numPanels; i++) {
			if (zBuffer.panel[i] >= y + cameraY) {
				i--;
				break;
			}
		}
		z = 0.999 - (double) i * (1.0 / 128.0);
	} else {
		z = -0.5;
	}

	float ltx1, ltx2, lty1, lty2;
	if (! NPOT_textures) {
		ltx1 = lightMap.texW * (x1+cameraX) / sceneWidth;
		ltx2 = lightMap.texW * (x2+cameraX) / sceneWidth;
		lty1 = lightMap.texH * (y1+cameraY) / sceneHeight;
		lty2 = lightMap.texH * (y2+cameraY) / sceneHeight;
	} else {
		ltx1 = (float) (x1+cameraX) / sceneWidth;
		ltx2 = (float) (x2+cameraX) / sceneWidth;
		lty1 = (float) (y1+cameraY) / sceneHeight;
		lty2 = (float) (y2+cameraY) / sceneHeight;
	}

	const GLfloat ltexCoords[] = { 
		ltx1, lty1,
		ltx2, lty1,
		ltx1, lty2,
		ltx2, lty2
	}; 

	if (light && lightMap.data) {
		if (lightMapMode == LIGHTMAPMODE_HOTSPOT) {
			int lx=(int)(x+cameraX);
			int ly=(int)(y+cameraY);

			if (lx<0) lx = 0;
			else if (lx>=sceneWidth) lx = sceneWidth-1;
			if (ly<0) ly = 0;
			else if (ly>=sceneHeight) ly = sceneHeight-1;

			GLubyte *target;
			if (! NPOT_textures) {
				target = lightMap.data + (ly*getNextPOT(sceneWidth) + lx)*4;
			} else {
				target = lightMap.data + (ly*sceneWidth + lx)*4;
			}
			curLight[0] = target[0];
			curLight[1] = target[1];
			curLight[2] = target[2];
		} else if (lightMapMode == LIGHTMAPMODE_PIXEL) {
			curLight[0] = curLight[1] = curLight[2] = 255;
			glActiveTexture(GL_TEXTURE1);
			glBindTexture (GL_TEXTURE_2D, lightMap.name);
			glActiveTexture(GL_TEXTURE0);
		}
	} else {
		curLight[0] = curLight[1] = curLight[2] = 255;
	}

	if (! (thisPerson->extra & EXTRA_RECTANGULAR))
		checkColourChange (true);

	setDrawMode (thisPerson);

	glBindTexture (GL_TEXTURE_2D, fontPal.tex_names[single.texNum]);

	glEnable(GL_BLEND);

	glUseProgram(shader.smartScaler);
	GLuint uniform = glGetUniformLocation(shader.smartScaler, "useLightTexture");
	if (uniform >= 0) glUniform1i(uniform, light && lightMapMode == LIGHTMAPMODE_PIXEL && lightMap.data);

	setPMVMatrix(shader.smartScaler);

	if (gameSettings.antiAlias == 1) {
		glUniform1i(glGetUniformLocation(shader.smartScaler, "antialias"), 1);
	} else {
		glUniform1i(glGetUniformLocation(shader.smartScaler, "antialias"), 0);
	}

	const GLfloat vertices[] = { 
		x1, y1, z, 
		x2, y1, z, 
		x1, y2, z,
		x2, y2, z
	};

	if (! mirror) {
		GLfloat tx3 = tx1;
		tx1 = tx2;
		tx2 = tx3;
	}
	const GLfloat texCoords[] = { 
		tx2, ty1,
		tx1, ty1,
		tx2, ty2,
		tx1, ty2
	}; 

	drawQuad(shader.smartScaler, vertices, 2, texCoords, ltexCoords);

	glDisable(GL_BLEND);
	glUseProgram(0);

	if (light && lightMapMode == LIGHTMAPMODE_PIXEL) {
		glActiveTexture(GL_TEXTURE1);
		glActiveTexture(GL_TEXTURE0);
	}
	setSecondaryColor(0., 0., 0.,1.);
	//glDisable(GL_COLOR_SUM); FIXME: replace line?

	// Are we pointing at the sprite?
	if (input.mouseX >= x1 && input.mouseX <= x2 && input.mouseY >= y1 && input.mouseY <= y2) {
		if (thisPerson->extra & EXTRA_RECTANGULAR) return true;
		return checkColourChange (false);
	}
	return false;
}
	void FluidDrawerBase::decDrawMode() {
		setDrawMode((FluidDrawMode)(drawMode - 1));
	}
Esempio n. 28
0
void ofxMSAFluidDrawer::decDrawMode() {
	setDrawMode(drawMode - 1);
}
Esempio n. 29
0
Vbo::Vbo(VertexLayout* _vertexLayout, GLenum _drawMode) : m_vertexLayout(_vertexLayout), m_glVertexBuffer(0), m_nVertices(0), m_glIndexBuffer(0), m_nIndices(0), m_isUploaded(false) {
    setDrawMode(_drawMode);
}
Esempio n. 30
0
void ofxMSAFluidDrawer::incDrawMode() {
	setDrawMode(drawMode + 1);
}