Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members Related Pages
Lesson2: Using OpenGL drawing. - In this lesson you will learn how to draw a simple shape in the window, which you know how to create from the Lesson 1.
- See also:
- sjgui::CWnd::OnDraw()
class CSpcWnd : public sjgui::CWnd
{
public:
virtual void OnDraw()
{
SET_GL_SIMPLE_PROSPECTIVE;
glTranslatef(0.0f,0.0f,-10.0f);
glColor3f(0.0f,0.0f,1.0f);
glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();
}
};
Back to Lesson 1. Forward to Lesson 3.
- The following is full source code for this lesson.
#include <sjgui/sjgui.h>
class CSpcWnd : public sjgui::CWnd
{
public:
virtual void OnDraw()
{
SET_GL_SIMPLE_PROSPECTIVE;
glTranslatef(0.0f,0.0f,-10.0f);
glColor3f(0.0f,0.0f,1.0f);
glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();
}
};
int main(int argc, char* argv[])
{
CSpcWnd SpcWnd;
SpcWnd.PosWnd(20,50,320,240);
if(sjgui::Create("Drawing something!",&SpcWnd))
{
sjgui::GlobalMainLoop();
}
else
printf("Could not create opengl window.\n");
return 0;
}
|
|