这是我的源代码https://paste.fedoraproject.org/428184/89404314/
我得到的错误是:
@Override
public void onLoopjTaskCompletedBarometro(ArrayList<JSONObject> arrayJSONObjects) {
String temperatura = null;
String presion = null;
String fecha = null;
String Id = null;
String altitud = null;
JSONObject date = null;
int index = 0;
for (JSONObject jsonObject : arrayJSONObjects) {
try {
Id = jsonObject.getString("Id_temp");
temperatura = jsonObject.getString("temperatura");
fecha = jsonObject.getString("Insertado_temp");
presion = jsonObject.getString("presion");
altitud = jsonObject.getString("altitud");
} catch (JSONException e) {
e.printStackTrace();
}
Medicion medicion = new Medicion(temperatura, presion, fecha, Id);
if (!mediciones.contains(medicion)) {
mediciones.add(medicion);
temperaturas.add(new Entry(Float.valueOf(index), Float.valueOf(medicion.getTemperatura())));
presiones.add(new Entry(Float.valueOf(index), Float.valueOf(medicion.getPresion())));
dates.add(fecha); // reduce the string to just 12:13 etc
index++;
}
}
for (Medicion temporaryMed : mediciones) {
Log.i(UtilitiesGlobal.TAG, "onLoopjTaskCompletedBarometro: listado sin dobles "
+ temporaryMed.getId());
Log.i(UtilitiesGlobal.TAG, "onSuccess: loopj "
+ "temperatura: " + temporaryMed.getTemperatura()
+ " presion: " + temporaryMed.getPresion()
+ " Fecha Inserción: " + temporaryMed.getFecha());
}
dir(着色器)具有以下功能:
C:\Python27>python.exe wx_gl_vbo_001.py
Traceback (most recent call last):
File "wx_gl_vbo_001.py", line 63, in <module>
MyApp(redirect = False).MainLoop()
File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_core.py", line 8628, in __init__
self._BootstrapApp()
File "C:\Python27\lib\site-packages\wx-3.0-msw\wx\_core.py", line 8196, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "wx_gl_vbo_001.py", line 60, in OnInit
canvas = MyCanvas(frame)
File "wx_gl_vbo_001.py", line 16, in __init__
}""", GL_VERTEX_SHADER)
File "C:\Python27\lib\site-packages\OpenGL\latebind.py", line 44, in __call__
self._finalCall = self.finalise()
File "C:\Python27\lib\site-packages\OpenGL\extensions.py", line 245, in finalise
self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined alternate function (glCompileShader, glCompileShaderARB), check for bool(glCompileShader) before calling
答案 0 :(得分:1)
很抱歉这么晚才回复你。这是一个使用wxpython工具包(我以前从未尝试过)使用opengl呈现三角形的演示。除了我在评论中注意到的内容之外,我还看到你没有使用vbo数组的全部内容,并且代码中的某些内容(如“self.haveInited”)不是必需的。这是一个使用OpenGL 2.1呈现vbo三角形的示例。
import wx
from wx import glcanvas
import sys
from OpenGL.GL import *
from OpenGL.arrays import vbo
from OpenGL.GL import shaders
import numpy as np
class MyCanvas(glcanvas.GLCanvas):
def __init__(self, parent):
glcanvas.GLCanvas.__init__(self, parent, -1)
self.context = glcanvas.GLContext(self)
self.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, event):
dc = wx.PaintDC(self)
self.SetCurrent(self.context)
self.InitGL()
self.OnDraw()
def InitGL(self):
glClearColor(0, 0, 0, 1)
VERTEX_SHADER = shaders.compileShader("""
#version 120
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
""", GL_VERTEX_SHADER)
FRAGMENT_SHADER = shaders.compileShader("""
#version 120
void main()
{
gl_FragColor = vec4(0, 1, 0, 1);
}
""", GL_FRAGMENT_SHADER)
self.shader = shaders.compileProgram(VERTEX_SHADER,FRAGMENT_SHADER)
self.vbo = vbo.VBO(np.array([
[ 0, 1, 0 ],
[ -1,-1, 0 ],
[ 1,-1, 0 ],
],'f'))
def OnDraw(self):
self.OnSize()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
shaders.glUseProgram(self.shader)
self.vbo.bind()
glEnableClientState(GL_VERTEX_ARRAY)
glVertexPointerf(self.vbo)
glDrawArrays(GL_TRIANGLES, 0, 9)
self.vbo.unbind()
glDisableClientState(GL_VERTEX_ARRAY)
shaders.glUseProgram(0)
self.SwapBuffers()
def OnSize(self):
size = self.size = self.GetClientSize()
glViewport(0, 0, size.width, size.height)
class MyApp(wx.App):
def __init__(self):
wx.App.__init__(self)
def OnInit(self):
frame = wx.Frame(None, title="OpenGL Test", size=(400, 300))
frame.Show(True)
c = MyCanvas(frame)
return True
app = MyApp()
app.MainLoop()
希望它有所帮助!