I'm using opengl for 2D rendering of triangular meshes. I'm using a single form concept with a status bar and couple of buttons at the bottom.
The problem is, when i set the rendering context to the form's handle, and start handling onPaint OpenGL fills the entire canvas when using glClear. The glViewport sets the render area, OK. But how do i constrain the painting area to a rectangle on the form, and not the entire canvas. I've read about rendering in other controls, but things got all messed up (... and after 3 hrs. i gave up, and decided to ask )
In short: How can one make OpenGL draw in a specified region of a form 10x in advance.
P.S It's fundamental i know, but i was unable to formulate a decent search phrase
Registriert: Do Dez 05, 2002 10:35 Beiträge: 4234 Wohnort: Dortmund
Welcome to the forum
The only thing you have to do is to place an TPanel on your form and create the render context (RC) with the device context (DC) of the panel. Normally you call DC := GetDC(Form.Handle) but now you must call DC := GetDC(Panel.Handle). And with this DC you are able to create an RC on the panel. The OpenGL drawing now will be applied to the panel.
BUT. You said you are using OnPaint from the form. If you only wants to render if the windows need to repaint you can't use the TPanel directlly. The TPanel dosn't provides an OnPaint event. I have written an really small component named TAdvancedPanel. It introduce the OnPaint Event and the ability to recieve the Focus / TabStop and the arrow keys. Simple use this instead the TPanel and it should works.
Mitglieder in diesem Forum: 0 Mitglieder und 3 Gäste
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.