【Cocos2d-x】編譯Android工程時提示error: 'GL_LINE_SMOOTH' was not declared in this scope

來源:互聯網
上載者:User

標籤:

在Cocos2d-x項目中用到了OpenGL,使用GL_LINE_SMOOTH開啟線條消除鋸齒。代碼如下:

ccDrawColor4B(50, 26, 12, 255);// 設定線寬glLineWidth(2.0f); // 啟用線段反鋸齒glEnable(GL_LINE_SMOOTH); // 畫第一條線ccDrawLine(startPoint1,endPoint);// 畫第二條線ccDrawLine(startPoint2,endPoint);// 關閉線段反鋸齒glDisable(GL_LINE_SMOOTH);
使用NDK編譯Android工程時提示error: ‘GL_LINE_SMOOTH‘ was not declared in this scope


開發環境說明:

引擎版本

Cocos2d-x2.2.1

開發工具

Visual Studio 2012

Android NDKr9

系統

windows7


error: ‘GL_LINE_SMOOTH‘ was not declared in this scope,表示GL_LINE_SMOOTH沒有找到定義。

1.於是開啟cocos2d.h,找到Android平台下與OpenGL相關的標頭檔CCGL.h


2.CCGL.h中包含了gl2.h和gl2ext.h兩個標頭檔,<>中的標頭檔表示優先在系統路徑下尋找


於是就到ndk路徑下尋找該檔案,這兩個標頭檔都在GLES2目錄下,該目錄下包含OpenGL ES2.0相關的標頭檔


查看gl2.h和glext.h後並沒有找到GL_LINE_SMOOTH的定義,表示這個可能定義在OpenGL ES1.0相關的標頭檔

3.於是到GLES目錄下去尋找


於是在gl.h標頭檔中找到了GL_LINE_SMOOTH的定義


4.在Android平台下的CCGL.h標頭檔中#include <GLES/gl.h>就可以解決這個問題了




【Cocos2d-x】編譯Android工程時提示error: 'GL_LINE_SMOOTH' was not declared in this scope

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.