Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 44
Registered: ‎05-22-2013
My Device: Blackberry 10
My Carrier: 02

Cascade-OpenGL ES texture proplem.

I am using cascade/openGL ES for a 2D map app. I follow the GoodCitizenCascade sample where I am reusing the OpenGLThread and OpenGLView classes. I seem to be having a texture cach problem, the image does not change even if I change the image address.

 

I have included my applicationUI constructor, my main.qml and my MapView::Render class, it extends the OpenGLView class.

 

ApplicationUI::ApplicationUI()
{
	Application::instance()->setAutoExit(false);

	//Connect app manual exit signal to our app shutdown slot.
	QObject::connect(
			Application::instance(),
			SIGNAL(manualExit()),
			this,
			SLOT(shutdown()));

    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole application lifetime
    QmlDocument *qml = QmlDocument::create("asset:///main.qml");

    if ( !qml->hasErrors() ) {
    	OpenGLView::setRenderingAPI(GL_ES_1);

    	m_pMapView = new MapView(DISPLAY_DEVICE);

    	qml->setContextProperty("_mapView", m_pMapView);

    	//The apps navigation pane is created from qml.
    	m_navPane = qml->createRootObject<NavigationPane>();
    	if (m_navPane) {
    		m_fwBound = false;
    		m_pForeignWindowControl = m_navPane->findChild<ForeignWindowControl*>("mapViewFW");

    		LayoutUpdateHandler *handler = LayoutUpdateHandler::create(m_pForeignWindowControl)
    			.onLayoutFrameChanged(this, SLOT(onLayoutFrameChanged(const QRectF &)));

    		Q_UNUSED(handler);

    		// connect ForeignWindowControl signals to MapView slots
    		QObject::connect( m_pForeignWindowControl, SIGNAL(touch(bb::cascades::TouchEvent *)),
    				m_pMapView, SLOT(onTouch(bb::cascades::TouchEvent)) );

        	// Finally the main scene for the application is set the Page.
        	Application::instance()->setScene(m_navPane);
    	}

    }

}

 

NavigationPane {
    id: nav
    
    Page {
        id: page
        
        //background container.
        content: Container {
            id: bg
            
            objectName: "bg"
            background: Color.create("#262626")
            horizontalAlignment: HorizontalAlignment.Fill
            verticalAlignment: VerticalAlignment.Fill
            
            layout: StackLayout {
                orientation: LayoutOrientation.TopToBottom
            }
            
            ForeignWindowControl {
                id: foreignWindow
                objectName: "mapViewFW"
                visible: true
                horizontalAlignment: HorizontalAlignment.Fill
                verticalAlignment: VerticalAlignment.Fill
            }
        }

 

void MapView::render()
{
	//Typical render pass
	glClearColor(0.775f, 0.775f, 0.775f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// first render background and menu if it is enabled
	enable_2D();

	glEnable(GL_TEXTURE_2D);

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	//glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

	//Then draw tiles
	drawTile(image_texure, 0.0f, 0.0f, 0.0f, 256.0f, 1.0f, 1.0f);


	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glDeleteTextures(1, &image_texure);

	glDisable(GL_TEXTURE_2D);

	//Use utility code to update the screen
	swapBuffers();

	// after rendering this view is no longer stale
	setStale(false);

}

/*
 * Draw tile method
 */
void MapView::drawTile(GLuint tile_texture, float x, float y, float z, float d, float tex_x, float tex_y)
{
	GLfloat tile_vertices[] = {x,y + d,z,    x + d,y + d,z,     x + d, y, z,   x,y,z}; //vertices for the tile's grid.
	GLfloat tile_tex_coord[] = {0.0f, tex_y,   0.0f, 0.0f,   tex_x, tex_y,   tex_x, 0.0f};  //coordinates for the tile texture.

	glVertexPointer(3, GL_FLOAT, 0, tile_vertices);
	glTexCoordPointer(2, GL_FLOAT, 0, tile_tex_coord);
	glBindTexture(GL_TEXTURE_2D, tile_texture);

	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

	//Added to see if gets here.
	qDebug()  << "drawing tiles ";

}

 the qDebug()  << "drawing tiles "; in drawTile keeps displaying on the console while the eventloop is still running indicating the draw function is actually called.

 

Highlighted
Developer
Posts: 44
Registered: ‎05-22-2013
My Device: Blackberry 10
My Carrier: 02

Re: Cascade-OpenGL ES texture proplem.

pls help I really need to get this working, its holding me down and am a newbie to OpenGL