• Advertisement


This topic is now archived and is closed to further replies.

Dynamic image display

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

An extremely long winded question... I''m not a very experienced programmer, but I''ve been using OpenGL as part of a project which converts an image into a large array, then transmits segments of this array to a receiver which then draws the segments to the screen as they arrive. The segmenting, transmitting and receiving are fine, but the displaying is my problem. Currently I am using a VC++ appwizard window with the GL window inside it (somehow). I am then using the glDrawPixels function to plot each array-segment to the screen as it arrives. This works fine, but it''s way too complicated. I wanted a much simpler program that would display the image without any File menus or Status bars - ie in a simple GL window. This was when I discovered the NeHe tutorials. I realized that with one page of code (lesson 2) I could display my image instead of the 6 pages + 8 headers + 5 resource folders that I am currently using. However, this is where my lack of C++ experience becomes a problem. Ideally the textured quad would be the best way to display the image (I think). But because there is no file to read from, and because the image is arriving in bits then that becomes difficult - unless I create 480 long thin textured quads. So I return to using the good old glDrawPixels function. This I assume goes into the GLDrawScene function. (Correct me if I''m wrong) So I have a function that receives the pixel-size of the image, and then the array-segments which are stored in a big 2d array: Big2dArray[ImageHeight][ImageWidth * 3] (* 3 because of RGB values for each pixel) I think I should call this function in WinMain(), so that the GL window can be initialised to be the right size for the image(ImageWidth * ImageHeight). What I want to know is how do I pass "Big2dArray" and the values of "ImageWidth" and "ImageHeight" to the GLDrawScene function? The code I would use to plot the image is this (is it right): unsigned char *SmallArray; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); SmallArray = ((unsigned char*)calloc((imageWidth * 3), sizeof(unsigned char))); /////////Big2dArray has to appear somehow/////////////// glRasterPos2d(0, 0); for(int t=0; t< imageHeight; t++) { SmallArray = Big2dArray[t]; glDrawPixels(imageWidth, 1, GL_RGB, GL_UNSIGNED_BYTE, SmallArray); glRasterPos2d(0, t); } glFlush(); free (SmallArray); free (Big2dArray); It''s a very long question with probably a very short answer (a wee bit of code would be useful) but I wanted to make sure that you have as much information as possible. I know it''s also not a game related question but it relates to the NeHe code. I hope you can help me - thank you very much for your time. Regards Andrew Muir Wood

Share this post

Link to post
Share on other sites

  • Advertisement