Jump to content
  • Advertisement
Sign in to follow this  
overseb

OpenGL OpenGL without viewport

This topic is 5404 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone I am trying to make an opengl picture renderer But my opengl app acts like a server I dont have any window or linux viewport, all my opengl stuff is in a DLL I don't use any pixelformatdescriptor or wglmakecontext. My pb is that I am using the function glReadPixel to make my frame picture, but that function doesn't work without any drawing context ??!!! Do you see my pb ? have any solution for me ? thx a lot ...

Share this post


Link to post
Share on other sites
Advertisement
you need to create a ogl context before you can use ogl at all

instead of rendering to a viewport you could have a look at pBuffers for rendering
i don t know if you can run opengl without a viewport at all though

Share this post


Link to post
Share on other sites
I don't want any ogl graphic context in my dll, I don't have any viewport

Isn't it possible to use opengl without stuff like that ??
m_hDC = ::GetDC(m_hWnd);
m_hRC = wglCreateContext(m_hDC);
wglMakeCurrent(m_hDC, m_hRC);


Do you have more details about pBuffer ?
thx ...

Share this post


Link to post
Share on other sites
Sounds like you want an offscreen rendering solution, and for offscreen rendering, I can highly recomend Mesa's offscreen driver OSMesa. It's a software renderer, so use it only if speed is of lesser importance.

Share this post


Link to post
Share on other sites
ok, again on my offscreen rendering pb

There is a solution without using Mesa, it is just to make a pBuffer for an offscreen rendering with the extension WGL_ARB_pbuffer.

I use the function glGetString(GL_EXTENSIONS) to get extension, but this damn function need an opengl context to work !!
So what is the solution ??
How to make an opengl offscreen context ?

thx ... ^^

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just create and then usea memory device context.

HDC memdc = CreateCompatibleDC(NULL);

then use memdc.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

m_hDC = ::CreateCompatibleDC(NULL); // Creates a compatible
// DC with the screen.
m_hRC = wglCreateContext(m_hDC);
wglMakeCurrent(m_hDC, m_hRC);

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
mm yeah, but there is a pb :
m_hDC = ::CreateCompatibleDC(NULL); // Creates a compatible
// DC with the screen.
m_hRC = wglCreateContext(m_hDC);
wglMakeCurrent(m_hDC, m_hRC);

m_hRC is set to NULL

any solution ?

Share this post


Link to post
Share on other sites
ok apparently I must create a dummy window to get a dummy device context to create my opengl context, then I will be able to create my pBuffer in my DLL (sic)

I tried this code :
HWND hWnd;
WNDCLASS wndclass;
memset(&wndclass, 0, sizeof(WNDCLASS));
wndclass.style = CS_OWNDC;
wndclass.lpfnWndProc = WinProc;
wndclass.hInstance = NULL;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) (COLOR_WINDOW+1);
wndclass.lpszClassName = "test";
RegisterClass(&wndclass);

hWnd = CreateWindow("test", "test", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, NULL, NULL);

HDC dummyHDC = ::GetDC(hWnd );
static PIXELFORMATDESCRIPTOR pfd =
{ sizeof(PIXELFORMATDESCRIPTOR),
1, PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA, 0,0,0,0,0,0,0,0,0,0,0,0,0,
16, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0
};

int pixelFormat = ChoosePixelFormat(dummyHDC, &pfd);
SetPixelFormat(dummyHDC, pixelFormat, &pfd);
HGLRC dummyHGLRC = wglCreateContext(dummyHDC);
wglMakeCurrent(dummyHDC, dummyHGLRC);

const unsigned char* tmp = glGetString(GL_EXTENSIONS);
std::string ext = (char*)tmp;
int k = ext.find("WGL_ARB_pbuffer");

but k == -1 it doesn't find my extension

I am sure that my window or my DC don't fit...
thx

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!