Jump to content

  • Log In with Google      Sign In   
  • Create Account


rotation, while resizing


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 A_M_S_S   Members   -  Reputation: 122

Like
0Likes
Like

Posted 29 January 2012 - 04:54 PM

Hello all
i am a beginner in OpenGL, i am using TAO framework with C#,
i noticed that my render control stooped updating while re-sizing the window, i had overcome the problem of updating the content of the render control by calling the my game loop function in the event handler of the form re-size event

but the rotation still have some work it is still not updated till the re-sizing process stop
here is my code

void GameLoop(double elapsedTime)
{
Gl.glViewport(0, 0, _openGLControl.Width, _openGLControl.Height);
////////////////////
float r = Color.DarkBlue.R / 255.0f;
float g = Color.DarkBlue.G / 255.0f;
float b = Color.DarkBlue.B / 255.0f;
float a = Color.DarkBlue.A / 255.0f;
Gl.glClearColor(r, g, b, a);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
Gl.glRotated(40 * elapsedTime, 0, 1, 0);
Gl.glBegin(Gl.GL_TRIANGLES);
{
Gl.glColor3d(1, 1, 0);
Gl.glVertex3d(-0.5,-0.5, 0);
Gl.glColor3d(0, 1, 1);
Gl.glVertex3d(0.5, -0.5, 0);
Gl.glColor3d(1, 0, 1);
Gl.glVertex3d(0, 0.5, 0);
}
Gl.glEnd();
Gl.glFinish();
_openGLControl.Refresh();
}

private void Form1_Resize(object sender, EventArgs e)
{
PreciseTimer _timer = new PreciseTimer();
GameLoop(_timer.GetElapsedTime());
}

Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 12275

Like
0Likes
Like

Posted 30 January 2012 - 05:14 AM

Start -> Control Panel -> System -> Advanced -> Performance/Settings
Animate windows when minimizing and maximizing = Checked


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 A_M_S_S   Members   -  Reputation: 122

Like
0Likes
Like

Posted 30 January 2012 - 06:44 AM

it is already checked, any other suggestions ?

#4 L. Spiro   Crossbones+   -  Reputation: 12275

Like
0Likes
Like

Posted 30 January 2012 - 05:53 PM

This is probably an issue with C#, and I haven’t used it much in years outside of one XNA project which is irrelevant here.
The first thing I would try is forcing a repaint operation and making sure it actually gets handled (as I recall, OnPaint() being called manually won’t create an update unless some dirty flag is set etc.)


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#5 A_M_S_S   Members   -  Reputation: 122

Like
0Likes
Like

Posted 31 January 2012 - 04:28 PM

i tried that


protected override void OnPaint(PaintEventArgs e)
{
PreciseTimer _timer = new PreciseTimer();
GameLoop(_timer.GetElapsedTime());
}

still not working
i don't think this a C# issue,
even in NEHE legacy tutorial lesson 4 written in c++, the rotation is stop while window re-sizing and window moving
i don't know if this is an intrinsic property in windows or what
i still need help

#6 irreversible   Crossbones+   -  Reputation: 1203

Like
0Likes
Like

Posted 31 January 2012 - 09:58 PM

I'm pretty sure this is tied to the fact that you're doing your rendering in the main thread, which also handles the user interface. In Windows, sizing (and AFAIR also moving) are blocking calls, which means that you may need to set up a separate thread for rendering. Just remember to keep all of your GL code in one thread as the render context isn't (safely) shared across threads.

#7 A_M_S_S   Members   -  Reputation: 122

Like
0Likes
Like

Posted 01 February 2012 - 06:37 PM

I'm pretty sure this is tied to the fact that you're doing your rendering in the main thread, which also handles the user interface. In Windows, sizing (and AFAIR also moving) are blocking calls, which means that you may need to set up a separate thread for rendering. Just remember to keep all of your GL code in one thread as the render context isn't (safely) shared across threads.


sounds good, i tried this




namespace GameLoop
{
public partial class Form1 : Form
{
FastLoop _fastLoop;

public Form1()
{
InitializeComponent();
_openGLControl.InitializeContexts();
backgroundWorker1.RunWorkerAsync();
}

void GameLoop(double elapsedTime)
{
Gl.glViewport(0, 0, _openGLControl.Width, _openGLControl.Height);
////////////////////
float r = Color.DarkBlue.R / 255.0f;
float g = Color.DarkBlue.G / 255.0f;
float b = Color.DarkBlue.B / 255.0f;
float a = Color.DarkBlue.A / 255.0f;
Gl.glClearColor(r, g, b, a);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
//Gl.glPointSize(25.0f);
//Gl.glLineWidth(5.0f);
Gl.glRotated(40 * elapsedTime, 0, 1, 0);
Gl.glBegin(Gl.GL_TRIANGLES);
{
Gl.glColor3d(1, 1, 0);
Gl.glVertex3d(-0.5,-0.5, 0);
Gl.glColor3d(0, 1, 1);
Gl.glVertex3d(0.5, -0.5, 0);
Gl.glColor3d(1, 0, 1);
Gl.glVertex3d(0, 0.5, 0);
}
Gl.glEnd();
Gl.glFinish();
if (this._openGLControl.InvokeRequired)
{
this._openGLControl.Invoke(new Action(Refresh));
}
}

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
_fastLoop = new FastLoop(GameLoop);
PreciseTimer _timer = new PreciseTimer();
GameLoop(_timer.GetElapsedTime());
}
}
}

it didn't work, more over, it sometimes make run time errors "access to protected memory"
?????????????????????




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS