Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

MarkS

Member Since 09 Jan 2001
Offline Last Active Today, 04:25 PM

#4988541 Reading wrong values from Joystick for the first few milliseconds

Posted by MarkS on 09 October 2012 - 06:16 PM

Is it a potentiometer-based joystick or switch-based? Is sounds like it is switch-based and there is no hardware debounce built into the circuit. Essentially, when a mechanical switch is pressed, it does not go from open to fully closed. The contacts bounce between open and closed for a few milliseconds. Depending on the intended use, this may or may not be an issue, but it always is an issue if the switch is connected to a microprocessor as the processor operates faster than the bouncing, resulting in jitter on the input until the bounce stops. Sleep is the best way to do software debounce if this is the case. All you can do is wait it out. Then send it back to have a hardware debounce circuit added.

I could be wrong, but that is the first thing to jump out at me.


#4984753 [For a Beginner] C++ express 2010 or C++ express 2012?

Posted by MarkS on 28 September 2012 - 09:59 AM

Back to the question at hand...

I tried VS Express 2012, but it required .NET 4.5, which is required for Windows 8 and apparently incompatible with Windows 7. I had to remove all copies of .NET and anything related to Visual Studio in order to reinstall 2010 and get it working. The impression I got was Microsoft forcing the transition to Windows 8. Yes, 2012 will install in Windows 7, but don't expect to actually compile anything.

JME


#4924457 Why the efficiency a simple 2D program is so low?

Posted by MarkS on 22 March 2012 - 04:47 PM

For 3 verts in a single triangle, doing things on the CPU should be effectively "free" - or at the very least have overhead so low that it's not even measurable.  For sure you should move them to the GPU (put them in your vertex shader) but in this case they're not going to be the cause of the symptoms you describe.


I agree. Since he is learning I felt it was best to steer him away from this practice. It may be free now, but it wont be with a much higher vertex model.

I didn't look at the book he linked to, but if that code is straight from that book, it should raise flags.


#4924266 Why the efficiency a simple 2D program is so low?

Posted by MarkS on 22 March 2012 - 05:09 AM

You are doing all of your calculations on the CPU (slow), using std::vector (also somewhat slow) for a static array (unnecessary) and then moving your vertex data across your system bus (from the CPU to the GPU) each frame (very slow).

If your array isn't dynamic, skip std::vector and use a standard array. Send you vertex data to the GPU once and then either transform it in the vertex shader or use glRotate each frame.


#4913063 Posssible memory leak in OpenGL Intel Win7 drivers

Posted by MarkS on 14 February 2012 - 12:29 PM

But we didn't allocate any memory here. What I understand is that after the call to glMapBuffer(), mappedBuf should be treated as GPU memory, so it's not up to us to free it. We copy the texture into this mapped memory, then call glUnmapBuffer() to indicate to OpenGL that we're done copying/modifying that buffer (the buffer that belongs to the driver, not us).


Any pointer in your code resides in CPU memory. The data contained within may come from GPU memory, but the pointer still needs to be declared in your code.

This function doesn't make any sense:

void mapAndCopyToBuffer(char* img1)
{
	glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pixelbufferHandle);
	mappedBuf = (char*) glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
	memcpy(mappedBuf, img1, w * h * s);
	glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
	mappedBuf = NULL;

	glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixelbufferHandle);

	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0);
}


The memcpy is copying img1 into mappedBuf and then you are setting mappedBuf to NULL. I suspect that you meant: memcpy(img1,mappedBuf,w * h * s);?

Also, since you know that img1 and mappedBuf will be w * h * s bytes, and that mappedBuf is only used in this function, why not do this:

void mapAndCopyToBuffer(char* img1)
{
    char *mappedBuf;

	glBindBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, pixelbufferHandle);
    mappedBuf = new char[w * h * s];
	mappedBuf = (char*) glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
	memcpy(img1, mappedBuf, w * h * s);
	glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
    delete [] mappedBuf;
	mappedBuf = NULL;

	glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixelbufferHandle);

	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 0);
}



#4911517 Hiring OpenGL teacher [PAYING 10$]

Posted by MarkS on 09 February 2012 - 08:45 PM

I have one book on OpenGL programming, the Red Book. It covers GL 1.1 and has been outdated as long as I have had it. I learned 99.9% of what I know, which I fully admit is limited, by using Google, OpenGL.org's forum and this forum. I ask questions. A LOT of questions. That being said, I would be embarrassed to offer someone $10 an hour for training in this subject, much less $10 total. Even with my limited subset of OpenGL knowledge, if I were to train you with what I know for money, I wouldn't charge less than $50 a session and it would take several one on one sessions.

I recommend that you use the internet to its fullest. Do research on your own (that includes asking questions here). Save your money for other things.


#4906181 Line drawing? (C#)

Posted by MarkS on 25 January 2012 - 01:18 PM

This is what I've used in the past for my tile level editors. Just modify it with your own map variables.

This is based in a modified version of Bresenham's classic line drawing code.



#define ABS(x) (x < 0 ? -x : x)

#define SIGN(x) ((x) < 0 ? -1 : ((x) > 0 ? 1 : 0))



void LineTool(TileMap *map,POINT p1,POINT p2,long tile_ID)

{

long y,x;

long dy,dx;

long sx,sy;

POINT start,end;

long accum;



start.x = p1.x;

start.y = p1.y;

end.x = p2.x;

end.y = p2.y;



dx = end.x - start.x;

dy = end.y - start.y;



sx = SIGN(dx);

sy = SIGN(dy);



dx = ABS(dx);

dy = ABS(dy);



end.x += sx;

end.y += sy;



if(dx > dy)

{

accum = dx >> 1;

do{

map->map[start.y][start.x] = tile_ID;



accum -= dy;

if(accum < 0)

{

accum += dx;

start.y += sy;

}

start.x += sx;

}while(start.x != end.x);

}else{

accum = dy >> 1;

do{

map->map[start.y][start.x] = tile_ID;



accum -= dx;

if(accum < 0)

{

accum += dy;

start.x += sx;

}

start.y += sy;

}while(start.y != end.y);

}

}




#4904477 The Sunset Strider

Posted by MarkS on 19 January 2012 - 11:48 PM

I was thinking "Oh great. Another Minecraft clone...", but the video spoke volumes! That is an amazing take on a platformer.


#4897647 GameDev.net 2012

Posted by MarkS on 28 December 2011 - 05:19 PM

My only complaint is the stark white background. It is quite jarring. The bluish gray background was much more pleasing to the eye.


#4880522 PDB files in OpenGL, Ignore or not?

Posted by MarkS on 04 November 2011 - 11:05 AM

Great post! I have been wondering about this myself. Truthfully, I didn't even know what a PDB file was until I read your link (thanks, BTW).What I find interesting is that all of the PDB not found warnings that I get are for DLLs supplied with either Windows or Visual Studio. Most, if not all, are in the Windows directory. After reading that link, it makes me wonder how useful this process is if you are guaranteed to get warnings simply because Microsoft failed to include the necessary PDBs with Visual Studio. I just have to assume that these are warnings we can safely ignore.

Here is the debug output from a project I am currently working on:


'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\opengl32.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\glu32.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\ddraw.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\dciman32.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Users\Kids\Documents\Visual Studio 2010\Projects\3D Maze\3D Maze\glew32.dll', Binary was not built with debug information.
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Program Files (x86)\Common Files\microsoft shared\ink\tiptsf.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file
'3D Maze.exe': Loaded 'C:\Windows\SysWOW64\nvoglv32.dll', Cannot find or open the PDB file

With the exception of 'glew32.dll", all of the listed DLLs came with Windows or Visual Studio.


#4786126 Survey: What do you think about the Bible?

Posted by MarkS on 15 March 2011 - 12:33 PM

kentl, are you trying to come across as you do? Can you please post in a somewhat sane manor and use correct grammar? Do you really need a random number of blank lines between each sentence? I've seen posting like yours before and it is typically on sites spouting flat earth theory and aliens are here to invade and other such nonsense. You do not come across as credible.

You've used the old argument of redefining what a day is. Let's assume for a minute that creation story is true, and that god told someone about the origin of the universe. He's god, so he knows everything which means by definition, he knows what the human concept of a "day" is. So why mislead?


AndyGeers answered this best. The Bible is full of translation errors such as this. There (as in English) were words that meant vastly different things, depending on various factors. The story of Noah (another topic in and of itself!) is one glaring example of this since the ancient Hebrew word for "country", "land", and "world" are one in the same.


Again, you can argue the "prime mover" view of god, i.e. Einsteins God of physical laws who set up the initial parameters for the universe (the physical constants) and let the whole thing unfold, but that is redefining the term creationist as most people understand it.


Yes! That is redefining "creationist"! That is exactly what I am trying to do! As "Creationism" is currently defined, it is pure bunk. It doesn't have to be that way though and it is currently that way because of absurd teachings for millennia.

You must understand that the teachings that sprouted up concerning this subject happened at a time when there was no understanding of the earth, solar system or universe. All they had to go on was a text that was full of holes. It persisted for so long because when we finally did start to have a more in depth understanding of the universe, this new understanding countered the teaching and those that dared to do so were branded heretics (often at great personal cost). As such, even today, most people argue the teaching at expense of the text. Many of them were raised in Christian (or at least creationist) homes and have their minds full of this. That is why I posted earlier that people should clear their minds of the teaching and read.

I wasn't even aware that Einstein thought of this, BTW.


#4785694 Survey: What do you think about the Bible?

Posted by MarkS on 14 March 2011 - 12:24 PM

..snip..


Two things that I find interesting about Genesis more than anything else.

1.) When a planetary system is formed, the planets (and the planetary system as a whole) are formless and empty until they gather enough dust and debris and cool. Per scientific theory.
2.) For years, scientists have bristled at the thought that there was light before the formation of the sun. Just not possible. Can't happen. Ludicrous! Until a couple of years ago when scientists speculated that shortly after the universe was "created", it was flooded with light. As though someone flipped on a light switch. What was darkness was filled with light. Interesting.

Now, let's look at the verse where God defines day. He called the light day and the darkness night. No where in the Bible is a 24 hour day mentioned. That is a human construct. Nor is it mentioned that day has any relevance to the rotation of the earth or brightness of the sun. If the universe was dark for 300,000 earth years (I believe that is the time frame I read) before it was flooded with light and then the light took a million or so earth years to dim into background radiation, it stands to reason that this period is the length of "day" as described in Genesis. Still too short of a time period per scientific theory, but far longer than 6 24-hour days.

My point is that we do not know everything and our understanding of the universe grows daily. To summarily dismiss a line of thought because it goes against our current understanding doesn't make that line of thought wrong. What makes creationism so hard for scientists to stomach isn't so much what was written, but the fact that those that believe what was written so often flat out resist any thought that it isn't complete. If creationists are so (nearly violently) opposed to any form of scientific thought and theory, then there is no point trying to reconcile the two. I have as much disdain for close minded creationists as I do for closed minded evolutionists.


#4785401 Survey: What do you think about the Bible?

Posted by MarkS on 13 March 2011 - 05:49 PM

Hence, bollocks.



Go back to my original posts in this thread. Only a fanatic wouldn't accept that the creation story is not complete. It wasn't meant to be. I've explained why several pages ago.

Indeed.



So, I take it you are happy being closed minded? I am a creationist and I am open to so much more. I realize that the creation story is not complete and am willing to accept scientific thought and theory to fill those holes. You are not even willing to entertain the thought? What purpose do you have in this thread?


#4766874 A request for beginners posting in this forum...

Posted by MarkS on 29 January 2011 - 08:15 PM

I know that sometimes you feel like the question is "beneath" those of us that have been programming for years. I know how it feels to ask a question that you have been struggling with for hours or days, only to have the answer turn out to be embarrassingly simple. It happens to all of us. I have been programming since I was 8 years old (I turn 34 in March). This is a hobby for me, but I do feel like I know about what the average computer programming graduate knows fresh out of college. Still, there are times where I have to ask the embarrassingly simple questions.

My point is that this is expected and OK. Even those of us that are "experienced" sometimes ask "silly" questions. We promise not to laugh!

Please, if you ask a question here, regardless of how you feel with the answer, respond to the thread. Don't leave us hanging. We answer, not to make fun, but to help. If you get embarrassed and let the thread "die", we have no way of knowing if our answer was helpful or what you needed. If someone *DOES* reply in a belittling fashion, report them to a mod, but please, reply.


#4765413 Math operation can't be used in Case statement.

Posted by MarkS on 26 January 2011 - 08:44 PM

You had several issues.

1.) You put a semicolon after the switch statement.
2.) You forgot the << between the "=" and the (num1 .. num2).
3.) You forgot the semicolon after the while statement.

Works fine now...

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
        double num1;
        double num2;
        char operation;
        char again;
        
        do
        {
        cout << "Enter math expression:\n";
        cin >> num1 >> operation >> num2;
        
        switch (operation)
        {
        case '+':
                cout << "=" << (num1 + num2) << endl;
                break;
        case '-':
                cout << "=" << (num1 - num2) << endl;
                break;
        case '*':
                cout << "=" << (num1 * num2) << endl;
                break;
        case '/':
                cout << "=" << (num1 / num2) << endl;
                break;
        }   	
        cout << "Do you want to try again <y or n>\n";
        cin >> again;
        }while (again == 'y' || again == 'Y');
        
        system("pause");
        return 0;
        
}





PARTNERS