我遵循the OpenGL programming book的代码教程,但它不起作用。它在我的窗口左上方显示白色矩形。你能告诉我它有什么问题吗?
class UserFeedback {
[string]$Name
[int]$ThingCount
[datetime]$ProcessStartDateTime
[int]$ProcessedCount
UserFeedback ([string] $Name,[int]$ThingCount){
$this.ProcessStartDateTime = Get-Date
$this.Name = $Name
$this.ThingCount = $ThingCount
$this.ProcessedCount = 0
}
WriteProgress([int] $intProcessed){
$this.ProcessStartDateTime
$SecondsElapsed = ((Get-Date) - $this.ProcessStartDateTime).TotalSeconds
$SecondsRemaining = ($SecondsElapsed / ($intProcessed / $this.ThingCount)) - $SecondsElapsed
Write-Progress -Activity $this.Name -PercentComplete (($intProcessed/$($this.ThingCount)) * 100) -CurrentOperation "$("{0:N2}" -f ((($intProcessed/$($this.ThingCount)) * 100),2))% Complete" -SecondsRemaining $SecondsRemaining
}
WriteProgress(){
$this.WriteProgress($this.ProcessedCount)
}
Increment(){
$this.ProcessedCount ++
}
答案 0 :(得分:2)
首先,在所有其他与GLUT相关的调用之前,您未在glutInit(&argc, argv)
中调用main()
。其次,您未在glutSwapBuffers()
中致电Render()
。
除此之外,您不会更改投影矩阵,因此不具备与本教程开头所示相同的调整大小功能。
void Resize(int width, int height)
{
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 1.0f, 1000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
更改这些内容和代码应该有效。