|
HI ALL
I am trying to load image buffer and update image buffer per second .
The function can load 256*256 image or 512*512 image but it can not load 768*576 image.
I apply it with following function,Please let me know how can i load 768*576 image buffer?.
int iwidth=768;
int iHeight=512;
unsigned char* data = 0;
float angle=1.0f;
BOOL CTestDlg::CreateWindowGL(HWND window) // This Code Creates Our OpenGL Window
{
DWORD windowStyle = WS_OVERLAPPEDWINDOW; // Define Our Window Style
DWORD windowExtendedStyle = WS_EX_APPWINDOW; // Define The Window's Extended Style
int iBitperPixel=16;
PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof (PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
iBitperPixel, // Select Our 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, // Accumulation Bits Ignored
16, // 16Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
GLuint PixelFormat; // Will Hold The Selected Pixel Format
CDC *pDc= GetDC(); // Grab A Device Context For This Window
PixelFormat = ChoosePixelFormat (pDc->m_hDC, &pfd); // Find A Compatible Pixel Format
if (SetPixelFormat (pDc->m_hDC, PixelFormat, &pfd) == FALSE) // Try To Set The Pixel Format
{
// Failed
ReleaseDC (pDc); // Release Our Device Context // Zero The Window Handle
return FALSE; // Return False
}
hRC = wglCreateContext (pDc->m_hDC); // Try To Get A Rendering Context
// Make The Rendering Context Our Current Rendering Context
if (wglMakeCurrent (pDc->m_hDC, hRC) == FALSE)
return FALSE;
glViewport (0, 0, (GLsizei)(iwidth), (GLsizei)(iHeight)); // Reset The Current Viewport
glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity (); // Reset The Projection Matrix
gluPerspective (45.0f, (GLfloat)(iwidth)/(GLfloat)(iHeight),1.0f, 100.0f); // Calculate The Aspect Ratio Of The Window
glMatrixMode (GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity ();
return TRUE; // Window Creating Was A Success
// Initialization Will Be Done In WM_CREATE
}
BOOL CTestDlg::Initialize()
{
// Start Of User Initialization
angle = 1.0f;
// Set Starting Angle To Zero // Grab A Device Context For Our Dib
glClearColor (0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth (1.0f); // Depth Buffer Setup
glDepthFunc (GL_LEQUAL); // The Type Of Depth Testing (Less Or Equal)
glEnable(GL_DEPTH_TEST); // Enable Depth Testing
glShadeModel (GL_SMOOTH); // Select Smooth Shading
glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Set Perspective Calculations To Most Accurate
glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); // Set Texture Max Filter
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); // Set Texture Min Filter
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); // Set The Texture Generation Mode For S To Sphere Mapping
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); // Set The Texture Generation Mode For T To Sphere Mapping
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256,256, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
return TRUE; // Return TRUE (Initialization Successful)
}
void CTestDlg::Draw() // Draw Our Scene
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
int i,j;
LoadBmpFile("C:\\test.bmp",i,j);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,i, j, GL_RGB, GL_UNSIGNED_BYTE, data);
if (TRUE) // Is Background Visible?
{
glLoadIdentity(); // Reset The Modelview Matrix
glBegin(GL_QUADS); // Begin Drawing The Background (One Quad)
// Front Face
glTexCoord2f(1.0f, 1.0f);
glVertex3f( 11.0f, 8.3f, -20.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-11.0f, 8.3f, -20.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-11.0f, -8.3f, -20.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f( 11.0f, -8.3f, -20.0f);
glEnd(); // Done Drawing The Background
}
glFlush (); // Flush The GL Rendering Pipeline
}
|
|
|
|
|
Please, in the future read the posting guidelines before posting (for instance, use the pre tags to format your code properly so that it is readable).
Now to your question: OpenGL only handle images which have a power of 2 as dimensions. Loading images with non-standard dimensions will work on certain graphic cards but not all of them. So, the solution to your problem is to simply create your image as a 1024x1024 image (for instance, additional space is filled with white) and then when the image is used (using glTexCoord2) you only take the part where your image really is (for instance if your image is 768 pixels wide, you have to specify 768/1024=0.75 in your glTexCoord function).
|
|
|
|
|
int iwidth=512;
int iHeight=512;
OK,Now i am create image 512*512 and give in glTexImage2D
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, iwidth,iHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, data);
In Draw Function
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0,768, 576, GL_RGB, GL_UNSIGNED_BYTE, data);
float fval=(float)(768.0f/512.0f);
if (TRUE)
{
glBegin(GL_QUADS);
glTexCoord2f(fval, fval);
glVertex3f( 11.0f, 8.3f, -20.0f);
glTexCoord2f(0.0f, fval);
glVertex3f(-11.0f, 8.3f, -20.0f);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(-11.0f, -8.3f, -20.0f);
glTexCoord2f(fval, 0.0f);
glVertex3f( 11.0f, -8.3f, -20.0f);
glEnd();
}
I can not able to load image like above coding.
By the way,My view size if fix 512*512 and i want to support zoom also.
|
|
|
|
|
That doesn't make any sense: tell me how you put an 768x768 image in an 512x512 image
How large is your image finally ? Because your fval (768/512) is bigger than 1 (and so, it is invalid for the glTexCoord function).
|
|
|
|
|
I know that some network car has this function. But how to call network interface?
|
|
|
|
|
be more specific on your question.
|
|
|
|
|
For example, if today is 2012 Jan 1st, the computer boots and then enter the windows system by itself. But I doknow how to call the bios to set it.
|
|
|
|
|
|
|
I am currently taking data from a database that is in the form of char data and attempting to convert to a string and then saving in a char array. It appears that these strings have to be saved in a two dimension array. The first array or inner array containing each element of the date in the form of chars. The outer array then contains each record or occurance of the date. Can someone help me in copying the string data into the array? Listed below is what I have so far.
char Date1[10] = {};
vFieldDate = rec->Fields->GetItem("Date")->Value;
for(int r = 0; r < 1; r++)
{
for(int c = 0; c < 10; c++)
{
strcpy (Date1,vFieldDate);
strcpy (Date[r][c],Date1[10]);
printf ("%s",Date[r][c]);
}
}
|
|
|
|
|
Mike Certini wrote: strcpy (Date[r][c],Date1[10]);
strcpy (Date[r][c],Date1); is correct.
Hope you have declared char Date[MAX][10] (where MAX will be greater than or equal to l) , or dynamically allocated memory for it.
|
|
|
|
|
Through research the following was derived from an MSDN website:
#define ARR 65500 //Total Records
#define TARGSIZE 11 //Field Length
char Date[ARR][TARGSIZE] = {};
orig = rec->Fields->GetItem("Time")->Value;
const size_t newsize = 100;
char nstring[newsize];
strcpy_s(nstring, (char *)orig);
strncpy(Date[cyc],nstring,TARGSIZE - 1);
printf("%s",nstring);
printf("\n");
Original MSDN website:
http://msdn.microsoft.com/en-us/library/ms235631(v=vs.80).aspx[^]
|
|
|
|
|
Why not:
strncpy(Date[cyc], (char *)orig, TARGSIZE - 1);
strncpy(Date[cyc], (char *)rec->Fields->GetItem("Time")->Value, TARGSIZE - 1);
I must get a clever new signature for 2011.
|
|
|
|
|
Gentlemen,
I hope everyone is having a good day.
I have an problem with my .dll that is linked to Excel.
I have 2 functions in the file, they are named in the def file and they work fine.
I added a third this morning, added name to def file.
I declared it in VBE.
For some reason, when I try to type it into a cell and give it a variable, i.e. cell formula is =Hs_P(B8),
immediately Excel has an error and shuts down. I am very perplexed.
Any ideas? Have I given enough information?
This is the error Excel is throwing out "Excel asertion error"
And the line from the code _ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse));
I haven't found the problem, but I believe it is the way I am calling one function from inside of another function.
|
|
|
|
|
Assuming you are talking about some C++ code then you may need to use your debugger to find exactly where it is failing. From the information provided above you have an invalid pointer somewhere.
I must get a clever new signature for 2011.
|
|
|
|
|
This function seems to be causing the assertion failure, but I cannot se why, it compiles without error.
I think I found the error, it appears I cannot delete the arrays before I return x, does anyone know this to be true?
delete [] J0;
delete [] n0;
delete [] Ir;
delete [] Jr;
delete [] nr;
return(x);
}
modified on Thursday, January 27, 2011 5:35 PM
|
|
|
|
|
You can't create any memory errors or access violations without destabilizing Excel.
|
|
|
|
|
Having looked at the code in your original message I see the problem. You are instantiating your arrays on the stack by statements such as:
double J0[10] = {0, 1, -5, -4, -3, -2, -1, 2, 3};
and then trying to dispose of them by delete . This is the cause of your problem, you cannot delete a variable that was not created with new . Stack variables will be disposed of automatically when the function returns.
I must get a clever new signature for 2011.
|
|
|
|
|
Hi all,
I have a CFormView, and a child CListCtrl control. I can handle
accelerator events, like Ctrl+C, Ctrl+V ... in CFormView without
problem, by defining below message handler:
ON_COMMAND(ID_EDIT_COPY, &CMyFormView::OnEditCopy)
Now I want my CListCtrl handle these commands differently. I want to
implement OnEditCopy in CListCtrl class, rather than implement logic
in the view class. How can I pass the accelerator events from CView to
child control, when CListCtrl is on focus? I tried like:
ON_CONTROL_REFLECT(ID_EDIT_COPY, &ThisClass::OnEditCopy)
But it does not work.
|
|
|
|
|
Have a look here[^], I'm not sure if it's posted by you as well (exact same wording of the question), but it appears to have been answered to the poster's satisfaction.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
how we write the c-program of sorting the set of point. w.r.t. convex polygon
|
|
|
|
|
how we write the c-program of sorting the set of point. w.r.t. convex polygon
|
|
|
|
|
Uh, what ?
Could you please explain your problem in more details so that we can understand what you are looking for ?
What is your problem exactly ? What did you try yet ? Where are you stuck precisely ? ...
|
|
|
|
|
Why don't you try to explain better your requirements instead of reposting (and cross-posting) your question?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Do you have the skills necessary to write a C program? If the answer is yes then you can use the simple or STL sort[^].
I must get a clever new signature for 2011.
|
|
|
|
|