Example #1
0
/**
 * If we can determine the WGL extension support from the current
 * context, then return that, otherwise give the answer that will just
 * send us on to get_proc_address().
 */
bool
epoxy_conservative_has_wgl_extension(const char *ext)
{
    HDC hdc = wglGetCurrentDC();

    if (!hdc)
        return true;

    return epoxy_has_wgl_extension(hdc, ext);
}
Example #2
0
void glfntInit(void)
{
    HDC hdc;

    if (LettersDL!=0) return;
    hdc=wglGetCurrentDC();
    SelectObject(hdc,GetStockObject(SYSTEM_FONT));
    LettersDL=glGenLists(128);
    wglUseFontBitmaps(hdc,32,127,LettersDL+32);
}
Example #3
0
void SpriteCreate(CCallParams& p)
{
    CBaseOglControl* ctrl = CBaseOglControl::controls[WindowFromDC(wglGetCurrentDC())];
    if (0 == ctrl || p.AsString(0) == "" || p.AsString(1) == "")return;
    ctrl->Collection().SpriteList().Create(p.AsString(0));
    CBaseSprite* spr = GetSprite(p.AsString(0));
    if (spr == 0)return;
    CBaseTexture* tex = ctrl->Collection().TextureList().Get(p.AsString(1));
    spr->SetTexture(tex);
}
QtRenderWindow::QtRenderWindow(QWidget* parent, QGLFormat format) : QGLWidget(format, parent)
{
	makeCurrent();
	deviceContext = wglGetCurrentDC();
	glContext = wglGetCurrentContext();
	onMakeCurrent();

	mRealtime = false;
	mNeedsUpdate = true;
}
void PlatformGetBackbufferDimensions( uint32& OutWidth, uint32& OutHeight )
{
	OutWidth = OutHeight = 0;
	HDC DeviceContext = wglGetCurrentDC();
	if( DeviceContext )
	{
		OutWidth = GetDeviceCaps( DeviceContext, HORZRES );
		OutHeight = GetDeviceCaps( DeviceContext, VERTRES );
	}
}
Example #6
0
bool               P3DGLMemoryContextPBuffer::Create
                                      (unsigned int        Width,
                                       unsigned int        Height,
                                       bool                NeedAlpha)
 {
  int              PixelFormat;
  UINT             FormatCount;
  HDC              CurrDeviceContext;

  CurrDeviceContext = wglGetCurrentDC();

  if (wglChoosePixelFormatARB( CurrDeviceContext,
                               NeedAlpha ? PBufferPixelFormatIntAttrsAlpha :
                                           PBufferPixelFormatIntAttrsNoAlpha,
                               NULL,
                               1,
                              &PixelFormat,
                              &FormatCount))
   {
    if (FormatCount == 0)
     {
      return(false);
     }
   }
  else
   {
    return(false);
   }

  PBufferHandle = wglCreatePbufferARB
                   (CurrDeviceContext,
                    PixelFormat, 
                    Width,
                    Height,
                    PBufferAttrs);

  if (PBufferHandle == NULL)
   {
    return(false);
   }

  PBufferDC = wglGetPbufferDCARB(PBufferHandle);
  GLContext = wglCreateContext(PBufferDC);

  if (MakeCurrent())
   {
    return(P3DGLExtInit());
   }
  else
   {
    return(false);
   }

  return(true);
 }
Example #7
0
void cl_context::init()
{
    // OpenCL
    try
    {
        // Get available platforms
        vector<cl::Platform> platforms;
        cl::Platform::get(&platforms);
        LOG_INFO<<platforms.front().getInfo<CL_PLATFORM_VERSION>();

        // context sharing is OS specific
#if defined (__APPLE__) || defined(MACOSX)
        CGLContextObj curCGLContext = CGLGetCurrentContext();
        CGLShareGroupObj curCGLShareGroup = CGLGetShareGroup(curCGLContext);

        cl_context_properties properties[] =
        {
            CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
            (cl_context_properties)curCGLShareGroup,
            0
        };
#elif defined WIN32
        cl_context_properties properties[] =
        {
            CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
            CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
            CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[0])(),
            0
        };
#else
        cl_context_properties properties[] =
        {
            CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(),
            CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(),
            CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[0])(),
            0
        };
#endif

        m_context = cl::Context(CL_DEVICE_TYPE_GPU, properties);

        // Get a list of devices on this platform
        vector<cl::Device> devices = m_context.getInfo<CL_CONTEXT_DEVICES>();
        m_device = devices[0];

        // Create a command queue and use the first device
        m_queue = cl::CommandQueue(m_context, m_device);

    }
    catch(cl::Error &error)
    {
        LOG_ERROR << error.what() << "(" << oclErrorString(error.err()) << ")";
    }
}
bool CGraphicView::GetScreenPtFrom3DPoint( const CPoint3D& modelSpacePt, CPoint& screenPt )
{
	// this function works for any xyz point but usually we will just be returning the 
	// screen point for a grid point or node.
	GLint viewport[4];
	GLdouble mvMatrix[16], projMatrix[16];
	double winX = 0.0;
	double winY = 0.0;
	double winZ = 0.0; //depth value between 0 and 1 - for depth sorting
	bool bSuccess = false;

	HGLRC currentRC = wglGetCurrentContext();
	if( !currentRC )
	{
		TRACE( "CGraphicView::GetScreenPtFrom3DPoint Failed in GetCurrentContext\n" );
		return bSuccess;
	}
	HDC hDC = wglGetCurrentDC( );
	if( !hDC )
	{
		TRACE( "CGraphicView::GetScreenPtFrom3DPoint Failed in GetCurrentDC\n" );
		return bSuccess;
	}

	//if( !wglMakeCurrent( m_pDC->GetSafeHdc(), m_hDC ) )
	if( !wglMakeCurrent( hDC, currentRC ) )
	{
		TRACE( "CGraphicView::GetScreenPtFrom3DPoint Failed in MakeCurrent\n" );
		return bSuccess;
	}

	glGetIntegerv( GL_VIEWPORT, viewport );
	glGetDoublev( GL_MODELVIEW_MATRIX, mvMatrix );
	glGetDoublev( GL_PROJECTION_MATRIX, projMatrix );

	if( !gluProject( modelSpacePt.x, modelSpacePt.y, modelSpacePt.z, 
		             mvMatrix, projMatrix, viewport, 
				     &winX, &winY, &winZ ) )
	{
		//TRACE( "Failed in GetScreenPt #2\n" );
		//wglMakeCurrent( NULL, NULL );
		return bSuccess;
	}

	//openGL convention (origin at lower left)
	screenPt.x = int(winX);
	screenPt.y = int(winY);


	//windows convention (origin at upper left)
	screenPt.y = viewport[3] - viewport[1] - screenPt.y;
	bSuccess = true;
	return bSuccess;
}
void CL::TinyCL::selectInteropDevice(DEVICE dev, bool profile) {
    try {
        //We assume only the first device and platform will be used
        //This is after all a lazy implementation
        cl::Platform::get(&mPlatforms);
        //Query the devices for the type desired
        mPlatforms.at(0).getDevices(static_cast<cl_device_type>(dev), &mDevices);
#ifdef _WIN32
        cl_context_properties properties[] = {
            CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
            CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
            CL_CONTEXT_PLATFORM, (cl_context_properties)(mPlatforms[0])(),
            0
        };
#elif defined(__linux__)
        cl_context_properties properties[] = {
            CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(),
            CL_WGL_HDC_KHR, (cl_context_properties)glXGetCurrentDisplay(),
            CL_CONTEXT_PLATFORM, (cl_context_properties)(mPlatforms[0])(),
            0
        };
#elif defined(__APPLE__)
        CGLContextObj glContext = CGLGetCurrentContext();
        CGLShareGroupObj shareGroup = CGLGetShareGroup(glContext);
        cl_context_properties properties[] = {
            CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
            (cl_context_properties)shareGroup,
        };
#endif

        mContext = cl::Context(mDevices, properties);
        //Grab the OpenGL device
        mDevices = mContext.getInfo<CL_CONTEXT_DEVICES>();
        if (profile)
            mQueue = cl::CommandQueue(mContext, mDevices.at(0), CL_QUEUE_PROFILING_ENABLE);
        else
            mQueue = cl::CommandQueue(mContext, mDevices.at(0));

        std::cout << "OpenCL Info:"
                  << "\nName: " << mDevices.at(0).getInfo<CL_DEVICE_NAME>()
                  << "\nVendor: " << mDevices.at(0).getInfo<CL_DEVICE_VENDOR>()
                  << "\nDriver Version: " << mDevices.at(0).getInfo<CL_DRIVER_VERSION>()
                  << "\nDevice Profile: " << mDevices.at(0).getInfo<CL_DEVICE_PROFILE>()
                  << "\nDevice Version: " << mDevices.at(0).getInfo<CL_DEVICE_VERSION>()
                  << "\nMax Work Group Size: " << mDevices.at(0).getInfo<CL_DEVICE_MAX_WORK_GROUP_SIZE>()
                  << std::endl;
    }
    catch (const cl::Error &e) {
        std::cout << "Error selecting GL interop device: " << e.what()
                  << " code: " << e.err() << std::endl;
        throw e;
    }

}
//--------------------------------------
static void fixCloseWindowOnWin32(){

	//get the HWND
	handle = WindowFromDC(wglGetCurrentDC());

	//store the current message event handler for the window
	currentWndProc = (WNDPROC)GetWindowLongPtr(handle, GWL_WNDPROC);

	//tell the window to now use our event handler!
	SetWindowLongPtr(handle, GWL_WNDPROC, (long)winProc);
}
Example #11
0
//---------------------------------------------------------------------------------
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, 	_In_opt_ HINSTANCE hPrevInstance,	_In_ LPWSTR    lpCmdLine, _In_ int       nCmdShow)
{	
	int argc = 0;	char* argv = "";

	// Exit handler to check memory on exit.
	const int result_1 = std::atexit(CheckMemCallback);

	std::wstring commandLine(lpCmdLine);
	gEditorMode = commandLine.find(L"-Editor") != std::string::npos;

	// Setup glut.
	glutInit(&argc, &argv);
	glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);
	glutInitWindowPosition(100, 100);
	int glutWind = glutCreateWindow(APP_WINDOW_TITLE);	
	HDC dc = wglGetCurrentDC();
	MAIN_WINDOW_HANDLE = WindowFromDC(dc);
	glutIdleFunc(Idle);
	glutDisplayFunc(Display);       // Register callback handler for window re-paint event	
	glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
	InitGL();                       // Our own OpenGL initialization

	// Init sounds system.
	CSimpleSound::GetInstance().Initialize(MAIN_WINDOW_HANDLE);
	
	// Call user defined init.
	if (gEditorMode)
	{
		EditorInit();
	}
	else
	{
		Init();
	}

	// Enter glut the event-processing loop				
	glutMainLoop();
	
	// Call user shutdown.
	if (gEditorMode)
	{
		EditorShutdown();
	}
	else
	{
		Shutdown();
	}

	// Shutdown sound system.
	CSimpleSound::GetInstance().Shutdown();

	// And we are done.
	return 0;
}
Example #12
0
HANDLE
CreateBufferRegion(unsigned int buffers)
{
    /* Create the buffer region. */
    HANDLE FBRegion = wglCreateBufferRegionARB(wglGetCurrentDC(), 0, buffers);

    if (FBRegion == 0)
        puts("wglCreateBufferRegionARB Failed");

    return FBRegion;
}
Example #13
0
int Server::initGLContexts()
{
	diplayWindow = wglGetCurrentDC();
	primaryContext = wglGetCurrentContext();
	loadingThreadContext = wglCreateContext(diplayWindow);
	wglMakeCurrent(NULL, NULL);
	BOOL error = wglShareLists(primaryContext, loadingThreadContext);
	wglMakeCurrent(diplayWindow, primaryContext);

	return 0;
}
Example #14
0
void CBaseOglControl::BaseInitialize()
{
	parser.Start();
	PIXELFORMATDESCRIPTOR pfd;
	int pf = 0;
	HDC hDC = GetDC(hMy);
	
	pfd.nSize        = sizeof(pfd);
	pfd.nVersion     = 1;
	pfd.dwFlags      = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
	pfd.iPixelType   = PFD_TYPE_RGBA;
	pfd.cColorBits   = 32;
	pf = ChoosePixelFormat(hDC, &pfd);
	if(pf==0)
	{
		pf = 1;
		if(DescribePixelFormat(hDC,pf,sizeof(PIXELFORMATDESCRIPTOR),&pfd)==0)
		return;
	}

	if (SetPixelFormat(hDC, pf, &pfd) == FALSE) return;
    hOGL = wglCreateContext(hDC);
    
	wglMakeCurrent(hDC, hOGL);
	
		quadObj = gluNewQuadric();//Для отрисовки цилиндра, сфер и т.д.

		//все перенести в скрипт
		glEnable(GL_TEXTURE_2D);
		glEnable(GL_LIGHTING);
		glEnable(GL_LIGHT0);
		glEnable(GL_COLOR_MATERIAL);

		//glDisable(GL_CULL_FACE); 
		glEnable(GL_DEPTH_TEST);
		glEnable(GL_ALPHA_TEST);
		
		glEnable(GL_BLEND); 
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

		glEnable(GL_ALPHA_TEST);
		glAlphaFunc(GL_GREATER, 0.5f);

		
		glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

		Initialize();

		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		SwapBuffers(wglGetCurrentDC());
		glFlush();
		
	wglMakeCurrent(hDC, 0);
}
Example #15
0
// The Effects of Double Buffering on Animation Frame Rates
//		http://www.futuretech.blinkenlights.nl/dbuffer.html
bool _SwapBuffers(JSContext *cx, JSObject *obj, unsigned argc, jsval *argv, jsval *rval) {

//	glFlush();
//	glFinish();
//	JL_ASSERT( JL_GetClass(obj) == _class, RT_ERROR_INVALID_CLASS );
	HDC hDC = wglGetCurrentDC(); // (TBD) un-specialize from OpenGL
	JL_ASSERT( hDC != NULL, "Could not get the Current Device Context." );
	BOOL res = SwapBuffers(hDC); // Doc: With multithread applications, flush the drawing commands in any other threads drawing to the same window before calling SwapBuffers.
	JL_ASSERT( res, "Unable to SwapBuffers.(%x)", GetLastError() );
	return true;
}
Example #16
0
static HGLRC init_ogl_context_ex(HDC dc, bool fc, int major, int minor)
{
   HWND testwnd = NULL;
   HDC testdc   = NULL;
   HGLRC testrc = NULL;
   HGLRC old_rc = NULL;
   HDC old_dc   = NULL;
   HGLRC glrc   = NULL;

   testwnd = _al_win_create_hidden_window();
   if (!testwnd)
      return NULL;

   old_rc = wglGetCurrentContext();
   old_dc = wglGetCurrentDC();

   testdc = GetDC(testwnd);
   testrc = init_temp_context(testwnd);
   if (!testrc)
      goto bail;

   if (is_wgl_extension_supported("WGL_ARB_create_context", testdc)) {
      int attrib[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, major,
                      WGL_CONTEXT_MINOR_VERSION_ARB, minor,
                      WGL_CONTEXT_FLAGS_ARB, 0,
                      0};
      if (fc)
         attrib[5] = WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
      if (!init_context_creation_extensions())
         goto bail;
      /* TODO: we could use the context sharing feature */
      glrc = _wglCreateContextAttribsARB(dc, 0, attrib);
   }
   else
      goto bail;

bail:
   wglMakeCurrent(NULL, NULL);
   if (testrc) {
      wglDeleteContext(testrc);
   }

   wglMakeCurrent(old_dc, old_rc);

   _wglCreateContextAttribsARB = NULL;

   if (testwnd) {
      ReleaseDC(testwnd, testdc);
      DestroyWindow(testwnd);
   }

   return glrc;
}
Example #17
0
void CBaseOglCamera::GetViewPort(RECT& vp)
{
	if (viewPort[0] != 0 || viewPort[1] != 0 || viewPort[2] != 0 || viewPort[3] != 0)
	{
		vp.left = viewPort[0];
		vp.top = viewPort[1];
		vp.right = viewPort[2];
		vp.bottom = viewPort[3];
	}
	else
		GetClientRect(WindowFromDC(wglGetCurrentDC()), &vp);
}
void RenderTarget_Win32::StartRenderingTo()
{
	m_hOldDeviceContext = wglGetCurrentDC();
	m_hOldRenderContext = wglGetCurrentContext();

	BOOL successful = wglMakeCurrent(GraphicsWindow::GetHDC(), g_HGLRC);
	ASSERT_M( successful == TRUE, "wglMakeCurrent failed in RenderTarget_Win32::StartRenderingTo()" );

	FlushGLErrors();
	glBindTexture( GL_TEXTURE_2D, m_texHandle );
	AssertNoGLError();
}
Example #19
0
/** returns true if the extension is available */
static bool WGLQueryExtension(WGLExtensions *extensions, const char *name) {
	const GLubyte *extension_string;

	if (!extensions->WGL_ARB_extensions_string)
		if (!extensions->WGL_EXT_extensions_string)
			return false;
		else
			extension_string = (GLubyte*)extensions->wglGetExtensionsStringEXT();
	else
		extension_string = (GLubyte*)extensions->wglGetExtensionsStringARB(wglGetCurrentDC());
	return extgl_QueryExtension(extension_string, name);
}
void KH::TextDrawer::SelectFont(int size, int charset, const char* face = "Arial") 
{ 
	fontName = std::string(face);
	fontSize = size;
	//创建指定字体 
	HFONT hFont = CreateFontA(size, 0, 0, 0, FW_MEDIUM, 0, 0, 0, charset, 
							OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, 
							DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, face
							); 
	//把创建的字体选入设备上下文,保存旧字体     
	HFONT hOldFont = (HFONT)SelectObject(wglGetCurrentDC(), hFont); 
}
Example #21
0
SkWGLExtensions::SkWGLExtensions()
    : fGetExtensionsString(nullptr)
    , fChoosePixelFormat(nullptr)
    , fGetPixelFormatAttribfv(nullptr)
    , fGetPixelFormatAttribiv(nullptr)
    , fCreateContextAttribs(nullptr)
    , fSwapInterval(nullptr)
    , fCreatePbuffer(nullptr)
    , fGetPbufferDC(nullptr)
    , fReleasePbufferDC(nullptr)
    , fDestroyPbuffer(nullptr)
 {
    HDC prevDC = wglGetCurrentDC();
    HGLRC prevGLRC = wglGetCurrentContext();

    PIXELFORMATDESCRIPTOR dummyPFD;

    ZeroMemory(&dummyPFD, sizeof(dummyPFD));
    dummyPFD.nSize = sizeof(dummyPFD);
    dummyPFD.nVersion = 1;
    dummyPFD.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
    dummyPFD.iPixelType = PFD_TYPE_RGBA;
    dummyPFD.cColorBits  = 32;
    dummyPFD.cDepthBits  = 0;
    dummyPFD.cStencilBits = 8;
    dummyPFD.iLayerType = PFD_MAIN_PLANE;
    HWND dummyWND = create_dummy_window();
    if (dummyWND) {
        HDC dummyDC = GetDC(dummyWND);
        int dummyFormat = ChoosePixelFormat(dummyDC, &dummyPFD);
        SetPixelFormat(dummyDC, dummyFormat, &dummyPFD);
        HGLRC dummyGLRC = wglCreateContext(dummyDC);
        SkASSERT(dummyGLRC);
        wglMakeCurrent(dummyDC, dummyGLRC);

        GET_PROC(GetExtensionsString, ARB);
        GET_PROC(ChoosePixelFormat, ARB);
        GET_PROC(GetPixelFormatAttribiv, ARB);
        GET_PROC(GetPixelFormatAttribfv, ARB);
        GET_PROC(CreateContextAttribs, ARB);
        GET_PROC(SwapInterval, EXT);
        GET_PROC(CreatePbuffer, ARB);
        GET_PROC(GetPbufferDC, ARB);
        GET_PROC(ReleasePbufferDC, ARB);
        GET_PROC(DestroyPbuffer, ARB);

        wglMakeCurrent(dummyDC, nullptr);
        wglDeleteContext(dummyGLRC);
        destroy_dummy_window(dummyWND);
    }

    wglMakeCurrent(prevDC, prevGLRC);
}
Example #22
0
void btgGLInit(CView *pView)
{
	oldRect = drawRect;

	pView->GetClientRect(&drawRect);

	if(oldRect != drawRect)
	{
		if (hGLDeviceContext != NULL)
		{
			wglMakeCurrent(NULL, NULL);
			wglDeleteContext(hGLRenderContext);
			hGLRenderContext = 0;
		}
	}

	hGLDeviceContext = wglGetCurrentDC();
	if (hGLDeviceContext == NULL || hGLRenderContext == 0)
	{
		hGLDeviceContext = ::GetDC(pView->GetSafeHwnd());

		setupPixelFormat(hGLDeviceContext);
		setupPalette(hGLDeviceContext);
		hGLRenderContext = wglCreateContext(hGLDeviceContext);  //create GL render context and select into window
		wglMakeCurrent(hGLDeviceContext, hGLRenderContext);

		//create the viewport for rendering
		auxInitPosition(0, 0, drawRect.right - drawRect.left, drawRect.bottom - drawRect.top);
		//set mode (direct color)
		auxInitDisplayMode(AUX_RGB);
	}
	else
	{
		//wglMakeCurrent(hGLDeviceContext, hGLRenderContext);
	}

	CBTGDoc* pDoc = (CBTGDoc*)pView->GetDocument();
	glClearColor((GLfloat)pDoc->mBGRed / 255.0f,
				 (GLfloat)pDoc->mBGGreen / 255.0f,
				 (GLfloat)pDoc->mBGBlue / 255.0f,
				 1.0f);
	glClear(GL_COLOR_BUFFER_BIT);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluOrtho2D(0, drawRect.right - drawRect.left, 0, drawRect.bottom - drawRect.top);
	glDisable(GL_LIGHTING);
	glDisable(GL_CULL_FACE);
	glDisable(GL_DEPTH_TEST);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE);
}
static void
_wgl_release (void *abstract_ctx)
{
    cairo_wgl_context_t *ctx = abstract_ctx;

    if (ctx->prev_dc != wglGetCurrentDC () ||
        ctx->prev_rc != wglGetCurrentContext ())
    {
        wglMakeCurrent (ctx->prev_dc,
                        ctx->prev_rc);
    }
}
void KH::TextDrawer::DrawEngString(const char* str) {     
	static int isFirstCall = 1;     
	static GLuint lists;     
	if( isFirstCall ) { 
		// 如果是第一次调用,执行初始化         
		// 为每一个ASCII字符产生一个显示列表         
		isFirstCall = 0;         // 申请MAX_CHAR个连续的显示列表编号         
		lists = glGenLists(_DRAW_MAX_CHAR);         // 把每个字符的绘制命令都装到对应的显示列表中         
		wglUseFontBitmaps(wglGetCurrentDC(), 0, _DRAW_MAX_CHAR, lists);     
	}     // 调用每个字符对应的显示列表,绘制每个字符     
	for(; *str!='\0'; ++str)        
		glCallList(lists + *str);
} 
Example #25
0
void FsSwapBuffers(void)
{
	if(0==doubleBuffer)
	{
		MessageBoxA(NULL,"Error! FsSwapBuffers used in the single-buffered mode.","Error!",MB_OK);
		exit(1);
	}

	HDC hDC;
	glFlush();
	hDC=wglGetCurrentDC();
	SwapBuffers(hDC);
}
Example #26
0
void CBaseOglControl::ReDraw()
{
	SetFocus(hMy);
	CalcFps();
	wglMakeCurrent(GetDC(hMy), hOGL);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	Refresh();

	SwapBuffers(wglGetCurrentDC());
	glFlush();
	wglMakeCurrent(GetDC(hMy), 0);
}
Example #27
0
	MapilVoid GLSprite::DrawString(	SharedPointer < GraphicsFont > pFont,
									const MapilTChar* pStr,
									ImageTransformationMethod method,
									const Vector2 < MapilFloat32 >& v,
									MapilUInt32 color )
	{
		if( !pStr ){
			return;
		}

#if defined ( API_WIN32API )

		::HDC hdc = wglGetCurrentDC();

		// Build string to be displayed.
		MapilTChar str[ 4096 ];
		va_list vl;
		MapilInt32 len;
		
		va_start( vl, pStr );
		len = _vsctprintf( pStr, vl ) + 1;
		if( len > sizeof( str ) ){
			return;
		}
		_vstprintf( str, pStr, vl );
		va_end( vl );
		len = _tcslen( str );

		SelectObject( hdc, reinterpret_cast < HFONT > ( pFont->Get() ) );
				
		MapilInt32 list = glGenLists( len );

		for( MapilInt32 i = 0; i < len; i++ ){
			wglUseFontBitmaps( hdc, str[ i ], 1, list + i );
		}

		//glDisable( GL_LIGHTING );

		glColor4i( ( color >> 16 ) & 0xFF , ( color >> 8 ) & 0xFF, color & 0xFF, ( color >> 24 ) & 0xFF );
		//glColor4f( 1.0f, 0.0f, 0.0f, 1.0f );
		glRasterPos2f( v.m_X, v.m_Y );
		for( MapilInt32 i = 0; i < len; i++ ){
			glCallList( list + i );
		}

		//glEnable( GL_LIGHTING );

		glDeleteLists( list, len );

#endif	// API_WIN32API
	}
Example #28
0
static void prepareSwapOnDC(HDC hdc,HDC &oldDC,HGLRC &oldRC)
{
  oldDC = wglGetCurrentDC();
  oldRC = wglGetCurrentContext();

  if(oldDC != hdc)
  {
    HGLRC rc = rcFromDC[hdc];
    if(rc)
      Mine_wglMakeCurrent(hdc,rc);
    else
      printLog("video/opengl: SwapBuffers called on DC with no active rendering context. This is potentially bad.\n");
  }
}
//----------------------------------------------------------------------------//
void OpenGLWGLPBTextureTarget::initialisePBuffer()
{
    int creation_attrs[] =
    {
        WGL_PBUFFER_LARGEST_ARB, true,
        0
    };

    releasePBuffer();

    HDC hdc = wglGetCurrentDC();
    d_pbuffer = wglCreatePbufferARB(hdc, d_pixfmt, 
                                    static_cast<int>(d_area.getWidth()),
                                    static_cast<int>(d_area.getHeight()),
                                    creation_attrs);

    if (!d_pbuffer)
        CEGUI_THROW(RendererException(
            "OpenGLWGLPBTextureTarget::initialisePBuffer - "
            "pbuffer creation failure, wglCreatePbufferARB() call failed."));

    d_hdc = wglGetPbufferDCARB(d_pbuffer);

    if (!d_hdc)
        CEGUI_THROW(RendererException(
            "OpenGLWGLPBTextureTarget::initialisePBuffer - "
            "pbuffer creation failure, wglGetPbufferDCARB() call failed."));

    d_context= wglCreateContext(d_hdc);

    if (!d_hdc)
        CEGUI_THROW(RendererException(
            "OpenGLWGLPBTextureTarget::initialisePBuffer - "
            "pbuffer creation failure, wglCreateContext() call failed."));

    if(!wglShareLists(wglGetCurrentContext(), d_context))
        CEGUI_THROW(RendererException(
            "OpenGLWGLPBTextureTarget::initialisePBuffer - "
            "pbuffer creation failure, wglShareLists() call failed."));

    // extract the actual size of the created bufer
    int actual_width, actual_height;
    wglQueryPbufferARB(d_pbuffer, WGL_PBUFFER_WIDTH_ARB, &actual_width);
    wglQueryPbufferARB(d_pbuffer, WGL_PBUFFER_HEIGHT_ARB, &actual_height);
    d_area.setSize(Size(static_cast<float>(actual_width),
                        static_cast<float>(actual_height)));

    // ensure CEGUI::Texture is wrapping real GL texture and has correct size
    d_CEGUITexture->setOpenGLTexture(d_texture, d_area.getSize());
}
Example #30
0
static int extensionSupportedWGL(const char* extension)
{
    const char* extensions = NULL;

    if (_glfw.wgl.GetExtensionsStringARB)
        extensions = _glfw.wgl.GetExtensionsStringARB(wglGetCurrentDC());
    else if (_glfw.wgl.GetExtensionsStringEXT)
        extensions = _glfw.wgl.GetExtensionsStringEXT();

    if (!extensions)
        return GLFW_FALSE;

    return _glfwStringInExtensionString(extension, extensions);
}