Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About fishleg003

  • Rank
  1. I'm trying to add my own idle function but this line is not valid. void App_Idle(System::Object sender, System::EventArgs e) Application::Idle += System::EventHandler(App_Idle); Error : cannot convert from 'void (__clrcall *)(System::Object,System::EventArgs)' to 'System::EventHandler' What am I missing ? heres the full code below, #include "stdafx.h" #include "Form1.h" using namespace System; using namespace BlackJackForm; int i = 0; //is this legal code ? void App_Idle(System::Object sender, System::EventArgs e) { i++; } [STAThreadAttribute] int main(array<System::String ^> ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); Application::Idle += gcnew System::EventHandler(App_Idle); i = 3; // Create the main window and run it Form1 ^MainForm; MainForm = gcnew Form1(); Application::Run(MainForm); return 0; } [Edited by - fishleg003 on February 18, 2008 7:11:54 AM]
  2. fishleg003

    Windows Forms Idle Hell

    Wow information overload, I had no idea c# was seperate from c and that was why I was just going round in circles. Thanks alot for your help I'll keep reading up on it I think. From what I understand you cant make use of the standard libaries from within c# project or use c++ classes ? Ill make a new post just so its more clear I think as I can see myself why its got so twisted. [Edited by - fishleg003 on February 18, 2008 6:00:56 AM]
  3. fishleg003

    Windows Forms Idle Hell

  4. fishleg003

    Windows Forms Idle Hell

    My forms keep flashing but I have figured out how to keep the form updated by actually having a reference to the form created. Below is the basis of the two classes I have, Main File namespace BlackJackForm{ static class Program { public static class Globals { public static string text; public Form1 Main_Form(); } [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Idle += App_Idle; Globals.Main_Form = new Form1; Application.Run(Globals.Main_Form); } static void App_Idle(object sender, EventArgs e) { Globals.Main_Form.Refresh_From_Idle("something"); } } } Form File namespace BlackJackForm { partial class Form1 { private void InitializeComponent() { this.Label = new System.Windows.Forms.Label(); } public void Refresh_From_Idle(string T) { this.Label.Text = T; this.Refresh(); } public System.Windows.Forms.Label Label } } All I wanted was to be able to trigger a change on the forms so when the program idle function is called and it decides the player needs a new card the form would change or the time label would keep ticking. With the above the form is updating but will only update if the mouse moves or if I drag the window it will only then start counting. The idle function should keep firing constantly I'd of thought when no other actions are being performed but it seems to be the oposite only when actions are being performed on the form. How would I correctly setup the idle function so it keeps firing when the program is idle ? and how do I stop the form from flashing ? Please help its driving me nuts ><. [Edited by - fishleg003 on February 17, 2008 3:19:15 PM]
  5. fishleg003

    Windows Forms Idle Hell

    I've got a very basic form but I'm having trouble understanding the basics... How do I keep my program in sync with a class of variables that are displayed in the form for instance. i.e. namespace BlackJackForm{ static class Program { static public class Globals { public static int timer; } /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Globals.timer = new Timer(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Idle += App_Idle; Application.Run(new Form1()); } static void App_Idle(object sender, EventArgs e) { static int last_time; int new_time = getticks()//example BlackJackForm.Form1.Update_Idle(last_time-new_time); } } } Neither of the two lines below work from within the form class and I can access my globals from within the form class itself but I dont know how to trigger the form to redraw itself. I understand I cant update the label as it may not exist yet or thats what the compiler seems to implying. namespace BlackJackForm { partial class Form1 { public static void Update_Idle(int t) { BlackJackForm.Form1.lbl_time.Text = T; BlackJackForm.Form1.lbl_time.Text = BlackJackForm.Program.Globals.Program.timer; } } } How come the classes are layed out so different to just normal c++ why does the main function/globals need to be encapsulated within a static class ? How would I trigger the form to refresh so if the time changes for instance I could say form1.refresh() then that would take into account all changes. Closest I can find to a refresh is a paint event but how would I trigger that based on a variable change like a constantly updating clock ? I understand the application has an idle event is it possible to also declare a form idle event which could update the form itself based on a custom class of ints etc ? Thanks for any help, fishy [Edited by - fishleg003 on February 17, 2008 3:33:14 AM]
  6. fishleg003

    Windows Form Help

    I thought I'd have ago at just doing a basic card game using windows forms. The problem is that I'm having trouble understanding how you actually tell windows to use the custom form designed in forms designer. I've got my basic message loop and window but how do I tell it to populate the window with the designed form ? Below is just a basic form created in the designer, using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; namespace Main { /// <summary> /// Summary for BlackJackForm /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. /// </summary> public ref class BlackJackForm : public System::Windows::Forms::Form { public: BlackJackForm(void) { InitializeComponent(); // //TODO: Add the constructor code here // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~BlackJackForm() { if (components) { delete components; } } private: System::Windows::Forms::Button^ button1; protected: private: System::Windows::Forms::TextBox^ textBox1; private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->button1 = (gcnew System::Windows::Forms::Button()); this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->SuspendLayout(); // // button1 // this->button1->Location = System::Drawing::Point(267, 174); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(187, 51); this->button1->TabIndex = 0; this->button1->Text = L"button1"; this->button1->UseVisualstyleBackColor = true; // // textBox1 // this->textBox1->Location = System::Drawing::Point(203, 94); this->textBox1->Name = L"textBox1"; this->textBox1->Size = System::Drawing::Size(322, 22); this->textBox1->TabIndex = 1; // // BlackJackForm // this->AutoScaleDimensions = System::Drawing::SizeF(8, 16); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(841, 446); this->Controls->Add(this->textBox1); this->Controls->Add(this->button1); this->Name = L"BlackJackForm"; this->Text = L"BlackJackForm"; this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion }; } I'm having real trouble understanding the basics of this but what do I need to do to get windows to reconise the form ? I've programmed the game and its just a case of creating an interface. I know how to hardcode the menu using the windows api but it would take way too long for me to add each button and label etc. Anyone know of a good tutorial site that explains the very basics of windows forms as msdn seems so vague and assumes so much.
  7. fishleg003

    Windows and Opengl help..

    Sorry solved this problem i was setting my windows class wrong. wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ); //flashy flashy wc.hbrBackground = NULL;//stops the background flashing :) How do i overlay opengl and the windows api ive only draw text to the screen using this code below. glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glClear( GL_COLOR_BUFFER_BIT ); glPushMatrix(); glBegin( GL_TRIANGLES ); glColor3f( 1.0f, 0.0f, 0.0f ); glVertex2f( 0.0f, 1.0f ); glColor3f( 0.0f, 1.0f, 0.0f ); glVertex2f( 0.87f, -0.5f ); glColor3f( 0.0f, 0.0f, 1.0f ); glVertex2f( -0.87f, -0.5f ); glEnd(); glPopMatrix(); GetClientRect(hwnd, &rect); //gets the current dimensions of the window DrawText(hdc, TEXT("hello butt fish"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); //draw some text in the center of the screen SwapBuffers( hdc ); If i do it this way the text appears on the screen but if you move the window around the text starts flashing so i cant be drawing it right, anyone know what could be causing that ?
  8. Basically im trying to create an interface using the windows api and opengl to display the graphics so i can have a file menu at the top etc.. Hard for me to explain this only just begun to learn the basics of the api but this is what ive gathered so far.. Heres my main loop, hdc = GetDC(hwnd); EnableOpenGL(hwnd, &hdc, &hrc); while(!Done) { if(!PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )){ //if no messages then redraw window UpdateWindow(hwnd); } else{ if(msg.message == WM_QUIT) Done = true; } TranslateMessage(&msg); //translate keyboard messages DispatchMessage(&msg); //sends the message to our window procedure message handler } DisableOpenGL(hwnd, hdc, hrc); So here i thought if windows is not processing any messages then draw the window a sort of idle msg is that right ? Then in my message handler function i thought i would do something like, switch(message) { case WM_PAINT: GetClientRect(hwnd, &rect); //gets the current dimensions of the window DrawText(hdc, TEXT("Some text in the middle of the screen!!"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); //draw some text in the center of the screen glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glClear( GL_COLOR_BUFFER_BIT ); glPushMatrix(); glBegin( GL_TRIANGLES ); glColor3f( 1.0f, 0.0f, 0.0f ); glVertex2f( 0.0f, 1.0f ); glColor3f( 0.0f, 1.0f, 0.0f ); glVertex2f( 0.87f, -0.5f ); glColor3f( 0.0f, 0.0f, 1.0f ); glVertex2f( -0.87f, -0.5f ); glEnd(); glPopMatrix(); SwapBuffers( hdc ); return 0; break; } My problem is the window is not refreshing properly because at the moment its drawing wierdly like if you move the window around you can see the window flashing black then drawing the triangle... As if its not taking into account the double buffering. Thx alot for any help. fishy.
  9. fishleg003

    ray picking help

    Sorry about that my code is really messy at the moment i do realise that its a member value, still getting used to the naming conventions. Bah i didnt realise it was taking the angle in radians so used to using degrees and i thought the perspective function was taking in the fov/2 of y as 60 but it does actually takes in the whole fov in y. Your a genius m8 after changing the angle into radians 0.52(30 degrees 60/2) when calculating the view space mouse coords it does indeed work :). Yeah you caught me red handed sorry i wanted to get your attention should of posted here then asked you to take another look at the post *slaps himself on the wrist*. Next step ill tidy up the code and see what happeneds when the camera moves.. muhahhaha :).
  10. fishleg003

    manual alternative to glulookat ?

    Yeah that makes it alot clearer but theres one last thing im a still a bit unsure of. You work out the RIGHT vector using the UP vector but you dont seem to update it before hand does this have an impact on the camera axis i know a few lines down from that you do update the UP vector in relation to the others. Vector vN = vEye - vLookat; //forward vector Vector vU = vUp ^ vN;//right vector (here you arnt taking into account any changes that have occured on Up vector or do you recalculate the new up vector before hand?) vU.Normalize(); vN.Normalize(); Vector vV = vN ^ vU; //up vector Its just if the UP vector has changed then the RIGHT vector would be wrong wouldnt it because you calculate the new right vector using the up vector before you update the up vector? sorry maybe its just me being daft.
  11. fishleg003

    Inverse Matrix help...

    My book describes Gaussian Elimination exactly like on this site, http://www.eng.umd.edu/~nsw/ench250/gauss.htm Last step doesnt explain how he gets from the fractions to the final answer. Please help this is driving me crazy.. :( What im trying to ask is there a way for me to get from fractions to the final answer without having to calculate the determinant ?
  12. fishleg003

    manual alternative to glulookat ?

    So with your method you track the rotation of the camera given the camera's look at position i think :)... // determine the new n Vector vN = vEye - vLookat; // determine the new u by crossing with the up vector Vector vU = vUp ^ vN; // normalize both the u and n vectors vU.Normalize(); vN.Normalize(); // determine v by crossing n and u Vector vV = vN ^ vU; Thing i dont get is you work out a new Forward vector by crossing Up X Right but the thing is Up may have changed. At the very bottom of your matrix you scale the camera's current position by each of the up right forward vectors but why what effect does this have? right.x up.x forw.x right.y up.y forw.y right.z up.z forw.z -(vEye.x * vU.x), -(vEye.y * vV.y), -(vEye.z * vN.z), 1.0f I noticed alot of people use column notation to represent the view matrix for opengl so im a tad confused to which one it will accept is it the column or row formation ? [Edited by - fishleg003 on October 29, 2006 10:00:41 AM]
  13. fishleg003

    manual alternative to glulookat ?

    Yeah thats pritty much what im doing at the moment i noticed that you dont take into account the eye look at position or am i missing something ? My view matrix so far, 1 0 0 0 //right vector 0 1 0 0 //up vector 0 0 -1 0 //forward vector -Cam_Posx -Cam_Posy -Cam_Posz 1 //minus cam pos So i apply rotations to the idividual up right forward vectors ? I tried looking for the previous thread you mentioned cant seem to find it :(.
  14. Ive been using glulookat for a while but i think its time i understand exactly how it works so i can get the most from it. I normally just store cam pos and the rotations in x y z then apply those to the camera's center and location then pass it all to glulookat but now id prefer to do this manually so i can store the whole view matrix in memory. 1 0 0 0 //right vector 0 1 0 0 //up vector 0 0 -1 0 //forward vector 0 0 0 1 Multiply this by the Camera's translation matrix this is where im a bit cloudy... 1 0 0 0 0 1 0 0 0 0 1 0 -Cam_Posx -Cam_Posy -Cam_Posz 1 Im confused where the rotations on the camera are applied do i keep applying the rotations to each individual right up forward vector then plonk them into the top matrix or do i apply the rotations to the camera's translation matrix and leave the original look vectors alone ? Thx for any help. Fishy
  15. fishleg003

    Inverse Matrix help...

    Thank you so much for going through that in so much detail the book i have is so annoying it just assumes you know how you get to these numbers... My book describes it a bit differently to what you said but i think like you said its just a different approach, 2 3 8 1 0 0 --- Multiply Row 1 by 1/2 6 0 -3 0 1 0 -1 3 2 0 0 1 1 3/2 4 1/2 0 0 6 0 -3 0 1 0 --- Add -6 times row 1 to row 2 -1 3 2 0 0 1 --- Add 1 times row 1 to row 3 1 3/2 4 1/2 0 0 0 -9 -27 -3 1 0 --- Multiply row 2 by -1/9 0 9/2 6 1/2 0 1 1 3/2 4 1/2 0 0--Add -3/2 times row 2 to row 1 0 1 3 1/3 1/9 0 0 9/2 6 1/2 0 1--Add -3/2 times row 2 to row3 So hard to explain but thats the jist of what the book goes through until you reach the inverse moving a row each time and adding multiples of the current row to the others to make the zero's. Quote:Anyway, this is devious - you shouldn't need to calculate the determinant in order to invert. At least not for n > 2. Not too sure what you meant by this i thought id always need the determinant to get the inverse or how else would i remove the fractions ?
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!