Rotation
From SWWorkshop
Sometimes we need to rotate primitives. We have two choice.
- First technique: We calculate edge points according to rotation value and give engine these calculated vertex values. This solution is a bit hard to use.
- Second technique: We set a rotation value when drawing primitives. SWEngine use this technique. This technique is easy and flexible. You could also give extra weight point for rotation. And SWEngine works with degrees. If you use radians you must convert degrees first. swMath api provides conversion functions between degrees and radians.
Api Docs
SwEngine, swApplication, swGraphics, swColor, swPoint, swDimension.
Source Code
#include "../../include/SWEngine.h" #pragma comment (lib,"../../lib/SWUtil.lib") #pragma comment (lib,"../../lib/SWTypes.lib") #pragma comment (lib,"../../lib/SWCore.lib") #pragma comment (lib,"../../lib/SWEngine.lib") swApplication rotationApp; swPoint elipsCenter={400,300}; swDimension elipsDim={300,100}; //------------------------------------------------------------------------------------------- void GameLoop(){ swGraphicsBeginScene(); //Background swGraphicsSetBgColor0(0.6f,0.6f,0.6f); //Draw Elips swGraphicsSetColor1(&SWCOLOR_GREEN); swGraphicsRenderSolidElips2(&elipsCenter,&elipsDim,30,0); //Rot val=0 degree swGraphicsSetColor1(&SWCOLOR_RED); swGraphicsRenderSolidElips2(&elipsCenter,&elipsDim,30,60);//Rot val=60 degree swGraphicsSetColor1(&SWCOLOR_BLUE); swGraphicsRenderSolidElips2(&elipsCenter,&elipsDim,30,120);//Rot val=120 degree swGraphicsEndScene(); } //------------------------------------------------------------------------------------------- int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd) { //Application Settings rotationApp.hInstance=hInstance; rotationApp.fullScreen=false; rotationApp.cursor=true; rotationApp.width=800; rotationApp.height=600; rotationApp.title="Rotation"; rotationApp.path="resource"; rotationApp.appRun=GameLoop; //Application Execution swEngineInit(&rotationApp); swEngineRun(); swEngineExit(); return 0; }

