PDA

View Full Version : OpenGL acceleration (again)



01-19-2001, 03:52 PM
My video card supports OpenGL yet none of my or nehe's tut apps run with acceleration on my computer.
(tested in windowed & 640 x 480 @ 16bits)

i posted this a while back, and somebody told me that i used ChoosePixelFormat to pick a format, and that i need to do better enumeration. i would like to try this, but i dont know how. i dont think its the resolution and i know my card supports 16 aspects of OGL.

any help would be great, (and it is NOT the resolution)

Osku
01-19-2001, 04:29 PM
What card do you have and what driver version?

Osku

coco
01-19-2001, 10:22 PM
The best way to begin with the ugly pixelformat stuff in win32 (such as ChoosePixelFormat, etc) is to copy-paste from piece of working sample code.
This is from the MSVC help:

PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // size of this pfd
1, // version number
PFD_DRAW_TO_WINDOW | // support window
PFD_SUPPORT_OPENGL | // support OpenGL
PFD_DOUBLEBUFFER, // double buffered
PFD_TYPE_RGBA, // RGBA type
16, // 16-bit color depth
0, 0, 0, 0, 0, 0, // color bits ignored
0, // no alpha buffer
0, // shift bit ignored
0, // no accumulation buffer
0, 0, 0, 0, // accum bits ignored
16, // 16-bit z-buffer
0, // no stencil buffer
0, // no auxiliary buffer
PFD_MAIN_PLANE, // main layer
0, // reserved
0, 0, 0 // layer masks ignored
};
HDC hdc;
int iPixelFormat;

// get the best available match of pixel format for the device context
iPixelFormat = ChoosePixelFormat(hdc, &pfd);

// make that the pixel format of the device context
SetPixelFormat(hdc, iPixelFormat, &pfd);

This should work perfectly.

01-20-2001, 10:40 AM
i have an S3 Savage3D with the latest drivers.

I think what i need is an FPS counter so i can really tell. can anyone give me some code for an fps counter that prints it out to a string? i will just use GDI for outputing the text

HoHo
01-21-2001, 02:25 AM
Originally posted by Rocket05:
i have an S3 Savage3D with the latest drivers.

I think what i need is an FPS counter so i can really tell. can anyone give me some code for an fps counter that prints it out to a string? i will just use GDI for outputing the text

Try using GetTickCount() and some static variables in your main drawing loop to get the number of milliseconds passed between two calls to this function and one static variable to store the total amount of milliseconds. One variable use for counting the # of frames (everytime you call the drawing fnc. equals one frame) When the total amount of milliseconds is greater than 1000 write the # of frames to another global variable(from which you can use it during processing the WM_PAINT message) and erase the total amount of millisec. and nr. of frames. For printing the number of frames to a string use the sprintf() function.

HoHo
01-21-2001, 02:29 AM
Maybe not too clear, but check out the SDK for openGL in vc++ (some programs using glaux have this fps count)

Glenn Upton
01-21-2001, 09:14 PM
// This timer will be used to recalculate the frame rate every second
SetTimer(hWnd, 1, 1000, NULL); // Every Five Seconds

break;

// Updates frame rate every 5 seconds
case WM_TIMER:
{
int nFrames;
char cOutBuffer[32];
LARGE_INTEGER currentTime;
float fps;

// Get the frame count
EnterCriticalSection(&csThreadSafe);
nFrames = rsRenderData.uiFrames;
LeaveCriticalSection(&csThreadSafe);

// Get the current Time
QueryPerformanceCounter(&currentTime);

fps = (float)(nFrames - nLastFrames)/((float)(currentTime.QuadPart - startTime.QuadPart)/
(float)timerFrequency.QuadPart);
// sprintf(cOutBuffer, "fps %0.1f %d x %d Navigate:arrow keys, Elevate:PGUP/PGDN, Camera Tilt:A,Z, Rotation:R, Wireframe:W ", fps, width, height);

sprintf(cOutBuffer, "fps %0.1f %d x %d", fps, width, height);
SetWindowText(hWnd, cOutBuffer);
nLastFrames = nFrames;

// Resets the timer
QueryPerformanceCounter(&startTime);
}
break;

Deiussum
01-22-2001, 08:40 AM
to tell if you're using hardware accelleration use glGetString(GL_VENDOR) and glGetString(GL_RENDERER). If the strings say something about using the Microsoft implementation, you are not using hardware accelleration.