Solved

printing the object in the opengl window

Posted on 2008-10-23
1
375 Views
Last Modified: 2012-05-05
I am develping an csgl application in csharp........is there any idea to print the object that is displayed in the opengl window........There is an option called print document in the csharp toolbox..........that is not working......

any ideas?
0
Comment
Question by:jsbsudha
1 Comment
 
LVL 3

Accepted Solution

by:
torrie01 earned 500 total points
ID: 22789914
I haven't used OpenGL before, but here is how I print a screenshot of a window:


        private void Print()
        {
            PrintDocument printDoc = new PrintDocument();
            printDoc.PrintPage += new PrintPageEventHandler(printer_PrintPage);
 
            PrintDialog printForm = new PrintDialog();
            printForm.Document = printDoc;
            printForm.UseEXDialog = true;
            DialogResult result = printForm.ShowDialog();
            if (result == DialogResult.OK)
            {
                printDoc.PrinterSettings = printForm.PrinterSettings;
                
                printDoc.Print();
            }
            
            //removing event handler so object will properly dispose
            printDoc.PrintPage -= new PrintPageEventHandler(printer_PrintPage);
            printDoc.Dispose();
            printForm.Dispose();
        }
 
	void printer_PrintPage(object sender, PrintPageEventArgs e)
        {
	    UserControl screen = this; //replace this with wherever your OpenGL window is
 
            using (Bitmap bmp = new Bitmap(screen.Width, screen.Height))
            {
                screen.DrawToBitmap(bmp, new Rectangle(0, 0, screen.Width, screen.Height));
                e.Graphics.DrawImage(bmp, 0, 0);
            }
        }

Open in new window

0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question