void c_move(  /*move pen */
            void *win,
            double x,
            double y) {
  WINDOW window = (WINDOW) win;

  window->Move2d (x, y);
}
void c_draw(  /*move pen */
            void *win,
            double x,
            double y) {
  WINDOW window = (WINDOW) win;

  window->Draw2d (x, y);
}
void c_line_color_index(  /*set color */
                        void *win,
                        C_COL index) {
  WINDOW window = (WINDOW) win;

  //      ASSERT_HOST(index>=0 && index<=48);
  if (index < 0 || index > 48)
    index = (C_COL) 1;
  window->Line_color_index ((COLOUR) index);
}
Beispiel #4
0
//*----------------------------------------------------------------------------
//*			DCR function
//*----------------------------------------------------------------------------
void GUI_DCR(GUI_DRIVER_INFO* drv_info, unsigned int reason, HANDLE param)
{
    GUI_DRIVER_DATA*  drv_data;
    WINDOW win = (WINDOW)param;

    drv_data = drv_info->drv_data;
    switch(reason)
    {
    case DCR_RESET:
        display_init(drv_info);
        break;

    case DCR_OPEN:
        if(win->mode.as_int)
        {
            // WINDOW objects
            win->rect.x0 = 0;
            win->rect.y0 = 0;
//				win->rect.x1 = drv_info->lcd->size_x;
//				win->rect.y1 = drv_info->lcd->size_y;
        }
        win->res = RES_OK;
        break;

    case DCR_HANDLE:
        if(win->mode.as_int)
        {
            locked_set_byte(&win->mode0, FLG_OK);
            svc_send_signal(&gui_task, SIG_GUI_TASK);
        }
        break;

    case DCR_CANCEL:
        if(win->mode.as_int)
        {
            // this is WINDOW handle...
            locked_set_byte(&win->mode0, FLG_SIGNALED);
            win->svc_list_cancel(drv_data->waiting);
        } else
        {
            // not a WINDOW
            if(win == drv_data->helper)
            {
                //the helper task is waiting for object...
                drv_data->helper = NULL;
                win->dst.as_voidptr = NULL;
                svc_HND_SET_STATUS(win, RES_SIG_OK);
            }
        }
        break;

    }
}
Beispiel #5
0
//Set up variables
bool DemoInit()
{
	if(!window.Init("Metaballs", 512, 512, 32, 24, 8, WINDOWED_SCREEN))
		return 0;											//quit if not created
	
	//set up grid
	if(!cubeGrid.CreateMemory())
		return false;
	if(!cubeGrid.Init(gridSize))
		return false;

	//set up metaballs
	for(int i=0; i<numMetaballs; i++)
		metaballs[i].Init(VECTOR3D(0.0f, 0.0f, 0.0f), 5.0f+float(i));

	//Set Up Colors
	diffuseColors[0].Set(0.345f, 0.843f, 0.902f, 1.0f);
	diffuseColors[1].Set(0.047f, 0.839f, 0.271f, 1.0f);
	diffuseColors[2].Set(0.976f, 0.213f, 0.847f, 1.0f);	

	//reset timer for start
	timer.Reset();
	
	return true;
}
Beispiel #6
0
//Set up variables
bool DemoInit()
{
    if(!window.Init("Project Template", 640, 480, 32, 24, 8, WINDOWED_SCREEN))
        return 0;											//quit if not created

    SetUpARB_multitexture();
    SetUpEXT_texture3D();
    SetUpEXT_texture_edge_clamp();
    SetUpNV_register_combiners();
    SetUpNV_texture_shader();
    SetUpNV_vertex_program();

    if(	!EXT_texture_edge_clamp_supported || !ARB_multitexture_supported ||
            !NV_vertex_program_supported || !NV_register_combiners_supported)
        return false;

    //Check we have at least 3 texture units
    GLint maxTextureUnitsARB;
    glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &maxTextureUnitsARB);

    if(maxTextureUnitsARB<3)
    {
        errorLog.OutputError("I require at least 3 texture units");
        return false;
    }

    //Set light colors
    lightColors[0].Set(1.0f, 1.0f, 1.0f, 1.0f);
    lightColors[1].Set((float)47/255, (float)206/255, (float)240/255, 1.0f);
    lightColors[2].Set((float)254/255, (float)48/255, (float)18/255, 1.0f);
    lightColors[3].Set((float)83/255, (float)243/255, (float)29/255, 1.0f);



    //Load textures
    //Decal image
    decalImage.Load("decal.tga");
    glGenTextures(1, &decalTexture);
    glBindTexture(GL_TEXTURE_2D, decalTexture);
    glTexImage2D(	GL_TEXTURE_2D, 0, GL_RGBA8, decalImage.width, decalImage.height,
                    0, decalImage.format, GL_UNSIGNED_BYTE, decalImage.data);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);


    //Create light textures
    if(!InitLightTextures(	atten1DTexture, atten2DTexture, atten3DTexture,
                            gaussian1DTexture, gaussian2DTexture))
        return false;


    camera.Init(VECTOR3D(0.0f, 0.0f, 3.5f));

    //reset timer for start
    timer.Reset();

    return true;
}
Beispiel #7
0
void INTERACTOR::Update()
{
	//update angles
	if(window.isLeftButtonPressed())
	{
		leftRightRotation+=(window.GetMouseXMovement())*rotationSensitivity;
		upDownRotation+=(window.GetMouseYMovement())*rotationSensitivity;
	}

	//update radius
	if(window.isRightButtonPressed())
	{
		r+=(window.GetMouseYMovement())*(float)translationSensitivity;
	}

	//update position if there has been a change
	if(window.isLeftButtonPressed() || window.isRightButtonPressed())
	{
		static MATRIX4X4 tempMatrix;
		glPushMatrix();
		glLoadIdentity();
		glTranslatef(lookAt.x, lookAt.y, lookAt.z);
		glRotated(-leftRightRotation, 0.0f, 1.0f, 0.0f);
		glRotated(-upDownRotation, 1.0f, 0.0f, 0.0f);
		glTranslatef(0.0f, 0.0f, r);
		glGetFloatv(GL_MODELVIEW_MATRIX, tempMatrix);
		position=tempMatrix.GetColumn(3);
		glPopMatrix();
	}
}
Beispiel #8
0
//Perform per frame updates
void UpdateFrame()
{
	window.Update();
	camera.Update();

	//Change object type
	if(window.isKeyPressed(' '))
	{
		++objectType;
		if(objectType==3)
			objectType=0;

		window.SetKeyReleased(' ');
	}

	//Change render path
	if(window.isKeyPressed('1') && renderPath!=CHROMATIC_SINGLE && pathOneSupported)
	{
		renderPath=CHROMATIC_SINGLE;
		InitChromaticSingleStates();
	}
	
	if(window.isKeyPressed('2') && renderPath!=SIMPLE_SINGLE)
	{
		renderPath=SIMPLE_SINGLE;
		InitSimpleSingleStates();
	}

	if(window.isKeyPressed('3') && renderPath!=CHROMATIC_TWIN)
	{
		renderPath=CHROMATIC_TWIN;
		//Set States every pass, as it is a 2 pass algorithm
	}
}
Beispiel #9
0
//Perform per frame updates
void UpdateFrame()
{
    window.Update();
    camera.Update();

    //Update the light's position
    lightPosition+=lightMovement;

    //reflect the velocity if necessary
    if(lightPosition.x>0.9f || lightPosition.x<-0.9f)
        lightMovement.x=-lightMovement.x;

    if(lightPosition.y>0.9f || lightPosition.y<-0.9f)
        lightMovement.y=-lightMovement.y;

    if(lightPosition.z>0.9f || lightPosition.z<-0.9f)
        lightMovement.z=-lightMovement.z;

    if(window.isKeyPressed('1') && codePath!=TEXTURE_ATTEN)
    {
        codePath=TEXTURE_ATTEN;
        SetTextureAttenStates();
    }

    if(	window.isKeyPressed('2') && codePath!=PASS_THROUGH_ATTEN &&
            NV_texture_shader_supported)
    {
        codePath=PASS_THROUGH_ATTEN;
        SetPassThroughAttenStates();
    }

    if(	window.isKeyPressed('3') && codePath!=TEXTURE_3D_ATTEN &&
            EXT_texture3D_supported)
    {
        codePath=TEXTURE_3D_ATTEN;
        SetTexture3DAttenStates();
    }

    if( window.isKeyPressed('4') && codePath!=GAUSSIAN_ATTEN)
    {
        codePath=GAUSSIAN_ATTEN;
        SetGaussianAttenStates();
    }

    if(	window.isKeyPressed(' '))
    {
        currentLightColor++;
        if(currentLightColor==4)
            currentLightColor=0;

        window.SetKeyReleased(' ');
    }
}
Beispiel #10
0
//ENTRY POINT FOR APPLICATION
//CALL WINDOW CREATION ROUTINE, DEAL WITH MESSAGES, WATCH FOR INTERACTION
int WINAPI WinMain(	HINSTANCE	hInstance,				//instance
					HINSTANCE	hPrevInstance,			//Previous Instance
					LPSTR		lpCmdLine,				//command line parameters
					int			nCmdShow)				//Window show state
{
	//Initiation
	errorLog.Init("Error Log.txt");

	//init variables etc, then GL
	if(!DemoInit())
	{
		errorLog.OutputError("Demo Initiation failed");
		return 0;
	}
	else
		errorLog.OutputSuccess("Demo Initiation Successful");

	if(!GLInit())
	{
		errorLog.OutputError("OpenGL Initiation failed");
		return 0;
	}
	else
		errorLog.OutputSuccess("OpenGL Initiation Successful");

	//Main Loop
	for(;;)
	{
		if(!(window.HandleMessages())) break;//handle windows messages, quit if returns false
		UpdateFrame();
		RenderFrame();
	}

	DemoShutdown();
	
	errorLog.OutputSuccess("Exiting...");
	return (window.msg.wParam);								//Exit The Program
}
Beispiel #11
0
DLLSYM WINDOW def_await_event(                           /*wait for event */
                              WINDOW win,                /*window to wait on */
                              BOOL8 wait,                /*waiting flag */
                              INT8 event_type,           /*type to wait for */
                              GRAPHICS_EVENT *out_event  /*output event */
                             ) {
  GRAPHICS_EVENT *event;         /*return event */
  INT16 fd;                      //file descriptor

  if (win == NULL)
    fd = 0;
  else
    fd = win->get_fd ();
                                 /*look for one */
  event = find_event (fd, wait, event_type);
  if (event == NULL)
    return NULL;                 /*not found */
  else {
    *out_event = *event;         /*copy event */
    if (event->type != DESTROY_EVENT)
      delete event;              //free the element
    return out_event->fd;
  }
}
Beispiel #12
0
void DemoShutdown()
{
	pbuffer.Shutdown();

	window.Shutdown();										//Shutdown window
}
Beispiel #13
0
//draw a frame
void RenderFrame()
{
	//Draw to pbuffer
	pbuffer.MakeCurrent();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();										//reset modelview matrix

	gluLookAt(	0.0f, 0.0f, 4.0f,
				0.0f, 0.0f, 0.0f,
				0.0f, 1.0f, 0.0f);

	//Draw scene
	if(drawTextured)
	{
		glBindTexture(GL_TEXTURE_2D, decalTexture);
		glEnable(GL_TEXTURE_2D);
		
		glPushMatrix();
		glRotatef(timer.GetTime()/20, 0.0f, 1.0f, 0.0f);

		glutSolidTeapot(0.8f);
		
		glPopMatrix();

		glDisable(GL_TEXTURE_2D);
	}
	else
	{
		glPushMatrix();
		glRotatef(timer.GetTime()/20, 0.0f, 1.0f, 0.0f);
		glRotatef(55.0f, 1.0f, 0.0f, 0.0f);
		glutWireTorus(0.3f, 1.0f, 12, 24);
		glPopMatrix();

		glPushMatrix();
		glRotatef(timer.GetTime()/20, 0.0f, 1.0f, 0.0f);
		glRotatef(-55.0f, 1.0f, 0.0f, 0.0f);
		glutWireTorus(0.3f, 1.0f, 12, 24);
		glPopMatrix();
	}


	
	//Draw to window
	window.MakeCurrent();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	camera.SetupViewMatrix();
	glLoadMatrixf(camera.viewMatrix);


	glBindTexture(GL_TEXTURE_2D, pbufferTexture);
	//use the pbuffer as the texture
	wglBindTexImageARB(pbuffer.hBuffer, WGL_FRONT_LEFT_ARB);


	//Draw simple rectangle
	glBegin(GL_TRIANGLE_STRIP);
	{
		glTexCoord2f(0.0f, 0.0f);
		glVertex3f(-1.0f, -1.0f, 0.0f);
		glTexCoord2f(0.0f, 1.0f);
		glVertex3f(-1.0f,  1.0f, 0.0f);
		glTexCoord2f(1.0f, 0.0f);
		glVertex3f( 1.0f, -1.0f, 0.0f);
		glTexCoord2f(1.0f, 1.0f);
		glVertex3f( 1.0f,  1.0f, 0.0f);
	}
	glEnd();

	//release the pbuffer for further rendering
	wglReleaseTexImageARB(pbuffer.hBuffer, WGL_FRONT_LEFT_ARB);



	fpsCounter.Update();											//update frames per second counter
	glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
	window.StartTextMode();
	window.Print(0, 28, "FPS: %.2f", fpsCounter.GetFps());			//print the fps
	glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
	window.Print(0, 48, "%dx Anisotropy", currentAnisotropy);
	glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
	window.Print(0, 68, "%s", useMipmapFilter ?	"LINEAR_MIPMAP_LINEAR filtering" :
												"LINEAR filtering");
	window.EndTextMode();
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

	if(window.isKeyPressed(VK_F1))
	{
		window.SaveScreenshot();
		window.SetKeyReleased(VK_F1);
	}

	window.SwapBuffers();									//swap buffers

	//check for any opengl errors
	window.CheckGLError();

	//quit if necessary
	if(window.isKeyPressed(VK_ESCAPE))
		PostQuitMessage(0);
}
Beispiel #14
0
//Perform per frame updates
void UpdateFrame()
{
	window.Update();
	camera.Update();

	//Change anisotropy level
	if(	window.isKeyPressed(VK_UP) && EXT_texture_filter_anisotropic_supported &&
		currentAnisotropy<maxAnisotropy)
	{
		window.MakeCurrent();
		currentAnisotropy*=2;
		glBindTexture(GL_TEXTURE_2D, pbufferTexture);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, currentAnisotropy);
		window.SetKeyReleased(VK_UP);
	}
	
	if(	window.isKeyPressed(VK_DOWN) && EXT_texture_filter_anisotropic_supported &&
		currentAnisotropy>1)
	{
		window.MakeCurrent();
		currentAnisotropy/=2;
		glBindTexture(GL_TEXTURE_2D, pbufferTexture);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, currentAnisotropy);
		window.SetKeyReleased(VK_DOWN);
	}

	//toggle mipmaps
	if( window.isKeyPressed('M') && useMipmapFilter==false && SGIS_generate_mipmap_supported)
	{
		window.MakeCurrent();
		glBindTexture(GL_TEXTURE_2D, pbufferTexture);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, true);
		useMipmapFilter=true;
	}

	if( window.isKeyPressed('L') && useMipmapFilter==true && SGIS_generate_mipmap_supported)
	{
		window.MakeCurrent();
		glBindTexture(GL_TEXTURE_2D, pbufferTexture);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, false);
		useMipmapFilter=false;
	}

	//Pause/unpause
	if(window.isKeyPressed('P'))
		timer.Pause();

	if(window.isKeyPressed('U'))
		timer.Unpause();

	//Swap between scenes in the pbuffer
	if(window.isKeyPressed('1') && drawTextured)
	{
		//Draw wire tori
		drawTextured=false;
	}

	if(window.isKeyPressed('2') && !drawTextured)
	{
		//draw textured sphere
		drawTextured=true;
	}
}
Beispiel #15
0
//Set up openGL
bool GLInit()
{
	//Set up for pbuffer
	pbuffer.MakeCurrent();

	//set viewport
	glViewport(0, 0, pbufferSize, pbufferSize);

	//set up projection matrix
	glMatrixMode(GL_PROJECTION);							//select projection matrix
	glLoadIdentity();										//reset
	gluPerspective(45.0f, 1.0f, 1.0f, 100.0f);
	
	//load identity modelview
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	//other states
	//shading
	glShadeModel(GL_SMOOTH);
	glClearColor(	pbufferBackgroundColor.r,
					pbufferBackgroundColor.g,
					pbufferBackgroundColor.b,
					pbufferBackgroundColor.a);
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

	//depth
	glClearDepth(1.0f);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);

	//hints
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);





	//Set up for window
	window.MakeCurrent();

	//set viewport
	int height;
	if (window.height==0)
		height=1;
	else
		height=window.height;
	
	glViewport(0, 0, window.width, height);					//reset viewport

	//set up projection matrix
	glMatrixMode(GL_PROJECTION);							//select projection matrix
	glLoadIdentity();										//reset
	gluPerspective(45.0f, (GLfloat)window.width/(GLfloat)height, 1.0f, 100.0f);
	
	//load identity modelview
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	//other states
	//shading
	glShadeModel(GL_SMOOTH);
	glClearColor(	windowBackgroundColor.r,
					windowBackgroundColor.g,
					windowBackgroundColor.b,
					windowBackgroundColor.a);
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

	//depth
	glClearDepth(1.0f);
	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);

	//hints
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	glEnable(GL_TEXTURE_2D);


	return true;
}
Beispiel #16
0
//Set up variables
bool DemoInit()
{
	if(!window.Init("Project Template", 640, 480, 32, 24, 8, WINDOWED_SCREEN))
		return 0;											//quit if not created

	SetUpARB_multitexture();
	SetUpARB_texture_cube_map();
	SetUpEXT_texture_edge_clamp();
	SetUpNV_register_combiners();
	SetUpNV_register_combiners2();
	SetUpNV_vertex_program();

	//Check for necessary extensions
	if(	!ARB_multitexture_supported || !ARB_texture_cube_map_supported ||
		!EXT_texture_edge_clamp_supported || !NV_register_combiners_supported ||
		!NV_vertex_program_supported)
		return false;

	//Check for single-pass chromatic aberration states
	GLint maxTextureUnits;
	glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &maxTextureUnits);
	if( NV_register_combiners2_supported && maxTextureUnits>=4)
	{
		errorLog.OutputSuccess("Single Pass Chromatic Aberration Supported!");
		pathOneSupported=true;
		renderPath=CHROMATIC_SINGLE;
	}

	camera.Init(VECTOR3D(0.0f, 0.0f, 4.0f), 2.5f, 10.0f);

	if(	!cubeMapPosX.Load("cube_face_posx.tga") ||
		!cubeMapNegX.Load("cube_face_negx.tga") ||
		!cubeMapPosY.Load("cube_face_posy.tga") ||
		!cubeMapNegY.Load("cube_face_negy.tga") ||
		!cubeMapPosZ.Load("cube_face_posz.tga") ||
		!cubeMapNegZ.Load("cube_face_negz.tga"))
		return false;

	//Build a texture from the data
	glGenTextures(1, &cubeMapTexture);								//Generate Texture ID
	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubeMapTexture);					//Bind texture
	
	glTexImage2D(	GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
					0, GL_RGBA8, cubeMapPosX.width, cubeMapPosX.height, 0,
					cubeMapPosX.format, GL_UNSIGNED_BYTE, cubeMapPosX.data);
	
	glTexImage2D(	GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
					0, GL_RGBA8, cubeMapNegX.width, cubeMapNegX.height, 0,
					cubeMapNegX.format, GL_UNSIGNED_BYTE, cubeMapNegX.data);

	glTexImage2D(	GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
					0, GL_RGBA8, cubeMapPosY.width, cubeMapPosY.height, 0,
					cubeMapPosY.format, GL_UNSIGNED_BYTE, cubeMapPosY.data);
	
	glTexImage2D(	GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
					0, GL_RGBA8, cubeMapNegY.width, cubeMapNegY.height, 0,
					cubeMapNegY.format, GL_UNSIGNED_BYTE, cubeMapNegY.data);

	glTexImage2D(	GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
					0, GL_RGBA8, cubeMapPosZ.width, cubeMapPosZ.height, 0,
					cubeMapPosZ.format, GL_UNSIGNED_BYTE, cubeMapPosZ.data);
	
	glTexImage2D(	GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
					0, GL_RGBA8, cubeMapNegZ.width, cubeMapNegZ.height, 0,
					cubeMapNegZ.format, GL_UNSIGNED_BYTE, cubeMapNegZ.data);

	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

	
	//reset timer for start
	timer.Reset();
	
	return true;
}
Beispiel #17
0
void DemoShutdown()
{
	window.Shutdown();										//Shutdown window
}
Beispiel #18
0
//draw a frame
void RenderFrame()
{
	//Clear buffers
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();										//reset modelview matrix


	camera.SetupViewMatrix();
	glMultMatrixf(camera.viewMatrix);

	DrawBackground();


	glPushAttrib(GL_ALL_ATTRIB_BITS);
	
	//Enable vertex program
	glEnable(GL_VERTEX_PROGRAM_NV);

	//Enable register combiners
	glEnable(GL_REGISTER_COMBINERS_NV);

	//Enable textures
	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubeMapTexture);
	glEnable(GL_TEXTURE_CUBE_MAP_ARB);
	
	glActiveTextureARB(GL_TEXTURE1_ARB);
	glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubeMapTexture);
	glEnable(GL_TEXTURE_CUBE_MAP_ARB);

	//Set up CHROMATIC_SINGLE tex units
	if(renderPath==CHROMATIC_SINGLE)
	{
		glActiveTextureARB(GL_TEXTURE2_ARB);
		glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubeMapTexture);
		glEnable(GL_TEXTURE_CUBE_MAP_ARB);

		glActiveTextureARB(GL_TEXTURE3_ARB);
		glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubeMapTexture);
		glEnable(GL_TEXTURE_CUBE_MAP_ARB);
	}
	
	glActiveTextureARB(GL_TEXTURE0_ARB);

	//Set the texture Matrix to be the inverse view matrix
	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	glMultMatrixf(camera.viewMatrix.GetInverse());
	glMatrixMode(GL_MODELVIEW);

	//Create object display lists
	static GLuint objectLists;
	if(!objectLists)
	{
		objectLists=glGenLists(3);
		
		glNewList(objectLists, GL_COMPILE);
		{
			glutSolidSphere(1.0, 120, 60);
		}
		glEndList();

		glNewList(objectLists+1, GL_COMPILE);
		{
			glutSolidTorus(0.3, 0.7, 120, 60);
		}
		glEndList();

		glNewList(objectLists+2, GL_COMPILE);
		{
			glutSolidTeapot(1.0f);
		}
		glEndList();
	}

	//If using CHROMATIC_TWIN, need to do two passes, so set states every frame
	if(renderPath==CHROMATIC_TWIN)
		InitChromaticTwin1States();

	//draw object
	glCallList(objectLists+objectType);

	//Do the second path if necessary
	if(renderPath==CHROMATIC_TWIN)
	{
		InitChromaticTwin2States();
		glCallList(objectLists+objectType);
	}

	//Reset texture matrix
	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
	glPopAttrib();

	


	fpsCounter.Update();											//update frames per second counter
	glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
	window.StartTextMode();
	window.Print(0, 28, "FPS: %.2f", fpsCounter.GetFps());			//print the fps
	glColor4f(0.5f, 0.0f, 1.0f, 1.0f);
	if(renderPath==CHROMATIC_SINGLE)
		window.Print(0, 48, "Single Pass Chromatic Aberration");
	if(renderPath==SIMPLE_SINGLE)
		window.Print(0, 48, "Single Pass Simple Refraction");
	if(renderPath==CHROMATIC_TWIN)
		window.Print(0, 48, "Two Pass Chromatic Aberration");
	window.EndTextMode();
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

	if(window.isKeyPressed(VK_F1))
	{
		window.SaveScreenshot();
		window.SetKeyReleased(VK_F1);
	}

	window.SwapBuffers();									//swap buffers

	//check for any opengl errors
	window.CheckGLError();

	//quit if necessary
	if(window.isKeyPressed(VK_ESCAPE))
		PostQuitMessage(0);
}
Beispiel #19
0
extern "C" LONG ALMCALLBACK WndAdminProc(
  OBJECTID                oiWindow,
  AObjMessage*            theSystem)
  {
  WINDOW*                 wnd;
  LONG                    rVal = A_NOTHANDLED;

  switch(theSystem->message1)
    {
    case AOBJ_AWAKENED:
      #ifdef AW_I_DEBUG
      g_nLayoutUseCount++;
      if (!g_hinstLayout)
        {
        I_ASSERT(g_nLayoutUseCount==1);
        g_hinstLayout = LoadLibrary("ALM_WLAY.DLL");
        ADBG_PRINT_I("Preloading Layout Editor");
        }
      #endif
      rVal = A_OK;
      break;

    case AOBJ_CREATED:
      #ifdef AW_I_DEBUG
      g_nLayoutUseCount++;
      if (!g_hinstLayout)
        {
        I_ASSERT(g_nLayoutUseCount==1);
        g_hinstLayout = LoadLibrary("ALM_WLAY.DLL");
        ADBG_PRINT_I("Preloading Layout Editor");
        }
      #endif

      wnd = new(oiWindow) WINDOW(oiWindow);  //The locks the data
      delete wnd;  //Just unlocks the data -- DOES NOT DELETE THE DATAS!!!
      rVal = A_OK;
      break;

    case AOBJ_DESTROYED:
    case AOBJ_ASLEEP:
      #ifdef AW_I_DEBUG
      g_nLayoutUseCount--;
      if(g_nLayoutUseCount==0)
        {
        FreeLibrary(g_hinstLayout);
        g_hinstLayout = NULL;
        g_lpfnEditWnd = NULL;
        g_lpfnItemFromUID = NULL;
        ADBG_PRINT_I("Unloading Layout Editor");
        }
      #endif
      rVal = A_CONTINUE;
      break;

    case AOBJ_ASSIGNOBJECT:
      //Assignment of a window object is not yet defined
      break;

    case AOBJ_PREWRITE:
      if (theSystem->message4 != /*AOBJ_PROJECTSAVE*/2)
        {
        wnd = LockWindowData(oiWindow);
        I_VERIFY_POINTER(wnd, break);
        if(wnd->PutItemsIntoDatas())
          rVal = A_CONTINUE;
        else
          rVal = A_NOTHANDLED;
        UnlockWindowData(oiWindow);
        }
      else
Beispiel #20
0
//Perform per frame updates
void UpdateFrame()
{
	window.Update();

	//update balls' position
	float c = 2.0f*(float)cos(timer.GetTime()/600);
  
	metaballs[0].position.x=-4.0f*(float)cos(timer.GetTime()/700) - c;
	metaballs[0].position.y=4.0f*(float)sin(timer.GetTime()/600) - c;

	metaballs[1].position.x=5.0f*(float)sin(timer.GetTime()/400) + c;
	metaballs[1].position.y=5.0f*(float)cos(timer.GetTime()/400) - c;

	metaballs[2].position.x=-5.0f*(float)cos(timer.GetTime()/400) - 0.2f*(float)sin(timer.GetTime()/600);
	metaballs[2].position.y=5.0f*(float)sin(timer.GetTime()/500) - 0.2f*(float)sin(timer.GetTime()/400);
	
	//increase or decrease density
	if(window.isKeyPressed(VK_UP) && gridSize<maxGridSize)
	{
		gridSize++;
		cubeGrid.Init(gridSize);
	}

	if(window.isKeyPressed(VK_DOWN) && gridSize>minGridSize)
	{
		gridSize--;
		cubeGrid.Init(gridSize);
	}

	//pause & unpause
	if(window.isKeyPressed('P'))
	{
		timer.Pause();
	}

	if(window.isKeyPressed('U'))
	{
		timer.Unpause();
	}

	//clear the field
	for(int i=0; i<cubeGrid.numVertices; i++)
	{
		cubeGrid.vertices[i].value=0.0f;
		cubeGrid.vertices[i].normal.LoadZero();
	}
	
	//evaluate the scalar field at each point
	VECTOR3D ballToPoint;
	float squaredRadius;
	VECTOR3D ballPosition;
	float normalScale;
	for(int i=0; i<numMetaballs; i++)
	{
		squaredRadius=metaballs[i].squaredRadius;
		ballPosition=metaballs[i].position;

		//VC++6 standard does not inline functions
		//by inlining these maually, in this performance-critical area,
		//almost a 100% increase in speed is found
		for(int j=0; j<cubeGrid.numVertices; j++)
		{
			//ballToPoint=cubeGrid.vertices[j].position-ballPosition;
			ballToPoint.x=cubeGrid.vertices[j].position.x-ballPosition.x;
			ballToPoint.y=cubeGrid.vertices[j].position.y-ballPosition.y;
			ballToPoint.z=cubeGrid.vertices[j].position.z-ballPosition.z;
			
			//get squared distance from ball to point
			//float squaredDistance=ballToPoint.GetSquaredLength();
			float squaredDistance=	ballToPoint.x*ballToPoint.x +
									ballToPoint.y*ballToPoint.y +
									ballToPoint.z*ballToPoint.z;
			if(squaredDistance==0.0f)
				squaredDistance=0.0001f;

			//value = r^2/d^2
			cubeGrid.vertices[j].value+=squaredRadius/squaredDistance;

			//normal = (r^2 * v)/d^4
			normalScale=squaredRadius/(squaredDistance*squaredDistance);
			//cubeGrid.vertices[j].normal+=ballToPoint*normalScale;
			cubeGrid.vertices[j].normal.x+=ballToPoint.x*normalScale;
			cubeGrid.vertices[j].normal.y+=ballToPoint.y*normalScale;
			cubeGrid.vertices[j].normal.z+=ballToPoint.z*normalScale;
		}
	}

	//toggle wireframe
	if(window.isKeyPressed('W'))
	{
		glPolygonMode(GL_FRONT, GL_LINE);
	}

	if(window.isKeyPressed('F'))
	{
		glPolygonMode(GL_FRONT, GL_FILL);
	}

	//Change color
	if(window.isKeyPressed(VK_SPACE))
	{
		currentDiffuseColor++;
		if(currentDiffuseColor==numDiffuseColors)
			currentDiffuseColor=0;
		glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuseColors[currentDiffuseColor]);

		window.SetKeyReleased(VK_SPACE);
	}
}
Beispiel #21
0
void Edit::on_hover()
{
	if(Mouse::is_over(get_position(), get_size()))
	{
		// change mouse cursor to I-beam
		WINDOW * window = WINDOW::get_active();
		if(window != nullptr)
		{
		#ifdef __windows__
		    HCURSOR ibeam = LoadCursor(nullptr, IDC_IBEAM);
		    SetClassLong(window->get_handle(), GCL_HCURSOR, (DWORD)ibeam); // DWORD = unsigned long
        #endif		
		#ifdef __gnu_linux__		
		    Cursor cursor = XCreateFontCursor(window->get_display(), XC_xterm); 
            XDefineCursor(window->get_display(), window->get_handle(), cursor);
			XFreeCursor(window->get_display(), cursor);
		#endif
		}
	} else {   // revert back to original mouse cursor
		WINDOW * window = WINDOW::get_active();
		if(window != nullptr)
		{
	    #ifdef __windows__
		    HCURSOR arrow = LoadCursor(nullptr, IDC_ARROW);
		    SetClassLong(window->get_handle(), GCL_HCURSOR, (DWORD)arrow);
		#endif
		#ifdef __gnu_linux__	
		    Cursor cursor = XCreateFontCursor(window->get_display(), XC_left_ptr); 
            XDefineCursor(window->get_display(), window->get_handle(), cursor);
			XFreeCursor(window->get_display(), cursor);
		#endif	
		}
	}
}
Beispiel #22
0
//draw a frame
void RenderFrame()
{
	//Clear buffers
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();										//reset modelview matrix


	glEnable(GL_LIGHTING);
	glTranslatef(0.0f, 0.0f, -30.0f);
	glRotatef((float)timer.GetTime()/30, 1.0f, 0.0f, 1.0f);
	cubeGrid.DrawSurface(threshold);
	glDisable(GL_LIGHTING);

	
	fpsCounter.Update();											//update frames per second counter
	glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
	window.StartTextMode();
	window.Print(0, 28, "FPS: %.2f", fpsCounter.GetFps());			//print the fps
	glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
	window.Print(0, 48, "Grid Size: %d", gridSize);
	window.Print(0, 68, "%d triangles drawn", cubeGrid.numFacesDrawn);
	window.EndTextMode();
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

	if(window.isKeyPressed(VK_F1))
	{
		window.SaveScreenshot();
		window.SetKeyReleased(VK_F1);
	}

	window.SwapBuffers();									//swap buffers

	//check for any opengl errors
	window.CheckGLError();

	//quit if necessary
	if(window.isKeyPressed(VK_ESCAPE))
		PostQuitMessage(0);
}
Beispiel #23
0
void gui_thread(GUI_DRIVER_INFO* drv_info)
{
    unsigned int res, tmp, redraw;
    WINDOW win;
    WINDOW top;
    WINDOW desktop;		//main_dlg;
    CHandle key_hnd;
    CHandle gui_hnd;

    //prevent these signals not to be used from task handles
    ALLOCATE_SIGNAL(SIG_GUI_TASK);

    //wait for static constructors (lcd object)
    while(!detect_displays(drv_info))
        tsk_sleep(10);

    // start desktop
    while( !(desktop = tsk_new_window(maindlg_cb)) )
    {
        tsk_sleep(10);
    }
    desktop->next = NULL;
    top = desktop;
    desktop->rect.x1 = drv_info->lcd[0]->size_x;
    desktop->rect.y1 = drv_info->lcd[0]->size_y;

    for(int i=0; i<GUI_DISPLAYS; i++)
    {
        if(drv_info->lcd[i])
        {
#if GUI_DISPLAYS > 1
            desktop->displays |= (1<<i);
#endif
            drv_info->lcd[i]->lcd_init((GUI_CB)splashdlg_cb);
        }
    }
    tsk_sleep(3000);


    init_main_menu();


    // start key handle
    key_hnd.tsk_safe_open(KEY_DRV_INDX, 0);
    key_hnd.src.as_int = 0;
    key_hnd.tsk_start_read(&key_hnd.src.as_int, 1);


    // start gui handle
    gui_hnd.tsk_safe_open(GUI_DRV_INDX, 0);			//mode = 1 - control handle
    gui_hnd.tsk_start_read(NULL, 0);

    for(;;)
    {
        res = tsk_wait_signal(-1u, 1000 - (CURRENT_TIME %1000));
        redraw = res>>8;;

        if(!res)
            redraw = 0xFF;

        // 1) get waiting objects
        if(res & gui_hnd.signal)
        {
            drv_info->lcd[0]->backlight_signal();
            gui_hnd.res &= ~FLG_SIGNALED;
            win = (WINDOW)gui_hnd.dst.as_voidptr;
            if(win)
            {
                top->next = win;
                do
                {
                    top = (WINDOW)top->next;
                    top->rect.x1 = desktop->rect.x1;
                    top->rect.y1 = desktop->rect.y1;
                    top->callback(NULL , WM_INIT);
#if GUI_DISPLAYS > 1
                    redraw |= top->displays;
#endif
                } while( top->next );
            }
            gui_hnd.tsk_start_read(NULL, 0);
#if GUI_DISPLAYS == 1
            redraw |= 1;
#endif
        }


        // 2) check keyboard
        if(res &  key_hnd.signal)
        {
            drv_info->lcd[0]->backlight_signal();
            key_hnd.res &= ~FLG_SIGNALED;
            //send to top
            tmp = top->callback(key_hnd.src.as_int , WM_KEY);
            if(tmp & FLG_BUSY)	//FLG_BUSY returned to redraw
            {
                tmp ^= FLG_BUSY;
#if GUI_DISPLAYS > 1
                redraw |= top->displays;
#else
                redraw |= 1;
#endif
            }
            top->mode1 = tmp;
            key_hnd.tsk_start_read(&key_hnd.src.as_int, 1);
        }

        // 3)  command loop
        top = NULL;
        win = desktop;
        do
        {
            // check for pending commands
            if(win->mode0 & FLG_OK)
            {
                locked_clr_byte(&win->mode0, FLG_OK);
                tmp = win->callback(win->dst.as_int, WM_USER);
                if(tmp & FLG_BUSY)	//FLG_BUSY returned to redraw
                {
                    tmp ^= FLG_BUSY;
#if GUI_DISPLAYS > 1
                    redraw |= win->displays;
#else
                    redraw |= 1;
#endif
                }
                win->mode1 |= tmp;

            }

            //check for complete (close object)
            if(top && ((win->mode0 | win->mode1) & FLG_SIGNALED) )
            {
                top->next = win->next;
#if GUI_DISPLAYS > 1
                redraw |= win->displays;
#else
                redraw |= 1;
#endif
                usr_HND_SET_STATUS(win, win->mode1 | FLG_SIGNALED);
                win = (WINDOW)top->next;
            } else
            {
                top = win;
                win = (WINDOW)win->next;
            }

        } while (win );

        // 3) draw loop
        for(int i=0; i<GUI_DISPLAYS; i++)
        {
            if( (redraw & (1<<i)) && drv_info->lcd[i])
            {
                drv_info->lcd[i]->redraw_screen(desktop);
            }
        }
    }

}
void c_clear_window(  /*move pen */
                    void *win) {
  WINDOW window = (WINDOW) win;

  window->Clear_view_surface ();
}
void c_make_current(  /*move pen */
                    void *win) {
  WINDOW window = (WINDOW) win;

  window->Make_picture_current ();
}
Beispiel #26
0
//Set up variables
bool DemoInit()
{
	if(!window.Init("Render To Texture", 640, 480, 32, 24, 8, WINDOWED_SCREEN))
		return 0;											//quit if not created

	camera.Init(VECTOR3D(0.0f, 0.0f, -2.5f), 2.0f, 100.0f);

	//Set up extensions
	if(	!SetUpWGL_ARB_extensions_string())
		return false;

	SetUpEXT_texture_filter_anisotropic();
	SetUpSGIS_generate_mipmap();
		
	//Get the WGL extensions string
	const char * wglExtensions;
	wglExtensions=wglGetExtensionsStringARB(window.hDC);

	//Set up wgl extensions
	if(	!SetUpWGL_ARB_pbuffer(wglExtensions) || !SetUpWGL_ARB_pixel_format(wglExtensions) ||
		!SetUpWGL_ARB_render_texture(wglExtensions))
		return false;


	//Init the pbuffer
	int pbufferExtraIAttribs[]={WGL_BIND_TO_TEXTURE_RGBA_ARB, true,
								0};

	int pbufferFlags[]={WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB,
						WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB,
						
						//request mipmap space if mipmaps are to be used
						SGIS_generate_mipmap_supported ? WGL_MIPMAP_TEXTURE_ARB : 0,
						SGIS_generate_mipmap_supported ? true : 0,

						0};

	if(!pbuffer.Init(pbufferSize, pbufferSize, 32, 24, 8, 1, pbufferExtraIAttribs, pbufferFlags))
		return false;
	

	//Create the texture object to relate to the pbuffer
	glGenTextures(1, &pbufferTexture);
	glBindTexture(GL_TEXTURE_2D, pbufferTexture);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	//Use generated mipmaps if supported
	if(SGIS_generate_mipmap_supported)
	{
		glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, true);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
		glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
		useMipmapFilter=true;
	}

	//Use maximum anisotropy if supported
	if(EXT_texture_filter_anisotropic_supported)
	{
		glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
		currentAnisotropy=maxAnisotropy;
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, currentAnisotropy);
	}



	//Load the decal texture
	//Note: This MUST be done when the pbuffer is the current context
	pbuffer.MakeCurrent();
	
	IMAGE decalImage;
	decalImage.Load("decal.bmp");

	glGenTextures(1, &decalTexture);
	glBindTexture(GL_TEXTURE_2D, decalTexture);
	glTexImage2D(	GL_TEXTURE_2D, 0, GL_RGBA8, decalImage.width, decalImage.height,
					0, decalImage.format, GL_UNSIGNED_BYTE, decalImage.data);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);


	
	//reset timer for start
	timer.Reset();
	
	return true;
}
Beispiel #27
0
//draw a frame
void RenderFrame()
{
    //Clear buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();										//reset modelview matrix

    camera.SetupViewMatrix();
    glLoadMatrixf(camera.viewMatrix);

    //Enable box texture
    glEnable(GL_TEXTURE_2D);

    //Enable attenuation textures
    if(codePath==TEXTURE_ATTEN || codePath==GAUSSIAN_ATTEN)
    {
        //2D atten
        glActiveTextureARB(GL_TEXTURE1_ARB);
        glEnable(GL_TEXTURE_2D);
        //1D atten
        glActiveTextureARB(GL_TEXTURE2_ARB);
        glEnable(GL_TEXTURE_1D);
        glActiveTextureARB(GL_TEXTURE0_ARB);
    }
    else if(codePath==PASS_THROUGH_ATTEN)	//set up pass through states
    {
        //enable texture shaders
        glEnable(GL_TEXTURE_SHADER_NV);
    }
    else if(codePath==TEXTURE_3D_ATTEN)
    {
        //3D atten
        glActiveTextureARB(GL_TEXTURE1_ARB);
        glEnable(GL_TEXTURE_3D);
        glActiveTextureARB(GL_TEXTURE0_ARB);
    }



    //Enable vertex program
    glEnable(GL_VERTEX_PROGRAM_NV);
    glBindProgramNV(GL_VERTEX_PROGRAM_NV, vertexProgram);

    //Send the light's color to primary color
    glColor4fv(lightColors[currentLightColor]);

    //set the texture matrix
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glTranslatef(0.5f, 0.5f, 0.5f);
    glScalef(0.5f, 0.5f, 0.5f);
    glScalef(1/lightRadius, 1/lightRadius, 1/lightRadius);
    glTranslatef(-lightPosition.x, -lightPosition.y, -lightPosition.z);
    glMatrixMode(GL_MODELVIEW);

    //Enable register combiners
    glEnable(GL_REGISTER_COMBINERS_NV);

    //Draw Cube
    glDrawArrays(GL_QUADS, 0, 24);

    //Disable box texture
    glDisable(GL_TEXTURE_2D);

    //Disable attenuation textures
    if(codePath==TEXTURE_ATTEN || codePath==GAUSSIAN_ATTEN)
    {
        //2D atten
        glActiveTextureARB(GL_TEXTURE1_ARB);
        glDisable(GL_TEXTURE_2D);
        //1D atten
        glActiveTextureARB(GL_TEXTURE2_ARB);
        glDisable(GL_TEXTURE_1D);
        glActiveTextureARB(GL_TEXTURE0_ARB);
    }
    else if(codePath==PASS_THROUGH_ATTEN)	//set up pass through states
    {
        //disable texture shaders
        glDisable(GL_TEXTURE_SHADER_NV);
    }
    else if(codePath==TEXTURE_3D_ATTEN)
    {
        //3D atten
        glActiveTextureARB(GL_TEXTURE1_ARB);
        glDisable(GL_TEXTURE_3D);
        glActiveTextureARB(GL_TEXTURE0_ARB);
    }

    //Disable vertex program
    glDisable(GL_VERTEX_PROGRAM_NV);

    //reset the texture matrix
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);

    //Disable register combiners
    glDisable(GL_REGISTER_COMBINERS_NV);


    //Draw light in a display list
    glColor4fv(lightColors[currentLightColor]);
    glTranslatef(lightPosition.x, lightPosition.y, lightPosition.z);
    static GLuint sphereList=0;
    if(!sphereList)
    {
        sphereList=glGenLists(1);
        glNewList(sphereList, GL_COMPILE);
        {
            gluSphere(sphere, 0.1f, 24, 12);
        }
        glEndList();
    }
    glCallList(sphereList);
    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);



    fpsCounter.Update();											//update frames per second counter
    glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
    window.StartTextMode();
    window.Print(0, 28, "FPS: %.2f", fpsCounter.GetFps());			//print the fps
    glColor4f(1.0f, 1.0f, 0.0f, 0.0f);
    if(codePath==TEXTURE_ATTEN)
        window.Print(0, 48, "Using Texture Attenuation");
    if(codePath==PASS_THROUGH_ATTEN)
        window.Print(0, 48, "Using Pass Through Attenuation");
    if(codePath==TEXTURE_3D_ATTEN)
        window.Print(0, 48, "Using 3D Texture Attenuation");
    if(codePath==GAUSSIAN_ATTEN)
        window.Print(0, 48, "Using Gaussian Texture Attenuation");
    window.EndTextMode();
    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

    if(window.isKeyPressed(VK_F1))
    {
        window.SaveScreenshot();
        window.SetKeyReleased(VK_F1);
    }

    window.SwapBuffers();									//swap buffers

    //check for any opengl errors
    window.CheckGLError();

    //quit if necessary
    if(window.isKeyPressed(VK_ESCAPE))
        PostQuitMessage(0);
}