I've a problem running Hasteroids, which uses GLGalore, on MorphOS, an user has reported that all textures are messed up like this:
Since all the examples that comes with GLGalore are running fine on his machine I've started to look for something in my code that could have produced this problem.
Looking at the Warp.hws example, I've found this block :
Code: Select all
Function p_Init(w, h)
fov = 170.0
p_Reshape({width = w, height = h})
gl.Disable(#GL_DEPTH_TEST)
gl.Clear(#GL_COLOR_BUFFER_BIT|#GL_DEPTH_BUFFER_BIT)
p_TexInit(1)
p_TexInit(2)
gl.ClearColor(0.3, 0.3, 0.3, 1.0)
gl.Color(1.0, 1.0, 1.0)
gl.BlendFunc(#GL_SRC_ALPHA, #GL_ONE_MINUS_SRC_ALPHA)
gl.Enable(#GL_TEXTURE_2D)
gl.TexEnv(#GL_TEXTURE_ENV, #GL_TEXTURE_ENV_MODE, #GL_REPLACE)
gl.ShadeModel(#GL_SMOOTH)
EndFunction
Code: Select all
---8<---- cutted ---
gl.ClearColor(self.ClearColor[0], self.ClearColor[1], self.ClearColor[2], self.ClearColor[3])
gl.Color(self.CommonColor[0], self.CommonColor[1], self.CommonColor[2], self.CommonColor[3])
gl.BlendFunc(self.GL_blendSrc, self.GL_blendDst)
gl.Enable(#GL_TEXTURE_2D)
gl.TexEnv(self.GL_TexEnv1, self.GL_TexEnv2)
gl.ShadeModel(self.GL_ShadeModel)
self.isInitialized = True
---8<---- cutted ---
.GL_TexEnv1 = #GL_TEXTURE_ENV_MODE
.GL_TexEnv2 = #GL_MODULATE
The first thing that I've seen is that gl.TexEnv() on the Warp example has 3 parameters instead of 2 as stated in the guide:
Code: Select all
6.136 gl.TexEnv
NAME
gl.TexEnv – set texture environment parameters
SYNOPSIS
gl.TexEnv(pname, param)
FUNCTION
A texture environment specifies how texture values are interpreted when a fragment is textured. pname can be either #GL_TEXTURE_ENV_MODE or #GL_TEXTURE_ENV_COLOR. If pname is #GL_TEXTURE_ENV_MODE, then param must be the symbolic name of a texture function. Four texture functions may be specified: #GL_MODULATE, #GL_DECAL, #GL_BLEND, and #GL_REPLACE.
A texture function acts on the fragment to be textured using the texture image value that applies to the fragment (See Section 6.141 [gl.TexParameter], page 199, for details.) and produces an RGBA color for that fragment. See an OpenGL reference manual for information on how the RGBA color is produced for each of the three texture functions that can be chosen.
If pname is #GL_TEXTURE_ENV_COLOR, param must be a table containing an array that holds an RGBA color consisting of four floating-point values.
#GL_TEXTURE_ENV_MODE defaults to #GL_MODULATE and #GL_TEXTURE_ENV_COLOR defaults to (0, 0, 0, 0)
Please consult an OpenGL reference manual for more information.
INPUTS
- pname specifies the symbolic name of a texture environment parameter (see above)
- param table or single value specifying the parameter
ERRORS
#GL_INVALID_ENUM is generated when pname is not one of the accepted defined values, or when param should have a defined constant value (based on the value of pname) and does not.
#GL_INVALID_OPERATION is generated if gl.TexEnv() is executed between the execution of gl.Begin() and the corresponding execution of gl.End().
ASSOCIATED GETS
gl.GetTexEnv()
- Could it be possible that the gl.TexEnv() is causing the texture problem on MOS? On Windows it works just fine.
- What is the right syntax of gl.TexEnv() : it uses two parameters or three?
- #GL_TEXTURE_ENV isn't mentioned anywhere in the manual
Sorry for the long post