Пример #1
0
int CCgiPacket::UnpacketSdCardRecordFileList(const char * pszBuffer,STRU_RECORD_FILE_LIST & t)
{
    
    NSLog(@"UnpacketSdCardRecordFileList...start");
    int n = 0;
	SscanfInt(pszBuffer,"record_num0=",n);
	if (n == 0)
	{
		return 1;
	}
    
     NSLog(@"UnpacketSdCardRecordFileList...1111");
    
    t.nCount = n;
    int PageCount=0;
    
    SscanfInt(pszBuffer,"PageCount=",PageCount);
    NSLog(@"UnpacketSdCardRecordFileList...2222");
    
	t.nPageCount=PageCount;
	char buf[128]={0};
	for (int i = 0 ; i < n ; i++)
	{
        
		sprintf(buf,"record_name0[%d]=",i);
		SscanfString(pszBuffer,buf,t.recordFile[i].szFileName);
		sprintf(buf,"record_size0[%d]=",i);
		SscanfInt(pszBuffer,buf,t.recordFile[i].nFileSize);
        sprintf(buf,"record_bend[%d]=",i);
		SscanfInt(pszBuffer,buf,t.recordFile[i].record_bend);
	}
     NSLog(@"UnpacketSdCardRecordFileList...end");
	return 1;
}
Пример #2
0
    int main (int argc, const char *argv[]){

    	int x = 1;

   	int y = 2;

    	int z = 0;

    	int adder = 0;

    	while(y &lt; 4000000){

	    	if (y%2==0){

    			adder = adder + y;

    			NSLog(@"Current fibonacci number is %d", y);

    		}

    		z=y;

    		y=y+x;

    		x=z;

    	}

    	NSLog(@"The sum of all the even-valued terms in the sequence which do not exceed four million is %d", adder);

    }
Пример #3
0
JSValueRef EJApp::loadModuleWithId(NSString * moduleId, JSValueRef module, JSValueRef exports)
{
    NSString * path = NSStringMake(moduleId->getCString() + string(".js"));
    NSString * script = NSString::createWithContentsOfFile(pathForResource(path)->getCString());

    if( !script ) {
        NSLog("Error: Can't Find Module %s", moduleId->getCString() );
        return NULL;
    }

    NSLog("Loading Module: %s", moduleId->getCString() );

    JSStringRef scriptJS = JSStringCreateWithUTF8CString(script->getCString());
    JSStringRef pathJS = JSStringCreateWithUTF8CString(path->getCString());
    JSStringRef parameterNames[] = {
        JSStringCreateWithUTF8CString("module"),
        JSStringCreateWithUTF8CString("exports"),
    };

    JSValueRef exception = NULL;
    JSObjectRef func = JSObjectMakeFunction( jsGlobalContext, NULL, 2,  parameterNames, scriptJS, pathJS, 0, &exception );

    JSStringRelease( scriptJS );
    JSStringRelease( pathJS );
    JSStringRelease(parameterNames[0]);
    JSStringRelease(parameterNames[1]);

    if( exception ) {
        logException(exception, jsGlobalContext);
        return NULL;
    }

    JSValueRef params[] = { module, exports };
    return invokeCallback(func, NULL, 2, params);
}
Пример #4
0
unsigned int parseStringConfig(const char *string, struct config *out) {
    unsigned int rc;
    size_t w;
    size_t h;
    size_t d;
    double r;
    int numConverted = sscanf(string, "%lux%lux%lu@%lf", &w, &h, &d, &r);
    if (numConverted != 4) {
        numConverted = sscanf(string, "%lux%lux%lu", &w, &h, &d);
        if (numConverted != 3) {
            rc = 0;
            NSLog(CFSTR("Error: the mode '%s' couldn't be parsed"), string);
        } else {
            out->w = w;
            out->h = h;
            out->d = d;
            r=60.0;
            rc = 1;
            NSLog(CFSTR("Warning: no refresh rate specified, assuming %.0lfHz"), r);
        }
    } else {
        out->w = w;
        out->h = h;
        out->d = d;
        out->r = r;
        rc = 1;
    }
    return rc;
}
Пример #5
0
CFDataRef copyIconDataForURL(CFURLRef URL) {
	CFDataRef data = NULL;

	if (URL) {
		FSRef ref;
		if (CFURLGetFSRef(URL, &ref)) {
			IconRef icon = NULL;
			SInt16 label_noOneCares;
			OSStatus err = GetIconRefFromFileInfo(&ref,
												  /*inFileNameLength*/ 0U, /*inFileName*/ NULL,
												  kFSCatInfoNone, /*inCatalogInfo*/ NULL,
												  kIconServicesNoBadgeFlag | kIconServicesUpdateIfNeededFlag,
												  &icon,
												  &label_noOneCares);
			if (err != noErr) {
				NSLog(CFSTR("in copyIconDataForURL in CFGrowlAdditions: could not get icon for %@: GetIconRefFromFileInfo returned %li\n"), URL, (long)err);
			} else {
				IconFamilyHandle fam = NULL;
				err = IconRefToIconFamily(icon, kSelectorAllAvailableData, &fam);
				if (err != noErr) {
					NSLog(CFSTR("in copyIconDataForURL in CFGrowlAdditions: could not get icon for %@: IconRefToIconFamily returned %li\n"), URL, (long)err);
				} else {
					HLock((Handle)fam);
					data = CFDataCreate(kCFAllocatorDefault, (const UInt8 *)*(Handle)fam, GetHandleSize((Handle)fam));
					HUnlock((Handle)fam);
					DisposeHandle((Handle)fam);
				}
				ReleaseIconRef(icon);
			}
		}
	}

	return data;
}
Пример #6
0
int fakeIt() {
    
    if ( !initApplication(hInstance)) {
        // Handle that shit
        NSLog(L"RegisterClassEx FAILED: %d", GetLastError());
    }

    HWND hWnd = CreateWindow( L"MainWClass",                // lpClassName
                                NULL,                    // lpWindowName
                                WS_OVERLAPPEDWINDOW,          // dwStyle
                                100,    // x
                                100,    // y
                                500,  // width
                                500, // height
                                NULL,                    // hWndParent
                                NULL,                    // hMenu
                                hInstance,               // hInstance
                                NULL );                  // lpParam

    if (!hWnd) {
        NSLog(L"CreateWindow FAILED: %d", GetLastError());
    }

    ShowWindow(hWnd, SW_SHOW); 
    UpdateWindow(hWnd); 



    HWND hWnd2 = CreateWindow( L"MainWClass",                // lpClassName
                                NULL,                    // lpWindowName
                                WS_CHILD,          // dwStyle
                                10,    // x
                                10,    // y
                                50,  // width
                                50, // height
                                hWnd,                    // hWndParent
                                NULL,                    // hMenu
                                hInstance,               // hInstance
                                NULL );                  // lpParam

    if (!hWnd2) {
        NSLog(L"CreateWindow FAILED: %d", GetLastError());
    }

    ShowWindow(hWnd2, SW_SHOW); 
    UpdateWindow(hWnd2); 

    MSG msg;

    while (GetMessage(&msg, NULL, 0, 0) > 0) {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return 0;

}
shared_ptr<mw::Component> CNCDeviceFactory::createObject(std::map<std::string, std::string> parameters,
												 ComponentRegistry *reg) {
												 
	REQUIRE_ATTRIBUTES(parameters, "device_name");
	
    string executable_path = parameters["executable_path"];
    if(executable_path == ""){
        executable_path = "/Applications/cncController.app/Contents/MacOS/cncController";
    }
	
    //NSTask *task = [NSTask launchedTaskWithLaunchPath:[NSString stringWithCString:executable_path.c_str() encoding:NSASCIIStringEncoding] arguments:[[NSArray alloc] init]];
   
    shared_ptr<mw::Clock> clock = mw::Clock::instance();
    //clock->sleepMS(1000);
    
    //if(![task isRunning]){
    //    throw SimpleException("Failed to launch eye tracker application");
    //}
    
    NSLog(@"%s",executable_path.c_str());
    
	string resource_name = parameters["device_name"];
    shared_ptr <mw::Component> newDevice(new CNCDevice(resource_name));

    return newDevice;
    
}
Пример #8
0
void *VMemAlloc(const vm_size_t size)
{
	GLbyte         *pointer = NULL;
	kern_return_t   err     = KERN_SUCCESS;
	
	// In debug builds, check that we have
	// correct VM page alignment
	
	check(size != 0);
	check((size % 4096) == 0);
	
	// Allocate directly from VM
	
	err = vm_allocate(	(vm_map_t) mach_task_self(),
					  (vm_address_t *)&pointer,
					  size,
					  VM_FLAGS_ANYWHERE );
	
	// Check errors
	
	check(err == KERN_SUCCESS);
	
	if( err != KERN_SUCCESS)
	{
		NSLog(@">> ERROR: Failed to allocate vm memory of size = %lu",size);
		
		pointer = NULL;
	} // if
	
	return pointer;
} // VMemAlloc
Пример #9
0
    JNIEXPORT void JNICALL Java_com_impactjs_ejecta_EjectaRenderer_nativeCreated(JNIEnv* env, jobject thiz , jstring package_path, jint w, jint h)
    {

        NSLog("nativeCreated : %d, %d", w, h);
        const char *nativeString = (env)->GetStringUTFChars(package_path, 0);
        EJApp::instance()->init(nativeString, w, h);
    }
Пример #10
0
unsigned int listCurrentMode(CGDirectDisplayID display, int displayNum) {
    unsigned int returncode = 1;
    CGDisplayModeRef currentMode = CGDisplayCopyDisplayMode(display);
    if (currentMode == NULL) {
        NSLog(CFSTR("%s"), "Error: unable to copy current display mode");
        returncode = 0;
    }
    NSLog(CFSTR("Display %d: %ux%ux%u@%.0f"),
           displayNum,
           CGDisplayModeGetWidth(currentMode),
           CGDisplayModeGetHeight(currentMode),
           bitDepth(currentMode),
           CGDisplayModeGetRefreshRate(currentMode));
    CGDisplayModeRelease(currentMode);
    return returncode;
}
Пример #11
0
static void print_log(const char* operation, const char* log)
{
//	__android_log_print(ANDROID_LOG_INFO, "OPENWAR", "%s: %s", operation, log);
#ifdef OPENWAR_USE_NSBUNDLE_RESOURCES
	NSLog(@"RENDERER log (%s):\n%s", operation, log);
#endif
}
Пример #12
0
        void FrameBufferPrivate::bind()
        {
            if(frameBufferId_ == 0)
            {
#ifdef __linux__
                // Create frame buffer
                glGenFramebuffers(1, &frameBufferId_);

                // Color buffer
                glGenTextures(1, &textureColorId_);
                glBindTexture(GL_TEXTURE_2D, textureColorId_);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width_, height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
                glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureColorId_, 0);

                // FBO status
                GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
                if(status != GL_FRAMEBUFFER_COMPLETE)
                {
                    throw Exception("FrameBuffer, creation failed!");
                }
#elif __APPLE__
                /* reference:
                 https://developer.apple.com/library/ios/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/WorkingwithEAGLContexts/WorkingwithEAGLContexts.html#//apple_ref/doc/uid/TP40008793-CH103-SW1
                 */
                
                glGenFramebuffers(1, &frameBufferId_);
                glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId_);
                
                GLuint colorRenderbuffer;
                glGenRenderbuffers(1, &colorRenderbuffer);
                glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
                glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA /* T */, width_, height_);
                glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorRenderbuffer);
                
                GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER) ;
                if(status != GL_FRAMEBUFFER_COMPLETE) {
                    NSLog(@"failed to make complete framebuffer object %x", status);
                }
                
                // create the texture
                glGenTextures(1, &textureColorId_);
                glBindTexture(GL_TEXTURE_2D, textureColorId_);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA /* T */,  width_, height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
                glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureColorId_, 0);
#endif
            }

            // Render to our framebuffer
            glBindTexture(GL_TEXTURE_2D, textureColorId_);
            glEnable(GL_TEXTURE_2D);
            glBindFramebuffer(GL_FRAMEBUFFER, frameBufferId_);
            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureColorId_, 0);
            glViewport(0, 0, width_, height_);
        }
Пример #13
0
task main(){
  show_log();//show the log
  NSLog("start");
  menu_init();//init the menu
  while(true){
    menu_main();//run menu
  }
}
Пример #14
0
UIApplication::UIApplication() {
    HINSTANCE hInstance = GetModuleHandle(NULL);

    // Register "class" with Win32
    this->_wndClass.style            = CS_HREDRAW | CS_VREDRAW;
    this->_wndClass.lpfnWndProc      = (WNDPROC) UIApplication::WndProcedure;
    this->_wndClass.cbClsExtra       = 0;
    this->_wndClass.cbWndExtra       = 0;
    this->_wndClass.hInstance        = hInstance;
    this->_wndClass.hIcon            = NULL;
    this->_wndClass.hCursor          = 0;
    this->_wndClass.hbrBackground    = (HBRUSH) GetStockObject(HOLLOW_BRUSH);
    this->_wndClass.lpszMenuName     = 0;
    this->_wndClass.lpszClassName    = APP_NAME;
    //this->_wndClass.cbSize           = sizeof(this->_wndClass);

#ifdef _WIN32_WCE
    if ( !RegisterClass(&this->_wndClass) ) {
        NSLog(L"RegisterClass FAILED: %d", GetLastError());
    }
#else
    if ( !RegisterClassEx(&this->_wndClass) ) {
        NSLog(L"RegisterClassEx FAILED: %d", GetLastError());
    }
#endif

    /*WNDCLASSEX _wndClass2;

    // Register "class" with Win32
    _wndClass2.style            = CS_HREDRAW | CS_VREDRAW;
    _wndClass2.lpfnWndProc      = (WNDPROC) UIApplication::WndProcedure;
    _wndClass2.cbClsExtra       = 0;
    _wndClass2.cbWndExtra       = 0;
    _wndClass2.hInstance        = hInstance;
    _wndClass2.hIcon            = NULL;
    _wndClass2.hCursor          = 0;
    _wndClass2.hbrBackground    = (HBRUSH) GetStockObject(HOLLOW_BRUSH);
    _wndClass2.lpszMenuName     = 0;
    _wndClass2.lpszClassName    = L"Whoa dude";
    _wndClass2.cbSize           = sizeof(_wndClass2);

    if ( !RegisterClassEx(&_wndClass2) ) {
        // Handle that shit
        NSLog(L"RegisterClassEx FAILED: %d", GetLastError());
    }*/
}
Пример #15
0
void driveRobot() {
  getJoystickSettings(joystick);
  NSLog("drive robot");
  motor[motorD] = joystick.joy1_y2;
  motor[motorE] = joystick.joy1_y2;
  motor[motorF] = joystick.joy1_y1;
  motor[motorG] = joystick.joy1_y1;
}
static inline void CheckForAndLogExtensionAvailable(const GLboolean extensionAvailable, 
													const GLchar *extensionName)
{
	if( extensionAvailable == GL_FALSE )
	{
		NSLog(@">> WARNING: \"%s\" extension is not available!\n", 
			  extensionName);
	} // if
} // CheckForExtensions
Пример #17
0
CFStringRef copyCurrentProcessName(void) {
	ProcessSerialNumber PSN = { 0, kCurrentProcess };
	CFStringRef name = NULL;
	OSStatus err = CopyProcessName(&PSN, &name);
	if (err != noErr) {
		NSLog(CFSTR("in copyCurrentProcessName in CFGrowlAdditions: Could not get process name because CopyProcessName returned %li"), (long)err);
		name = NULL;
	}
	return name;
}
static Boolean _checkOSXVersion(void) {
	long OSXVersion = 0L;
	OSStatus err = Gestalt(gestaltSystemVersion, &OSXVersion);
	if (err != noErr) {
		NSLog(CFSTR("WARNING in GrowlInstallationPrompt: could not get Mac OS X version (selector = %x); got error code %li (will show the installation prompt anyway)"), (unsigned)gestaltSystemVersion, (long)err);
		//we proceed anyway, on the theory that it is better to show the installation prompt when inappropriate than to suppress it when not.
		OSXVersion = minimumOSXVersionForGrowl;
	}
	return (OSXVersion >= minimumOSXVersionForGrowl);
}
Пример #19
0
CFPropertyListRef createPropertyListFromURL(CFURLRef file, u_int32_t mutability, CFPropertyListFormat *outFormat, CFStringRef *outErrorString) {
	CFPropertyListRef plist = NULL;

	if (!file)
		NSLog(CFSTR("in createPropertyListFromURL in CFGrowlAdditions: cannot read from a NULL URL"));
	else {
		CFReadStreamRef stream = CFReadStreamCreateWithFile(kCFAllocatorDefault, file);
		if (!stream)
			NSLog(CFSTR("in createPropertyListFromURL in CFGrowlAdditions: could not create stream for reading from URL %@"), file);
		else {
			if (!CFReadStreamOpen(stream))
				NSLog(CFSTR("in createPropertyListFromURL in CFGrowlAdditions: could not open stream for reading from URL %@"), file);
			else {
				CFPropertyListFormat format;
				CFStringRef errorString = NULL;

				plist = CFPropertyListCreateFromStream(kCFAllocatorDefault,
													   stream,
													   /*streamLength*/ 0,
													   mutability,
													   &format,
													   &errorString);
				if (!plist)
					NSLog(CFSTR("in createPropertyListFromURL in CFGrowlAdditions: could not read property list from URL %@ (error string: %@)"), file, errorString);

				if (outFormat) *outFormat = format;
				if (errorString) {
					if (outErrorString)
						*outErrorString = errorString;
					else
						CFRelease(errorString);
				}

				CFReadStreamClose(stream);
			}

			CFRelease(stream);
		}
	}

	return plist;
}
Пример #20
0
unsigned int setDisplayToMode(CGDirectDisplayID display, CGDisplayModeRef mode) {
    CGError rc;
    CGDisplayConfigRef config;
    rc = CGBeginDisplayConfiguration(&config);
    if (rc != kCGErrorSuccess) {
        NSLog(CFSTR("Error: failed CGBeginDisplayConfiguration err(%u)"), rc);
        return 0;
    }
    rc = CGConfigureDisplayWithDisplayMode(config, display, mode, NULL);
    if (rc != kCGErrorSuccess) {
        NSLog(CFSTR("Error: failed CGConfigureDisplayWithDisplayMode err(%u)"), rc);
        return 0;
    }
    rc = CGCompleteDisplayConfiguration(config, kCGConfigurePermanently);
    if (rc != kCGErrorSuccess) {
        NSLog(CFSTR("Error: failed CGCompleteDisplayConfiguration err(%u)"), rc);        
        return 0;
    }
    return 1;
}
Пример #21
0
CFURLRef copyTemporaryFolderURL(void) {
	FSRef ref;
	CFURLRef url = NULL;

	OSStatus err = FSFindFolder(kOnAppropriateDisk, kTemporaryFolderType, kCreateFolder, &ref);
	if (err != noErr)
		NSLog(CFSTR("in copyTemporaryFolderPath in CFGrowlAdditions: Could not locate temporary folder because FSFindFolder returned %li"), (long)err);
	else
		url = CFURLCreateFromFSRef(kCFAllocatorDefault, &ref);

	return url;
}
Пример #22
0
CFURLRef copyCurrentProcessURL(void) {
	ProcessSerialNumber psn = { 0, kCurrentProcess };
	FSRef fsref;
	CFURLRef URL = NULL;
	OSStatus err = GetProcessBundleLocation(&psn, &fsref);
	if (err != noErr) {
		NSLog(CFSTR("in copyCurrentProcessURL in CFGrowlAdditions: Could not get application location, because GetProcessBundleLocation returned %li\n"), (long)err);
	} else {
		URL = CFURLCreateFromFSRef(kCFAllocatorDefault, &fsref);
	}
	return URL;
}
Пример #23
0
bool LogOpenALError( const CHAR_ * lpFile, I32 iLine )
{
    ALenum aError;
    bool bErr = false;
    while( (aError = alGetError()) != AL_NO_ERROR )
    {
        NSLog( @"OpenAL: File - %s, Line - %ld, Code: %d", lpFile, iLine, aError );
        bErr = true;
    }
    
    return bErr;
}
Пример #24
0
unsigned int configureDisplay(CGDirectDisplayID display, struct config *config, int displayNum) {
    unsigned int returncode = 1;
    CFArrayRef allModes = CGDisplayCopyAllDisplayModes(display, NULL);
    if (allModes == NULL) {
        NSLog(CFSTR("Error: failed trying to look up modes for display %u"), displayNum);
    }

    CGDisplayModeRef newMode = NULL;
    CGDisplayModeRef possibleMode;
    size_t pw; // possible width.
    size_t ph; // possible height.
    size_t pd; // possible depth.
    double pr; // possible refresh rate
    int looking = 1; // used to decide whether to continue looking for modes.
    int i;
    for (i = 0 ; i < CFArrayGetCount(allModes) && looking; i++) {
        possibleMode = (CGDisplayModeRef)CFArrayGetValueAtIndex(allModes, i);
        pw = CGDisplayModeGetWidth(possibleMode);
        ph = CGDisplayModeGetHeight(possibleMode);
        pd = bitDepth(possibleMode);
        pr = CGDisplayModeGetRefreshRate(possibleMode);
        if (pw == config->w &&
            ph == config->h &&
            pd == config->d &&
            pr == config->r) {
            looking = 0; // Stop looking for more modes!
            newMode = possibleMode;
        }
    }
    CFRelease(allModes);
    if (newMode != NULL) {
        NSLog(CFSTR("set mode on display %u to %ux%ux%u@%.0f"), displayNum, pw, ph, pd, pr);
        setDisplayToMode(display,newMode);
    } else {
        NSLog(CFSTR("Error: mode %ux%ux%u@%f not available on display %u"), 
                config->w, config->h, config->d, config->r, displayNum);
        returncode = 0;
    }
    return returncode;
}
Пример #25
0
///
// Update a triangle using the shader pair created in Init()
//
static void Update ( ESContext *esContext, float deltaTime)
{

    UserData *userData = (UserData*) esContext->userData;
    ESMatrix perspective;
    ESMatrix modelview;

    float    aspect;

    // Compute a rotation angle based on time to rotate the cube
    userData->angle += 1;//( deltaTime * 40.0f );
    if( userData->angle >= 360.0f )
       userData->angle -= 360.0f;


    // Compute the window aspect ratio
    aspect = 1;//(GLfloat) esContext->width / (GLfloat) esContext->height;

    // Generate a perspective matrix with a 60 degree FOV
    esMatrixLoadIdentity( &perspective );
    esPerspective( &perspective, 50.0f, aspect, 1.0f, 20.0f );



    // Generate a model view matrix to rotate/translate the cube
    esMatrixLoadIdentity( &modelview );

    // Translate away from the viewer
    esTranslate( &modelview, 0.0, 0.0, -2.0 );

    esScale( &modelview,.2,.2,.2);
    // Rotate the cube
    esRotate( &modelview, userData->angle, .0, 1.0, .0 );

    // Compute the final MVP by multiplying the modevleiw and perspective matrices together
    esMatrixMultiply( &userData->mvpMatrix, &modelview, &perspective );

#if 1
    userData->normalMatrix = processNormalMatrix(modelview);


#else
    // Normal Matrix
    // Transform normals from object-space to eye-space
    bool invertible;
    GLKMatrix3 normalMatrix = GLKMatrix4GetMatrix3(GLKMatrix4InvertAndTranspose(modelViewMatrix, &invertible));
    if(!invertible)
        NSLog(@"MV matrix is not invertible");
    glUniformMatrix3fv(self.phongShader.uNormalMatrix, 1, 0, normalMatrix.m);
#endif

}
Пример #26
0
void MemFree(void *pointer)
{
	if ( pointer != NULL )
	{
		free( pointer );
		
		pointer = NULL;
	} // if
	else
	{
		NSLog(@">> ERROR: Can't free a NULL pointer!");
	} // else
} // MemFree
Пример #27
0
void VMemFree(const vm_size_t size, void *pointer)
{
	if ( ( pointer != NULL ) && ( size > 0 ) )
	{
		kern_return_t err = vm_deallocate(	(vm_map_t) mach_task_self(),
										  (vm_address_t)pointer,
										  size );
		
		// Check errors
		
		check(err == KERN_SUCCESS);
		
		if( err != KERN_SUCCESS)
		{
			NSLog(@">> ERROR: Failed to deallocate vm memory of size = %lu",size);
		} // if
	} // if
	else
	{
		NSLog(@">> ERROR: Can't free a NULL vm pointer!");
	} // else
} // VMemFree
Пример #28
0
		void Log(ELogLevel const &Lv, const char * Tag, const char * Msg) override
		{
#if K3DPLATFORM_OS_WIN
			static thread_local char logBuffer[4096] = { 0 };
			sprintf(logBuffer, "[%s]-[%d]\t%s\t%s\n", GetLocalTime(), Lv, Tag, Msg);
			OutputDebugStringA(logBuffer);
#elif K3DPLATFORM_OS_MAC
            NSLog(@"%s::%s", Tag, Msg);
#elif K3DPLATFORM_OS_ANDROID
            
#else
            
#endif
		}
Пример #29
0
void build_vertices(Mesh* mesh_ptr) {
	mesh_ptr->numVertices = CLOTH_WIDTH * CLOTH_HEIGHT;
	NSLog(@"rezerwacja pamieci dla mesh_ptr->vertices");
	mesh_ptr->vertices = (Vertex3d*)alloc_mem(1, mesh_ptr->numVertices * sizeof(Vertex3d));	
	memset(mesh_ptr->vertices, 0, mesh_ptr->numVertices * sizeof(Vertex3d));
	NSLog(@"rezerwacja pamieci dla mesh_ptr->vertices_tier2");	
	mesh_ptr->vertices_tier2 = (Vertex3d*)alloc_mem(1, mesh_ptr->numVertices * sizeof(Vertex3d));
	memset(mesh_ptr->vertices_tier2, 0, mesh_ptr->numVertices * sizeof(Vertex3d));	
	
	int index = 0;
	
	for (int y=0; y<CLOTH_HEIGHT; y++) {
		for (int x=0; x<CLOTH_WIDTH; x++) {
			index = x + (y * CLOTH_WIDTH);
			
			mesh_ptr->vertices[index].old[0] = mesh_ptr->vertices[index].current[0] = (x - CLOTH_WIDTH/2)  *  GAP_X;
			mesh_ptr->vertices[index].old[1] = mesh_ptr->vertices[index].current[1] = (y - CLOTH_HEIGHT/2) * -GAP_Y;
			mesh_ptr->vertices[index].old[2] = mesh_ptr->vertices[index].current[2] = 0.0;			
		}
		
	}
	
	return;
}
Пример #30
0
Mesh3D::~Mesh3D()
{
	NSLog(@"Destroy %s", m_filename.c_str());
	glDeleteBuffers(m_ModelPOD.nNumMesh, iVertexVBO);
	glDeleteBuffers(m_ModelPOD.nNumMesh, m_puiIndexVbo);
	
	delete[] iVertexVBO;
	delete[] m_puiIndexVbo;
	delete[] meshInfo;	
	
	for(int i=0;i< m_numMaterials ;i++)
	{
		TextureManager::getInstance().removeTexture( materialInfo[i].textureFileName.c_str() );
	}
	delete[] materialInfo;
	delete[] m_uiTexture;
}