الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

مشكلتان تصادفني في البرمجة مع Opengl ارجو المساعدة

بدأه مدمن ++C في 28 فبراير 2009 · 6 رد · 1,418 مشاهدة · في OpenGL
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بســم الله الـرحمــن الرحيــم

السلام عليكــم ورحمـة الله وبركاتــة ،،

كيف حالك إن شاء الله دائمــاً بخير ؟

عندي مشكلتين في برمجة مع OpenGL

لقد بحثت عن حل لمصيبتي فلم اجد اي شيء مفيد

أولاً

كيف لي بتضمين مكتبات lib ؟

وأين أضع ملفات dll??

ثانياً:

برمجت اول برنامج لي..

ولكنه ظهر أخطاء كثيرة... وأنا تعبت حتى فهمت دروس الأستاذ علي الدعيج رحمه الله

وهذه هي الاخطاء

1>------ Build started: Project: 1-test, Configuration: Debug Win32 ------

1>Compiling...

1>1-test1.cpp

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(66) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [29]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(71) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [34]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(78) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [31]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(84) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [24]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(88) : error C2664: 'UnregisterClassW' : cannot convert parameter 1 from 'const char [7]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(90) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [28]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(119) : error C2440: '=' : cannot convert from 'const char [7]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(123) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [37]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(141) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [94]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(148) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [24]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(180) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(183) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [23]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(212) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [34]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(219) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [35]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(226) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [27]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(233) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [37]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(240) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [41]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(252) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [23]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>c:\users\peace\documents\visual studio 2008\projects\1-test\1-test\1-test1.cpp(329) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'const char [42]' to 'LPCWSTR'

1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

1>Build log was saved at "file://c:\Users\PEACE\Documents\Visual Studio 2008\Projects\1-test\1-test\Debug\BuildLog.htm"

1>1-test - 19 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

فأرجو المساعدة يا أخوان

#2

وعليكم السلام ورحمة الله وبركاته ..

ليست مشكلة .. لكن

visual c++ 6 كان يتعامل مع أي دالة مثل MessageBox على أنها MessageBoxA ( بمعنى أنها تستقبل بارمتر من نوع اسكي وليس unicode )

في الاصدارات الحدايثة من الفيجوال ,, صار العكس ( وهذا افضل طبعا ) , نحو دعم اليونيكود .. بشكل افتراضي .

الحل للمشكلة :

1- أن تضع قبل أي نص String حرف L , ( ماكرو) ,,,

MessageBox(NULL, L"Hello World",L"Test",MB_OK);

2- الحل الثاني الاسهل .. هو ان تخبر المترجم بأنك لا تريد استخدام الدوال التي تعتمد على اليونيكود ..

بعد ان تنشئ مشروعك الجديد ... من القائمة اختر

Project ->Properties

او للاختصار ... Alt + F7

post-42837-1235782293_thumb.png

تم تعديل هذه المشاركة بواسطة الشمري في 28 فبراير 2009 في 03:52

logo1.png تطبيق طمأنينة ، نسخة بيتا على أندرويد

عبدالله الشمّري - Al-Shammari

CodingAlone.com

twitter @abshammeri

abshammeri AT gmail.com

github : abshammeri

#3

جزااك الله ألف خير يا الشمري...:)

بجرب وبخبرك النتيجة^^

سلام

#4

أختفت أخطاء الرسائل... لتظهر أخطاء جديدة:(

يا إلهي...>_>

انظر إلى الأخطاء أخي الشمري... رغم أني متأكد من سلامة الكوود

1>------ Build started: Project: 1-test, Configuration: Debug Win32 ------

1>Linking...

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "void __cdecl ReSizeGLScene(int,int)" (?ReSizeGLScene@@YAXHH@Z)

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function "void __cdecl ReSizeGLScene(int,int)" (?ReSizeGLScene@@YAXHH@Z)

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function "void __cdecl ReSizeGLScene(int,int)" (?ReSizeGLScene@@YAXHH@Z)

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__glHint@8 referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ)

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__glDepthFunc@4 referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ)

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ)

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__glClearDepth@8 referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ)

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ)

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__glShadeModel@4 referenced in function "int __cdecl InitGL(void)" (?InitGL@@YAHXZ)

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function "int __cdecl DrawGLScene(void)" (?DrawGLScene@@YAHXZ)

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__wglDeleteContext@4 referenced in function "void __cdecl KillGLWindow(void)" (?KillGLWindow@@YAXXZ)

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__wglMakeCurrent@8 referenced in function "void __cdecl KillGLWindow(void)" (?KillGLWindow@@YAXXZ)

1>1-test1.obj : error LNK2019: unresolved external symbol __imp__wglCreateContext@4 referenced in function "int __cdecl CreateGLWindow(char *,int,int,int,bool)" (?CreateGLWindow@@YAHPADHHH_N@Z)

1>C:\Users\PEACE\Documents\Visual Studio 2008\Projects\1-test\Debug\1-test.exe : fatal error LNK1120: 13 unresolved externals

1>Build log was saved at "file://c:\Users\PEACE\Documents\Visual Studio 2008\Projects\1-test\1-test\Debug\BuildLog.htm"

1>1-test - 14 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

#5

يجب أن تربط المكتبات .. اضف هذه الاسطر في بداية البرنامج :

#pragma comment(lib, "OpenGL32.lib")
#pragma comment(lib, "GLu32.lib")

واذا كنت تستخدم glaux فاضف هذا السطر ايضا ..

#pragma comment(lib, "Glaux.lib")

بالمناسبة : يوجد دروس في الفهرس المثبت عن طريقة تنفيذ برنامجك الاول في OpenGL في Win32 API أو GLUT أو SDL ..

بالتوفيق أخي ..

تم تعديل هذه المشاركة بواسطة الشمري في 3 مارس 2009 في 06:21

logo1.png تطبيق طمأنينة ، نسخة بيتا على أندرويد

عبدالله الشمّري - Al-Shammari

CodingAlone.com

twitter @abshammeri

abshammeri AT gmail.com

github : abshammeri

#6

المدة التي تأخرت فيها بالرد... علمتني كل شي... وجزاك الله كل شي

تمكنت من البرمجة... حتى تعلمت رسم ثلاثي الابعااد....

ولكن حصلت لي مشكلة في الأكساء... أرجو أن ترى الكود... وتخبرني لما لم يتطبق الاكساء

# pragma comment (lib, "opengl32.lib")   
# pragma comment (lib, "glu32.lib")	  
# pragma comment (lib, "glaux.lib")

#include <windows.h>	
#include <stdio.h>
#include <gl\gl.h>		 
#include <gl\glu.h>			 
#include <gl\glaux.h>	
#include "in.h"

GLuint texture[1];
AUX_RGBImageRec *LoadBMP(char *Filename)
{
	FILE *File=NULL;
	if(!Filename)
	{
		return NULL;
	}
	File=fopen(Filename,"r");
	if (File)
	{
		fclose(File);
		return auxDIBImageLoad(Filename);
	}
	return NULL;
}

int LoadGLTextures()
{
	int Status=false;
	AUX_RGBImageRec *TextureImage[1];
	memset(TextureImage,0,sizeof(void *)*1);
	if (TextureImage[0]=LoadBMP("Pictures/r.bmp"));
	{
		Status=true;
		glGenTextures(1, &texture[0]);
		glBindTexture(GL_TEXTURE_2D, texture[0]);
		glTexImage2D(GL_TEXTURE_2D,0,3,TextureImage[0]->sizeX, TextureImage[0]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,TextureImage[0]->data);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	}
	if (TextureImage[0])
	{
		if (TextureImage[0]->data)
		{
			free(TextureImage[0]->data);
		}
		free(TextureImage[0]);
	}
	return Status;
}

GLfloat t = 0.0f;
void mothalth(float x1,float y1,float z1, float x2, float y2, float z2, float x3, float y3, float z3)
{
glColor3f(0.5, 1.0, 0.5);
glBegin(GL_TRIANGLES); 
glVertex3f(x1,y1,z1); 
glVertex3f(x2,y2,z2);
glVertex3f(x3,y3,z3);
glEnd();
}
int DrawGLScene(GLvoid)	
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-1.0f);
glRotatef(t,0.0,1.0,0.0);
mothalth(0.0f,0.2f,0.0f,-0.2f,-0.2f,0.2f,0.2f,-0.2f,0.2f);
mothalth(0.0f,0.2f,0.0f,0.2f,-0.2f,0.2f,0.2f,-0.2f,-0.2f);
mothalth(0.0f,0.2f,0.0f,0.2f,-0.2f,-0.2f,-0.2f,-0.2f,-0.2f);
mothalth(0.0f,0.2f,0.0f,-0.2f,-0.2f,-0.2f,-0.2f,-0.2f,0.2f);
t+=1.0f;
return TRUE;
}

int WINAPI WinMain(	HINSTANCE	hInstance,HINSTANCE	hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
	char NAME_WINDOW[]="kookoo";
	int X_WINDOW=640,Y_WINDOW=480,T=16;
	MSG		msg;
	BOOL	done=FALSE;
  //  if(MessageBox(NULL,"FULL?","SBR",MB_YESNO|MB_ICONQUESTION)==IDNO)
//	{
		fullscreen=FALSE;
//	}
	if (!CreateGLWindow(NAME_WINDOW,X_WINDOW,Y_WINDOW,T,fullscreen))
	{
		return 0;
	}
	while(!done)
	{
		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
		{
			if (msg.message==WM_QUIT)
			{
				done=TRUE;
			}
			else
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else								
		{
		if ((active && !DrawGLScene()) || keys[VK_ESCAPE])	
			{
				done=TRUE;
			}
			else	
			{
				SwapBuffers(hDC);
			}
			if (keys[VK_F1])
			{
				keys[VK_F1]=FALSE;	
				KillGLWindow();	
				fullscreen=!fullscreen;		
	if (!CreateGLWindow(NAME_WINDOW,X_WINDOW,Y_WINDOW,T,fullscreen))
				{
					return 0;
				}
			}
		}
	}
	KillGLWindow();
	return (msg.wParam);
}
#7

- لم تحدد احداثيات الاكساء , يجب تحديد احداثيات الاكساء في الدالة mothalath , عن طريق الدالة glTexCoord2f

- تأكد من تفعيل الاكساء , عن طريق الدالة

glEnable(GL_TEXTURE_2D);

- تأكد من اختيار الاكساء عن طريق الدالة glBindTexture 

logo1.png تطبيق طمأنينة ، نسخة بيتا على أندرويد

عبدالله الشمّري - Al-Shammari

CodingAlone.com

twitter @abshammeri

abshammeri AT gmail.com

github : abshammeri

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…