rendered paste bodybool SDLRenderArea::init(RenderArea* sharedArea)
{
std::cout << "Initializing SDLRenderArea" << std::endl;
#if defined(_WIN32)
m_hglrc = wglGetCurrentContext();
m_hdc = wglGetCurrentDC();
WGLAttachContext(m_hdc, m_hglrc);
#elif defined(LINUX)
m_hglrc = glXGetCurrentContext();
m_drawable = glXGetCurrentDrawable();
m_dpy = glXGetCurrentDisplay();
GLXAttachContext(m_dpy, m_hglrc);
#else
#error
#endif
makeCurrent();
if (!nvui::RenderArea::init(sharedArea))
throw std::string("bad");
NVSG_ASSERT(m_renderTraverser == 0);
NVSG_VERIFY(m_renderTraverser = new GLTraverser);
// Load Shaders
std::cout << "Begin loading shaders." << std::endl;
std::string path;
nvutil::GetCurrentDir( path );
path += "/shaders/blue.cg";
// Create the context, this is a container for Cg programs
CGcontext context = cgCreateContext();
if(context == NULL){
std::cout << "Failed to create CGcontext." << std::endl;
exit(-1);
}else{
CGprogram program = cgCreateProgramFromFile(
context, // The context where we want it added
CG_SOURCE, // The following parameter is an
// array of bytes containing Cg source
path.c_str(), // The sourcefile
CG_PROFILE_ARBVP1,// The profile
"main", // The entry function
NULL // Compiler options
);
if(program==NULL){
std::cout << "Failed to compile the program: " << path.c_str() << std::endl;
exit(-1);
}else{
std::cout << "Loaded shader: " << path << std::endl;
// Now load the program
cgGLLoadProgram(program);
// Enable the profile
cgGLEnableProfile(CG_PROFILE_ARBVP1);
// Bind the program
cgGLBindProgram(program);
}
}
m_renderTraverser->addRef();
}