예제 #1
0
bool StGLUVCylinder::computeMesh() {
    clearRAM();
    if(myNbRings == 0) {
        return false;
    }

    const int aNbVerts = (myNbRings + 1) * 2;
    myVertices.initArray(aNbVerts);
    myNormals .initArray(aNbVerts);
    myTCoords .initArray(aNbVerts);

    for(int aRingIter = 0; aRingIter <= myNbRings; ++aRingIter) {
        const GLfloat aPhi    = float(aRingIter) * float(M_PI * 2.0) / float(myNbRings);
        const GLfloat aTexCrd = float(aRingIter) / float(myNbRings);
        myTCoords.changeValue(aRingIter * 2 + 0) = StGLVec2(aTexCrd, 0.0f);
        myTCoords.changeValue(aRingIter * 2 + 1) = StGLVec2(aTexCrd, 1.0f);

        const StGLVec3 aNorm(cosf(aPhi), 0.0f, sinf(aPhi));
        myNormals.changeValue(aRingIter * 2 + 0) = aNorm;
        myNormals.changeValue(aRingIter * 2 + 1) = aNorm;

        myVertices.changeValue(aRingIter * 2 + 0) = myCenter + aNorm * myRadius - StGLVec3(0.0f, myHeight * 0.5f, 0.0f);
        myVertices.changeValue(aRingIter * 2 + 1) = myCenter + aNorm * myRadius + StGLVec3(0.0f, myHeight * 0.5f, 0.0f);
    }
    return true;
}
예제 #2
0
void main(void)
{

    static const char msg[] =
    	"\n\rHello SX C World\n\rpush 'a' to loop again\n\r";
	char ch;
	
    OPTION = 0xa8;  // ints off!

    clearRAM();  // built in function

	// not needed..
#if 0
    // configure 8-bit RB, all outputs
	TRISB = 0x00;   // all pins output
	LVL_B = 0xff;   // all TTL voltages
    ST_B = 0xff;    // schmitt triggers off
    PLP_B = 0xff;   // pull-ups off
    WKED_B = 0xff;  // Wake up falling edge
    WKPND_B = 0x00; // Wake up clear register
    WKEN_B = 0xff;  // Wake up disabled

    // configure 8-bit RC, all outputs
	TRISC = 0x00;   // all pins output
	LVL_C = 0xff;   // all TTL voltages
    ST_C = 0xff;    // schmitt triggers off
    PLP_C = 0xff;   // pull-ups off
#endif

    serial_on(100);	// turn on serial I/O, delay appox. 100 milli seconds
	                // the delay gives the SX some stablilization
					// time
	
	while (1) {
	
        puts(msg);
		putchar('>');
		ch = getchar();
		if (ch != 'a') break;
	}	

    serial_off();	// turn off serial, calling this is important in the event
	                // that the transmit buffer is not yet processed by the
					// interrupt handler in SXIO.H
	
	sleep();

}
예제 #3
0
void main() {
  clearRAM(); //clear all ram
  DDR_init(); //intialize DDR copy registers
  //initialize and install VP's
  vpInit(); //must be called prior to other vp functions
  tx = vpInstall(TX1); //install virtual peripheral TX1
  rx = vpInstall(RX1); //install virtual peripheral RX1
  //setup tasks
  TaskInit(); //must be called prior to other task functions
  TaskSet(0,TXDEQUEUE+TASKSTART,2); // task slot 0, run "TxDequeue", every 2 taskticks
  TaskSet(1,RXENQUEUE+TASKSTART,2); // task slot 1, run "RxEnqueue", every 2 taskticks
  TaskEnable(); //master task enable (eg. enable task interrupts)
  //at this point, the interrupt should be enabled
  OPTION = RTCC_ON + RTCC_PS_OFF;
  sendString(WELCOME);
  while (1) {
    wresult = dequeue(); // get received byte (from receiver queue)
    if (wresult.high8 == 0) { //queue not empty, so result valid
      sendChar(wresult.low8); //echo received byte
    }
  }
}
예제 #4
0
void StGLMesh::release(StGLContext& theCtx) {
    clearRAM();
    clearVRAM(theCtx);
}
예제 #5
0
파일: main.c 프로젝트: Balu1991/Wifly_Light
void main(void)
{
#else
int g_start_gl = 1;
int main(int argc, const char** argv)
{
	if ((argc > 1) && (argv[1][0] == 'h'))
		g_start_gl = 0;
#endif
	/* softReset() on x86 will jump here! */
	softResetJumpDestination();

	InitAll();

	while(1)
	{
		Timer_StartStopwatch(eMAIN);
#ifndef __CC8E__
		// give opengl thread a chance to run
		usleep(10);
#endif /* #ifndef __CC8E__ */



			do_and_measure(Platform_CheckInputs);

			do_and_measure(Error_Throw);

			do_and_measure(CommandIO_GetCommands);

		if(g_UpdateLedStrip > 0) {
			do_and_measure(Ledstrip_UpdateLed);
			Timer1Enable();
			g_UpdateLedStrip = 0;
		}
		Timer_StopStopwatch(eMAIN);

			do_and_measure(ScriptCtrl_Run);

		if(g_UpdateLed > 0) {
			do_and_measure(Ledstrip_DoFade);

			Timer5InterruptLock();
			g_UpdateLed = 0;
			Timer5InterruptUnlock();

		}
	}
}
//*********************** UNTERPROGRAMME **********************************************

void InitAll()
{
	clearRAM();
	Trace_Init();
	Platform_OsciInit();
	Platform_IOInit();
	RingBuf_Init(&g_RingBuf);
	UART_Init();
	Timer_Init();
	Ledstrip_Init();
	CommandIO_Init();
	Rtc_Init();
	ScriptCtrl_Init();
	ExtEeprom_Init();
	
#ifndef __CC8E__
	init_x86(g_start_gl);
#endif /* #ifndef CC8E */

	Platform_AllowInterrupts();

	/* Startup Wait-Time 2s
	 * to protect Wifly-Modul from errors*/
	gScriptBuf.waitValue = 20;
	CommandIO_CreateResponse(&g_ResponseBuf, FW_STARTED, OK);
	CommandIO_SendResponse(&g_ResponseBuf);
	Trace_String(" Init Done ");
	Platform_DisableBootloaderAutostart();
}