91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 21.28MB
    文件類型: .rar
    金幣: 1
    下載: 0 次
    發布日期: 2023-08-06
  • 語言: C/C++
  • 標簽: c++??vs2017??

資源簡介

VS工程奉上,運行邏輯應該無問題,用六面體代表貪吃蛇的身體,繪制用一個數組保存所有的頂點,用一個數組保存頂點的序號。但最后繪制的時候,不是編寫循環語句逐個的指定頂點了,而是通知OpenGL,”保存頂點的數組”和”保存頂點序號的數組”所在的位置,由OpenGL自動的找到頂點,并進行繪制。但是沒有調gluLookAt和glRotatef,運行起來是二維的。c++和opengl都是初學,請大家指正。

資源截圖

代碼片段和文件信息

#include????
#include????
#include????
#include
#include
#include
#include?
#include
#include
#include
#include
using?namespace?std;
void?Isalive();
void?initList();

class?Food
{
public:
int?x;
int?y;
bool?Iseat;//true有??false沒有產生新的
};
class?Snake
{
public:
int?n;
int?x;
int?y;
char?ch;
bool?gamestate;
bool?alive;
};
Snake*?snake?=?new?Snake;
Food?*food=new?Food;
void?initList()?
{
snake[0].x?=?0;
snake[0].y?=?0;
snake[1].x?=?1;
snake[1].y?=?0;
snake[2].x?=?2;
snake[2].y?=?0;
snake[0].n?=?3;
food->Iseat?=?false;
snake[0].alive?=?true;
snake[0].ch?=?‘w‘;
}
void?mydisplay()
{
if?(snake[0].alive?==?true)
{
glClear(GL_COLOR_BUFFER_BIT?|?GL_DEPTH_BUFFER_BIT);
glPolygonMode(GL_FRONT?GL_LINE);
glPolygonMode(GL_BACK?GL_LINE);????//設置背面為輪廓線類型
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glRotatef(45.0f45.0f?45.0f45.0f);
//邊界
glColor3f(1.0f?1.0f?1.0f);
???float?x1?=?0.9;
???float?x2?=?-0.9;
???float?y1?=?0.9;
???float?y2?=?-0.9;
???float?vertex_list[8][3]?=////?將立方體的八個頂點保存到一個數組里面?
???{
{?x2y2-0.1?}
{?x1y2-0.1?}
{?x1y1-0.1?}
{?x2y1-0.1?}
{?x2y10}
{?x2y20}
{?x1y20}
{?x1y10}
???};
???int?index_list[16]?=
???{

0123
4567
2761
3450

???};
???glEnableClientState(GL_VERTEX_ARRAY);????//啟用頂點數組
???glVertexPointer(3?GL_FLOAT?0?vertex_list);????//指定頂點數組
???glDrawElements(GL_QUADS?16?GL_UNSIGNED_INT?index_list);
???//食物
???glColor3f(1.0f?0.0f?0.0f);
???float?a1?=?food->x?/?10.0;
???float?a2?=?a1?-?0.1;
???float?b1?=?food->y?/?10.0;
???float?b2?=?b1?-?0.1;
???float?vertex_list1[8][3]?=
???{
{?a2b20?}
{?a1b20?}
{?a1b10?}
{?a2b10?}
{?a2b10.1}
{?a2b20.1}
{?a1b20.1}
{?a1b10.1}
???};
???int?index_list1[16]?=
???{
0123
4567
2761
3450
???};
???glEnableClientState(GL_VERTEX_ARRAY);????//啟用頂點數組
???glVertexPointer(3?GL_FLOAT?0?vertex_list1);????//指定頂點數組
???glDrawElements(GL_QUADS?16?GL_UNSIGNED_INT?index_list1);


???for?(int?i?=?0;?i? ???{
???if?(i?==?0)
???{
???glColor3f(1.0f?0.0f?0.0f);
???}
???else
???{
???glColor3f(0.0f?0.0f?1.0f);
???}
???float?x1?=?snake[i].x?/?10.0;
???float?x2?=?x1?-?0.1;
???float?y1?=?snake[i].y?/?10.0;
???float?y2?=?y1?-?0.1;
???float?vertex_list[8][3]?=
???{
{?x2y20?}
{?x1y20?}
{?x1y10?}
{?x2y10?}
{?x2y10.1}
{?x2y20.1}
{?x1y20.1}
{?x1y10.1}
???};
???int?index_list[16]?=
???{
0123
4567
2761
3450
???};
???//頂點數組是如何使用
???glEnableClientState(GL_VERTEX_ARRAY);????//啟用頂點數組
???glVertexPointer(3?GL_FLOAT?0?vertex_list);????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

????..A..H.?????35840??2020-03-21?12:27??貪吃蛇\.vs\opengltest\v15\.suo

?????文件???37392384??2020-03-21?23:34??貪吃蛇\.vs\opengltest\v15\Browse.VC.db

????..A..H.????????36??2020-03-21?12:18??貪吃蛇\.vs\opengltest\v15\Browse.VC.opendb

?????文件????3866624??2020-03-16?20:20??貪吃蛇\.vs\opengltest\v15\ipch\AutoPCH\921065164ffb760e\OPENGL.ipch

?????文件???74121216??2020-03-21?12:18??貪吃蛇\.vs\opengltest\v15\ipch\AutoPCH\b5de8ebafe9ef7d6\OPENGL.ipch

?????文件??????71168??2020-03-21?12:18??貪吃蛇\Debug\opengltest.exe

?????文件?????510984??2020-03-21?12:18??貪吃蛇\Debug\opengltest.ilk

?????文件?????757760??2020-03-21?12:18??貪吃蛇\Debug\opengltest.pdb

?????文件?????100273??2020-03-21?12:18??貪吃蛇\opengltest\Debug\opengl.obj

?????文件????????249??2020-03-21?12:18??貪吃蛇\opengltest\Debug\opengltest.log

?????文件???????1354??2020-03-21?12:18??貪吃蛇\opengltest\Debug\opengltest.tlog\CL.command.1.tlog

?????文件??????70028??2020-03-21?12:18??貪吃蛇\opengltest\Debug\opengltest.tlog\CL.read.1.tlog

?????文件???????1038??2020-03-21?12:18??貪吃蛇\opengltest\Debug\opengltest.tlog\CL.write.1.tlog

?????文件???????2414??2020-03-21?12:18??貪吃蛇\opengltest\Debug\opengltest.tlog\link.command.1.tlog

?????文件???????7162??2020-03-21?12:18??貪吃蛇\opengltest\Debug\opengltest.tlog\link.read.1.tlog

?????文件????????986??2020-03-21?12:18??貪吃蛇\opengltest\Debug\opengltest.tlog\link.write.1.tlog

?????文件????????214??2020-03-21?12:18??貪吃蛇\opengltest\Debug\opengltest.tlog\opengltest.lastbuildstate

?????文件?????609280??2020-03-21?12:18??貪吃蛇\opengltest\Debug\vc141.idb

?????文件?????520192??2020-03-21?12:18??貪吃蛇\opengltest\Debug\vc141.pdb

?????文件???????7957??2020-03-21?12:18??貪吃蛇\opengltest\opengl.cpp

?????文件???????6152??2020-03-10?14:58??貪吃蛇\opengltest\opengltest.vcxproj

?????文件????????951??2020-03-10?14:58??貪吃蛇\opengltest\opengltest.vcxproj.filters

?????文件????????165??2020-03-10?14:38??貪吃蛇\opengltest\opengltest.vcxproj.user

?????文件???????1443??2020-03-10?14:38??貪吃蛇\opengltest.sln

?????目錄??????????0??2020-03-22?00:14??貪吃蛇\.vs\opengltest\v15\ipch\AutoPCH\921065164ffb760e

?????目錄??????????0??2020-03-22?00:14??貪吃蛇\.vs\opengltest\v15\ipch\AutoPCH\b5de8ebafe9ef7d6

?????目錄??????????0??2020-03-22?00:14??貪吃蛇\.vs\opengltest\v15\ipch\AutoPCH

?????目錄??????????0??2020-03-22?00:14??貪吃蛇\.vs\opengltest\v15\ipch

?????目錄??????????0??2020-03-22?00:14??貪吃蛇\.vs\opengltest\v15

?????目錄??????????0??2020-03-22?00:14??貪吃蛇\opengltest\Debug\opengltest.tlog

............此處省略9個文件信息

評論

共有 條評論