Solved

printing the object in the opengl window

Posted on 2008-10-23
1
364 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now