View Full Version : Newbie Question
Hello!
I have built a small openGL code drawing an object. i want to move this object by reading the data from en editbox on a Form (c++). So lets say, if the value in this box increases the object should move or rotate faster.
Now, where do i have to place this funtion in my code (Frompaint, InitGl, etc?), and which gl-functions do i need to call every time the value changes so that it works?
Maybe somebody has a code snippet for that?
Thanks
nexusone
09-17-2002, 08:44 AM
I don't have any windows based code, but you need to have some type of event managment.
event_idle()
{
// Nothing going on, keep spinning the cube.
}
Then some variables that keeps your current cube state.
cube_state = 1= spinning, 0 = stopped.
cube_speed = ? // current cube speed of movement.
cube_rotation = ?// store cubes current rotation.
cube_xyz = 0,0,0 // location of cube.
If I remember in windows you call window_paint (something like that) to update screen.
the following website has windows example code for opengl. nehe.gamedev.net
Originally posted by Clouddancer:
Hello!
I have built a small openGL code drawing an object. i want to move this object by reading the data from en editbox on a Form (c++). So lets say, if the value in this box increases the object should move or rotate faster.
Now, where do i have to place this funtion in my code (Frompaint, InitGl, etc?), and which gl-functions do i need to call every time the value changes so that it works?
Maybe somebody has a code snippet for that?
Thanks
[This message has been edited by nexusone (edited 09-17-2002).]
Hi!
Thanks for the reply.
Well i think that i have to implement the function under void __fastcall TForm1::FormPaint(TObject *Sender)...seems the most logical to me. i have to test,but it's pretty hard.
You wrote something about event management and event_idle. Do you maybe know, where to find some decription to that or the specific nehe tutorial/lesson?
Deiussum
09-17-2002, 09:51 AM
Sounds like you're using Borland Builder for your development. I'm not too familiar with their Win32 wrapper classes, but somewhere there's got to be a way to setup an event for the edit-boxes "on change" event.
nexusone
09-17-2002, 11:00 AM
Windows API for the most part is a event driven format, if you are writing a word processor, or CAD. Events are taken care of in windows API.
But in a game events are things that happen even when a player is not doing anything.
This is where a event loop is needed for idle time. You would do this with some type of timer function, every X time check for non-user events or update objects etc.
example of an idle event... if player has not moved in X amount of time start making faces at him.
or a monster's are moving around our world.
Or just a simple animation on the screen.
Here is a link to a good windows C++ site for opengl: www.GameTutorials.com (http://www.GameTutorials.com)
I think since you are learning opengl, would be best for you to go over all his tutors.
Originally posted by Clouddancer:
Hi!
Thanks for the reply.
Well i think that i have to implement the function under void __fastcall TForm1::FormPaint(TObject *Sender)...seems the most logical to me. i have to test,but it's pretty hard.
You wrote something about event management and event_idle. Do you maybe know, where to find some decription to that or the specific nehe tutorial/lesson?
[This message has been edited by nexusone (edited 09-17-2002).]
Hi There!
Thanks for your Inputs!! I will go through the recommended site. But i've found the solution. You were right nexusone, i had to implement an "Idle-Function", right into the constructor of the cpp.
No it works pretty fine:-)
But i will go on, and learn much more about OpenGL, as it really is fascinating!
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.