Solved

printing the object in the opengl window

Posted on 2008-10-23
1
381 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

738 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