|
jeron1 wrote: because there are 4294967295 entries in each dimension
Yes but he's writing his program in the fourth dimension!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Because in the fourth dimension no one can hear your allocation fail?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
What does my question has to deal with facebook and drinking behaviour?
|
|
|
|
|
Member 14812342 wrote: What does my question has to deal with facebook and drinking behaviour?
Nothing.
It was not an answer, just a signature!
|
|
|
|
|
So what is it that has to be done. I want to create Differential Distribution Table (DDT) of Blowfish algorithm. I have done for DES.
|
|
|
|
|
for Differential Distribution Table of Blowfish algorithm
|
|
|
|
|
Well you cannot create it in memory like that. You need to rethink what you are trying to do and understand the hardware and software limitations of the system you are working on.
|
|
|
|
|
How does one invoke the File Explorer Properties dialog box in Windows 10 for a specific file from a C++ application?
EDIT:
You must use ShellExecute with a verb of "properties".
The difficult we do right away...
...the impossible takes slightly longer.
modified 24-Apr-20 10:52am.
|
|
|
|
|
Please read carefully.
I am not looking for RTFM replies.
I am getting nowhere in OpenGL forum.
I do understand this is NOT OpenGL forum.
I am NOT looking for fancy shading graphics,
I am not looking for how to retrieve object outline either.
I am looking for as detailed as possible practical flow in using OpenGL stencil.
I have bits and pieces and it is all just "try this ... try that..."
I am looking for help, not for pointless criticism of my coding style.
If you cannot help me , please dot not reply.
glPushAttrib( GL_ALL_ATTRIB_BITS);
// must clear all for resizing
// TOK resizing works !
glClear(
GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glClearStencil(0); // why and what ???
glEnable( GL_STENCIL_TEST); // TOK
// glStencilMask is set to 1 as default (??)
//glStencilMask(0x00); // no effect
//glStencilMask(0xFF); // no effect
{
// process object block is this correct place ??
OpenGL_Render_RealAxis(); // int parameter = 0)
OpenGL_Render_Plus_IMG_Axis(); //int parameter = 0)
OpenGL_Render_Minus_IMG_Axis(5); //passed temporary last circle as parameter 5 }
// TOK turn off writing to color buffer - do no show object to be stenciled
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
// Set the stencil buffer to write a 1 in every time
// a pixel is written to the screen
glStencilFunc( GL_ALWAYS, 1, 0xFFFF);
glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE);
{
// process block dupe
OpenGL_Render_RealAxis(); // int parameter = 0)
OpenGL_Render_Plus_IMG_Axis(); //int parameter = 0)
OpenGL_Render_Minus_IMG_Axis(5); //passed temporary last circle as parameter = 0)
}
parameter_stencil = 42; // verify stencil function
parameter_stencil = Stencil(parameter_stencil);
if (parameter_stencil == 0) {
printf(
"\nTOK HERE Stencil full circle parameter %i @function %s @line %i",
parameter_stencil, __FUNCTION__, __LINE__);
glStencilFunc(GL_EQUAL, 1, 1);
} // show / keep inside circle
else {
printf(
"\nStencil last circle parameter %i @function %s @line %i",
parameter_stencil, __FUNCTION__, __LINE__);
glStencilFunc(GL_NOTEQUAL, 1, 1);
} // keep all outside of stencil
// now showing all - stencil plus object ??
glFlush();
glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE);
glutSwapBuffers(); // no change !
|
|
|
|
|
Well you failed the first part of the flow you need to enable the stencil buffer before you clear it
glEnable(GL_STENCIL_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
From there the steps are
- Enable writing to the stencil buffer.
- Render objects, updating the stencil buffer.
- Disable writing to the stencil buffer.
- Render other objects
- display whole result
In vino veritas
|
|
|
|
|
I am sorry, but ALL buffers - display modes (?) are enabled in main OpenGl "event loop".
I though that glEnable(GL_STENCIL_TEST); // ENABLE the stencil buffer
is specifically to enable writing to the stencil buffer.
Am I wrong ?
window = glutCreateWindow("OpenGL - Base ");
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL);
I think I need to review all in old-fashioned "IBM flow chart" style - from top to bottom - from "vertex" to pixel on screen.
This OpenGL "pipe architecture" - from left to right - is just not working when it comes to stencilling.
What is confusing is mixing of hardwareand software.
"stencil works on pixel(s) "
Fore example
"stencil mask "defaults" to 1"
then I see stuff like this glStencilMask(0xFFFF);
I may also have modlelview stack messed-up.
|
|
|
|
|
Here is my latest code.
I'll try to delete my debugging stuff. Hope I 'll not delete something important.
The code basically works, it does apply the stencil - to show only data INSIDE the stencil circle.
BUT
ONLY when I enable viewing of the stencil AND data being written to the color buffer.
I have highlighted the code. I was under the impression this is ONLY for viewing the stencil, but apparently not.
Obviously I do not have to re-able the color buffer , hence I get BOTH - stencil and the stencilled "fragment".
I have no idea how to proceed and where is my error.
glClear(
GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glDisable( GL_STENCIL_TEST);
glEnable(GL_STENCIL_TEST);
glClearStencil(0x0);
glClear(
GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glStencilMask(GL_TRUE); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glStencilFunc(GL_ALWAYS, 1, 1);
parameter_stencil = 42;
parameter_stencil = Stencil(parameter_stencil); glFlush();
if (parameter_stencil == 0) {
printf(
"\nStencil full circle parameter %i @function %s @line %i",
parameter_stencil, __FUNCTION__, __LINE__);
glStencilFunc(GL_EQUAL, 1, 1);
} else {
printf(
"\nStencil last circle parameter %i @function %s @line %i",
parameter_stencil, __FUNCTION__, __LINE__);
glStencilFunc(GL_NOTEQUAL, 1, 1);
}
{
OpenGL_Render_Plus_IMG_Axis(); }
from here I am not sure how to display only the rendered fragment
I get both stencil and fragment ONLY when writing to color buffer is enabled
glStencilMask(GL_FALSE);
glClear(
GL_STENCIL_BUFFER_BIT );
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClear(
GL_STENCIL_BUFFER_BIT );
glFlush();
|
|
|
|
|
maybe professionals here at codeproject have a hint for me.
Please see following example:
#include <iostream>
using namespace std;
int c, d;
#define Circumference c
#define Diameter d
int main ()
{
cout << "Please enter diameter: ";
cin >> Diameter;
Circumference = 3.14 * Diameter;
cout << " Circumference is " << Circumference << endl;
return 0;
}
My IDE (Understand) report possibilities always break down the #define to it's origin. So all reports state that function main() uses variables 'c' and 'd'.
But what I like to have is the real used expression in the function source code. So report shoud show that main() uses 'Circumference' and 'Diameter' and not 'c' and 'd'.
Is there any tool out there (for Windows 10 OS) which is able to do this ?
Many thanks for any hint!
'There are 10 types of people in this world, those who understand binary and those who dont.'
|
|
|
|
|
I am not sure I understand what the problem is. I have just built and run your code successfully. But why are you doing it that way, what is wrong with: the following?
#include <iostream>
using namespace std;
int main ()
{
float Circumference;
float Diameter;
cout << "Please enter diameter: ";
cin >> Diameter;
Circumference = 3.14f * Diameter;
cout << " Circumference is " << Circumference << endl;
return 0;
}
|
|
|
|
|
In C/C++ lines that start with # are preprocessor directives. What you need to understand about the preprocessor is what it basically does is text replacement. So what happens is that your C/C++ program text, lets call it program.cpp, gets passed through the preprocessor, and the output of that gets passed to the compiler proper.
So lets say you have
#define Circumference c
#define Foo 10
cout << Circumference << " " << Foo << end;
When it gets to the compiler, it sees this:
cout << c << " " << 10
So the compiler proper never sees the #define statements.
The fine print:
The standards for C and C++ don't specify how the preprocessor is implemented, just how it should behave. Most compilers have chosen to implement the preprocessor as a separate executable, but it certainly doesn't have to be that way.
Keep Calm and Carry On
|
|
|
|
|
Why don't you do this instead:
int main( void )
{
float Diameter;
float Circumference;
cout << "Please enter diameter: ";
cin >> Diameter;
Circumference = 3.14 * Diameter;
cout << " Circumference is " << Circumference << endl;
return 0;
} Then it is more standard, and you also get what you want.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
Great minds think alike!
Sorry about that. I went from the OP to Reply, with no stops in between.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Done it myself occasionally.
|
|
|
|
|
I've found in a C function, from a Linux library a function: get_osfhandle:
handle = get_osfhandle(fd);
And it is declared up in the C file like this:
HANDLE get_osfhandle(int);
but I got a link error:
error LNK2019: unresolved external symbol "void * __cdecl get_osfhandle(int)" (?get_osfhandle@@YAPAXH@Z) referenced in function ...
I commented that line, HANDLE get_osfhandle(int); , and without this declaration, I got the error from post subject. Of course, I have included io.h header, like msdn said: _get_osfhandle | Microsoft Docs[^]
But I got the same errors. I have tried to include <windows.h>, seem to be useless ... how to overcome this error ?
|
|
|
|
|
Microsoft have helpfully changed the name, it is now _get_osfhandle (with a leading underscore), as defined in io.h.
|
|
|
|
|
|
Yes, I was well aware of that. I have been using WSL for some time, but maybe I should upgrade to WSL2. Thanks for the link.
|
|
|
|
|
Since today is my day to ask stupid questions, here is another one.
I have some understanding how to pass a function as a parameter.
I can even add and use ONE parameter to such function.
I do not understand the
- syntax. how to add more parameters.
What I am also missing is syntax on how to read / access , verify passed parameters.
I need to make a decision based on the parameter.
void OpenGL_Stencil(void (*f)(int parameter));
void OpenGL_Stencil(void (*Stencil)(int parameter)) {
Stencil(0);
PS Take your time , my interned connection is like a yo-yo today.
modified 20-Apr-20 9:24am.
|
|
|
|
|
To add more parameters, just extend the argument list: (int parameter1, int parameter2) and so on.
All you have at this point is a declaration and definition of the function OpenGL_Stencil . Its parameter is a function that returns void and takes one int parameter. The next step is to implement a function with that signature and pass it as an argument to OpenGL_Stencil .
void Something(int value) { }
After which invoking OpenGL_Stencil(Something) should cause OpenGL_Stencil to invoke Something .
|
|
|
|