|
<br />
#include "stdafx.h"<br />
#include "OpenGl.h"<br />
#include "creatfoufou.h"<br />
#include "foufou.h"<br />
<br />
#include <math.h><br />
<br />
#ifdef _DEBUG<br />
#undef THIS_FILE<br />
static char THIS_FILE[]=__FILE__;<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
creatfoufou::creatfoufou()<br />
{<br />
<br />
}<br />
<br />
creatfoufou::~creatfoufou()<br />
{<br />
<br />
}<br />
<br />
void creatfoufou::creatfou(int amount)<br />
{<br />
foufou *newfoufouPtr;<br />
int randomX,randomY,randomZ;<br />
int speed,steer;<br />
<br />
for(int index=0;index<amount;index++)<br />
{<br />
newfoufouPtr = new foufou();<br />
fou_caracter.push_back( newfoufouPtr );<br />
randomX = ( ( 1 + rand( ) % 900 ) - 450 );<br />
randomY = ( ( 1 + rand( ) % 100 ) - 50 );<br />
randomZ = ( ( 1 + rand( ) % 900 ) - 450 );<br />
<br />
setposition(randomX,randomY,randomZ);<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
void creatfoufou::setposition(int newX, int newY, int newZ)<br />
{<br />
-->the mistak RePaint(randomX,randomY,randomZ);<br />
}<br />
and here when i declared
<br />
#include "stdafx.h"<br />
#include "OpenGl.h"<br />
#include "foufou.h"<br />
#include <gl/glut.h><br />
<br />
#ifdef _DEBUG<br />
#undef THIS_FILE<br />
static char THIS_FILE[]=__FILE__;<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
foufou::foufou()<br />
{<br />
<br />
}<br />
<br />
foufou::~foufou()<br />
{<br />
<br />
}<br />
<br />
<br />
<br />
GLfloat Material_Ambiante[]={0.5,0.5, 0.5, 1 };<br />
GLfloat Material_Difuse[]={0.5, 0.5, 0.5, 1};<br />
GLfloat Material_Specular[]={0.5, 0.5, 0.5, 1};<br />
<br />
<br />
<br />
<br />
GLfloat Light_Ambiante[]={0.2, 0.2, 0.2, 0.1};<br />
GLfloat Light_Difuse[]={0.5, 0.5, 0.5, 1.0 };<br />
GLfloat Light_Specular[]={1.0, 1.0, 1.1, 1.0 };<br />
GLfloat Light_Position[]={10, 12, 10, 1.0 };<br />
<br />
<br />
<br />
GLfloat Light_Direction[]={0.0,-1.0, 0.0, 1.0};<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
void foufou::Initial()<br />
{<br />
<br />
glMaterialfv( GL_FRONT, GL_AMBIENT, Material_Ambiante);<br />
glMaterialfv( GL_FRONT, GL_DIFFUSE, Material_Difuse);<br />
glMaterialfv( GL_FRONT, GL_SPECULAR,Material_Specular);<br />
glMaterialf( GL_FRONT, GL_SHININESS, 20);<br />
<br />
glLightfv( GL_LIGHT0, GL_AMBIENT,Light_Ambiante );<br />
glLightfv( GL_LIGHT0, GL_DIFFUSE, Light_Difuse );<br />
glLightfv( GL_LIGHT0, GL_SPECULAR, Light_Specular);<br />
glLightfv( GL_LIGHT0, GL_POSITION, Light_Position );<br />
<br />
<br />
<br />
<br />
glEnable( GL_LIGHTING );<br />
<br />
<br />
glEnable( GL_LIGHT0 );<br />
<br />
<br />
<br />
glEnable( GL_DEPTH_TEST );<br />
<br />
};<br />
<br />
void foufou::RePaint(int xpos,int ypos,int zpos)<br />
{<br />
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);<br />
<br />
<br />
glMatrixMode (GL_PROJECTION);<br />
glLoadIdentity ();<br />
<br />
<br />
<br />
gluPerspective (90, 1, 5, 50);<br />
gluLookAt (2,2, -15, -4,0.0, 1, 0.0, 1.0, 0.0 );<br />
<br />
<br />
glPushMatrix();<br />
<br />
<br />
<br />
glColorMaterial( GL_FRONT, GL_AMBIENT );<br />
glColor4f(0.5, 0.5, 0.6, 1.0 );<br />
glColorMaterial( GL_FRONT, GL_DIFFUSE );<br />
glColor4f( 0.5, 0.2, 0.8, 1.0 );<br />
glColorMaterial( GL_FRONT, GL_SPECULAR );<br />
glColor4f( 0.9, 0.8, 1.0, 1.0 );<br />
<br />
<br />
<br />
glTranslated(-xpos, ypos, zpos );<br />
glutSolidSphere(0.9,30,40);<br />
glDisable( GL_LIGHTING );<br />
<br />
glPopMatrix();<br />
<br />
<br />
<br />
<br />
<br />
SwapBuffers(wglGetCurrentDC());<br />
<br />
};<br />
|
|
|
|
|
Did this have anything to do with my thread? If so I can't see how.
-Jack
There are 10 types of people in this world, those that understand binary and those who don't.
|
|
|
|
|
Is there anyway to have a class defined within a namespace, and still use a forward declaration? Take the following example:
class myclass;
static void function(myclass *p);
namespace abc
{
class myclass
{
public:
int i;
};
};
using abc::myclass;
Compiling this with VC++ 6.0, I get error "C2874: using-declaration causes a multiple declaration of 'myclass'". Is there anyway around this? Does using namespaces mean you can no longer use forward declarations?
Thanks for your help.
|
|
|
|
|
You have to declare it like this
namespace abc
{
class myclass;
}
|
|
|
|
|
I have this dialog based project with a huge set of menus that I need to duplicate in my SDI. Can I just import them? If so how?????
|
|
|
|
|
with the SDI project open, open the dialog project's .RC file. Copy the menu ID's and paste them into your SDI project's resource window. Simple copy and paste.
|
|
|
|
|
Much obliged pardner!
|
|
|
|
|
I have an application that is sending data through a serial port. That is working fine, but I am now to the point where I need to read from the serial port. I same across a CSerial Class developed by P J Naughter and it works quite well. I have played around with the Read() function and it works as long as you call it when you know something has already hit the port.
The application I am using this in is just a very simple dialog application. How do I setup an event handler that can interupt my program when a byte has hit the serial port? I have looked at some various resources without success. Does anyone have an idea that could help?
Thanks
Kevin Shaffer
Student of Computer Science
University of Kansas
kshaff03@msn.com
|
|
|
|
|
One solution is to implement a non-blocking I/O model to communicate with the port. Microsoft published one solution using OVERLAPPED I/O.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp
Kuphryn
|
|
|
|
|
I've already spent alot of time in this article, but it doesnt help me (or at least I don't understand it well enough to help me). My application is running on a pc, and it needs to recieve instructions from a Palm, fetch data from the pc, and send it back to the Palm.
In order to do this, my application needs to be sitting here, and realize, oh! something has just hit the serial port. The program reads the data and processes it, then waits for the next com port "Event". I would prefer not to create my own loop and continue to poll the serial port, because then my application cannot handle other events that might occur.
That artice mentions an event called EV_RXCHAR is issued when a byte hits the serial port. I went through the message handling tutorials and tried to set up an event handler using ON_MESSAGE with no success. Im still trying all sorts of things, any more input would be appreciated.
thanks!
Kevin Shaffer
Student of Computer Science
University of Kansas
kshaff03@msn.com
|
|
|
|
|
I have worked on a similar project 3 years ago and one of my team members handled the incoming data so I really don't remember much about the topic. If I remember correctly you have to have a thread which checks the serial port for a "Receive Character Event" and a while statement calling WaitCommEvent. I don't remember much but I hope that helps you.
// Afterall I realized that even my comment lines have bugs
|
|
|
|
|
Do as the sample \Microsoft Visual Studio\MSDN98\SAMPLES\VC98\SDK\WINBASE\IO\SERIAL do,all things are OKAY
QQ
|
|
|
|
|
Hello!
I have exactly the same Problem!
I just created a small function that results the current fill-status of the serial buffer. I used the implemented GetModemStatus function of CSerial from P.J.Naughter.
e.g.:
if (SomethingInIt()==TRUE)
buffer = Port.Read(..);
So this is nonblocking.
I hope I help you out!
Greetings from germany, Jan
|
|
|
|
|
I have a program that uses a Progress bar , but when i try to minimise the dialog window during execution or activate some other program ,
and then return back to the dialog seems to get freezed
, progress bar status does not increment ,
HOWEVER the program run correctly in the background and after its execution completes the dialog freeze end and it is displayed currectly .
Any suggestions ??
|
|
|
|
|
It sounds like the classic "preemption" problem. Your application is blocking while doing its processing, thus not allowing the dialog's message pump to process messages. Read Joe Newcomer's article on thread management[^].
|
|
|
|
|
hi yashraj,
Execute the background process in a seperate thread(Worker thread will do). Increment the progress bar from the thread.
mahesh
|
|
|
|
|
Another problem when mixing pure "C" code and C++...
I'm adapting a DLL to use some pure "C" functions.
I have some modules in pure "C" puro and othersin C++.
In my module "ExportedFunctions.cpp" I have declared DLL exported functions... In this module the call to functions of class "login" are made:
login.createWindow(hwnd);
login.makeConexion(CString(operador), CString(senha), &lservidor );
In the file "ExportedFunctions.cpp" I have declared the class:
CLogin login;
In the module "login" I have declared as "public:" this functions:
public:
void createWindow(CWnd *pParent);
void makeConexion(CString operador, CString senha, CStringArray servidores);
These is working...;)
But now I have another modul (contcp.c), in pure "C"... And I have tried many ways to call fnEntrada from inside "ExportedFunctions.cpp" to a Function of "C" module without success! I #include "contcp.h" in "ExportedFunctions.cpp" and/or in "ExportedFunctions.h", but always occurs link error:
ExportedFunctions.obj : error LNK2001: unresolved external symbol "int __cdecl fnEntrada(void)" (?fnEntrada@@YAHXZ)
../dlls/Axsceovs2.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Somebody may help me??
Cesario
http://cesariosimoes.hpg.ig.com.br
Cesario Simoes, jr
Working with computers since 1970 (Burroughs/GTE). Programming in assembly DSP (TMS320c2x and TMS320c5x), C and C++. Using C++ and MFC, developping GUI to telecommunication equipment (PABX, ACD, RAS, etc.)
|
|
|
|
|
Anywhere you have #include "contcp.h", you need to surround that with the extern keyword as in:
extern "C"
{
#include "contcp.h"
}
|
|
|
|
|
Thank you, David! Ok very simple and I did it but, doesn't result... Remains ocurring the link error:
ExportedFunctions.obj : error LNK2001: unresolved external symbol _fnEntrada
../dlls/Axsceovs2.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
Another idea?
Cesario Simoes, jr
Working with computers since 1970 (Burroughs/GTE). Programming in assembly DSP (TMS320c2x and TMS320c5x), C and C++. Using C++ and MFC, developping GUI to telecommunication equipment (PABX, ACD, RAS, etc.)
|
|
|
|
|
|
The problem occurs just this functions. If I declare a variable, this is recognized in the other module... Perhaps is something related with the function declaration? I'm declaring like this:
int fnEntrada();
Cesario
Cesario Simoes, jr
Working with computers since 1970 (Burroughs/GTE). Programming in assembly DSP (TMS320c2x and TMS320c5x), C and C++. Using C++ and MFC, developping GUI to telecommunication equipment (PABX, ACD, RAS, etc.)
|
|
|
|
|
Thanks again, David!
It's ok now! I forget a "static" in front of the function declaration in the .h file...
Best regards from the lower south of Brazil...
Cesario Simoes, jr
Working with computers since 1970 (Burroughs/GTE). Programming in assembly DSP (TMS320c2x and TMS320c5x), C and C++. Using C++ and MFC, developping GUI to telecommunication equipment (PABX, ACD, RAS, etc.)
|
|
|
|
|
Hi!,
I use this code to get the column number of a CListControl into a CFormView. It works fine.
But It work for right click. I cannot find a Handler for left click. Something like NM_LCLICK unstead of NM_RCLICK.
BOOL CDataBaseManagerView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
HD_NOTIFY *pHDN = (HD_NOTIFY*)lParam;
LPNMHDR pNH = (LPNMHDR) lParam;
// wParam is zero for Header ctrl
if( wParam == 0 && pNH->code == NM_RCLICK )
{
// Right button was clicked on header
CPoint pt(GetMessagePos());
CHeaderCtrl* pHeader =(CHeaderCtrl*)m_wndListCtrl.GetHeaderCtrl();
pHeader->ScreenToClient(&pt);
// Determine the column index
int index = 0;
CRect rcCol;
for( int i = 0 ; Header_GetItemRect(pHeader->m_hWnd, i, &rcCol) ; i++ )
{
if( rcCol.PtInRect( pt ) )
{
index = i;
break;
}
}
CString str;
str.Format("Column no: %d", index);
AfxMessageBox(str);
}
return CFormView::OnNotify(wParam, lParam, pResult);
}
any ideas?
Thanks
Everything's beautiful if you look at it long enough...
|
|
|
|
|
I found It!!
BOOL CDataBaseManagerView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
//unstead of: HD_NOTIFY *pHDN = (HD_NOTIFY*)lParam;
// and: LPNMHDR pNH = (LPNMHDR) lParam;
NMHDR *pHdr = (NMHDR*)lParam;
//unstead of: if( wParam == 0 && pNH->code == NM_RCLICK )
if(pHdr->code == LVN_COLUMNCLICK)
{
...
}
return CFormView::OnNotify(wParam, lParam, pResult);
}
Everything's beautiful if you look at it long enough...
|
|
|
|
|
Hi,
For Left Mouse Button, it is just NM_CLICK.
regards
~Hari~
|
|
|
|
|