Jump to content
  • Advertisement
Sign in to follow this  
Kincaid

gdi drawing a 1d texture to a window...

This topic is 3637 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

Hello I have a float array defining a 1d texture (RGBA) I would like to display a bar with this texture in my gui. (i.e. i have a frame item in which i want (stretch) display that tex) I have the following code working for bitmaps loaded from resource, but I cant seem to link my float array correctly to display it. any suggestions would be appreciated very much if (msg == WM_PAINT) { // get frame window item HWND frame = GetDlgItem(hWnd,SPECTRUM); // get spectrum frame size RECT r; GetClientRect (GetDlgItem(hWnd,SPECTRUM),&r); int w = r.right; int h = r.bottom; here i determine the length of one 'spectrum' = float array (channels = 4bpp) grad1d should point to the 1d texture, taken from a a 2d, then the length is the length of the spectrum/bmp, and its only 1 pixel high int rowlen = mod.lights.nSpectrum * mod.lights.nChannels; float* grad1d = mod.lights.map + (l * rowlen ); int gradw = mod.lights.nSpectrum; int gradh = 1; // draw colormap PAINTSTRUCT ps; HDC hdc = BeginPaint(frame, &ps); SetStretchBltMode (hdc,HALFTONE); HDC hdcMem = CreateCompatibleDC(hdc); here im trying something, but get only as far as a black bar i guess im missing one or two lines here....... HBITMAP memBM = CreateCompatibleBitmap ( hdcMem, gradw, gradh ); SetBitmapBits (memBM, rowlen, grad1d); SelectObject (hdcMem, memBM ); StretchBlt (hdc, 0, 0, w, h, hdcMem, 0, 0, mod.lights.nSpectrum, mod.lights.nMaxLights, SRCCOPY); DeleteDC (hdcMem); EndPaint(GetDlgItem(hWnd,SPECTRUM), &ps); return 0; } thanx in advance

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!